From ac203dda1faca12e6e1196d3136aa0e745b6a9e4 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 20 Jul 2021 16:46:51 +0100 Subject: [PATCH] (#14) Perform solution-wide code cleanup --- X10D/src/ByteExtensions/SByteExtensions.cs | 4 +-- .../ComparableExtensions.cs | 30 +++++++++---------- .../DictionaryExtensions.cs | 5 +--- X10D/src/DoubleExtensions/DoubleExtensions.cs | 4 +-- .../EnumerableExtensions.cs | 4 +-- X10D/src/Int64Extensions/Int64Extensions.cs | 5 ++-- X10D/src/RandomExtensions/RandomExtensions.cs | 6 ++-- .../MemberInfoExtensions.cs | 5 ++-- X10D/src/SingleExtensions/SingleExtensions.cs | 4 +-- X10D/src/StreamExtensions/StreamExtensions.cs | 4 +-- X10D/src/StringExtensions/StringExtensions.cs | 8 ++--- X10D/src/TimeSpanParser.cs | 4 +-- 12 files changed, 41 insertions(+), 42 deletions(-) diff --git a/X10D/src/ByteExtensions/SByteExtensions.cs b/X10D/src/ByteExtensions/SByteExtensions.cs index b7d242f..9e0398e 100644 --- a/X10D/src/ByteExtensions/SByteExtensions.cs +++ b/X10D/src/ByteExtensions/SByteExtensions.cs @@ -60,13 +60,13 @@ namespace X10D /// /// byte[] bytes = { byte.MinValue, 100, 200, byte.MaxValue }; /// bool result; - /// + /// /// foreach (byte value in bytes) /// { /// result = value.ToBoolean(); /// Console.WriteLine("{0, -5} --> {1}", value, result); /// } - /// + /// /// // The example displays the following output: /// // 0 --> False /// // 100 --> True diff --git a/X10D/src/ComparableExtensions/ComparableExtensions.cs b/X10D/src/ComparableExtensions/ComparableExtensions.cs index efddf64..857cee1 100644 --- a/X10D/src/ComparableExtensions/ComparableExtensions.cs +++ b/X10D/src/ComparableExtensions/ComparableExtensions.cs @@ -18,8 +18,8 @@ namespace X10D /// The exclusive lower bound. /// The exclusive upper bound. /// - /// if is between the and - /// + /// if is between the and + /// /// -or- /// otherwise. /// @@ -30,13 +30,13 @@ namespace X10D /// /// int lower = 0; /// int upper = 20; - /// + /// /// Console.WriteLine($"{firstValue} between {lower} and {upper}?"); /// Console.WriteLine(firstValue.Between(lower, upper)); /// /// Console.WriteLine($"{secondValue} between {lower} and {upper}?"); /// Console.WriteLine(secondValue.Between(lower, upper)); - /// + /// /// // This will output the following: /// // 42 between 0 and 20? /// // False @@ -84,7 +84,7 @@ namespace X10D /// int value = 42; /// int lower = 0; /// int upper = 20; - /// + /// /// int clamped = value.Clamp(lower, upper); /// // clamped will be 20 /// @@ -112,13 +112,13 @@ namespace X10D /// /// if is greater than /// -or- - /// otherwise. + /// otherwise. /// /// /// /// int first = 5; /// int second = 10; - /// + /// /// bool result = first.GreaterThan(second); /// // result will be False /// @@ -144,13 +144,13 @@ namespace X10D /// /// if is greater than or equal to /// -or- - /// otherwise. + /// otherwise. /// /// /// /// int first = 5; /// int second = 10; - /// + /// /// bool result = first.GreaterThanOrEqualTo(second); /// // result will be False /// @@ -176,13 +176,13 @@ namespace X10D /// /// if is less than /// -or- - /// otherwise. + /// otherwise. /// /// /// /// int first = 5; /// int second = 10; - /// + /// /// bool result = first.LessThan(second); /// // result will be True /// @@ -208,13 +208,13 @@ namespace X10D /// /// if is less than or equal to /// -or- - /// otherwise. + /// otherwise. /// /// /// /// int first = 5; /// int second = 10; - /// + /// /// bool result = first.LessThanOrEqualTo(second); /// // result will be True /// @@ -245,7 +245,7 @@ namespace X10D /// /// int first = 5; /// int second = 10; - /// + /// /// int max = first.Max(second); /// // max will be 10 /// @@ -276,7 +276,7 @@ namespace X10D /// /// int first = 5; /// int second = 10; - /// + /// /// int min = first.Min(second); /// // min will be 5 /// diff --git a/X10D/src/DictionaryExtensions/DictionaryExtensions.cs b/X10D/src/DictionaryExtensions/DictionaryExtensions.cs index fbbe369..4040460 100644 --- a/X10D/src/DictionaryExtensions/DictionaryExtensions.cs +++ b/X10D/src/DictionaryExtensions/DictionaryExtensions.cs @@ -54,9 +54,6 @@ namespace X10D return string.Join(";", list); } - /// A representing the dictionary as a key=value; set. - /// - /// /// /// Converts an of to a HTTP GET parameter /// string. @@ -64,7 +61,7 @@ namespace X10D /// The key type. /// The value type. /// The source dictionary. - /// Returns a representing the dictionary as a key=value& set. + /// Returns a representing the dictionary as a key=value& set. public static string ToGetParameters(this IEnumerable> value) { if (value is null) diff --git a/X10D/src/DoubleExtensions/DoubleExtensions.cs b/X10D/src/DoubleExtensions/DoubleExtensions.cs index 1b562e5..2de42d6 100644 --- a/X10D/src/DoubleExtensions/DoubleExtensions.cs +++ b/X10D/src/DoubleExtensions/DoubleExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.CompilerServices; namespace X10D @@ -124,7 +124,7 @@ namespace X10D /// /// The value to round. /// The nearest multiple to which should be rounded. - /// rounded to the nearest multiple of . + /// rounded to the nearest multiple of . public static double Round(this double value, double nearest) { return Math.Round(value / nearest) * nearest; diff --git a/X10D/src/EnumerableExtensions/EnumerableExtensions.cs b/X10D/src/EnumerableExtensions/EnumerableExtensions.cs index 021cc33..9fd9bbf 100644 --- a/X10D/src/EnumerableExtensions/EnumerableExtensions.cs +++ b/X10D/src/EnumerableExtensions/EnumerableExtensions.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; namespace X10D @@ -29,7 +29,7 @@ namespace X10D /// The maximum length of the nested collection. /// /// An containing an of - /// whose lengths are no greater than . + /// whose lengths are no greater than . /// public static IEnumerable> Split(this IEnumerable value, int chunkSize) { diff --git a/X10D/src/Int64Extensions/Int64Extensions.cs b/X10D/src/Int64Extensions/Int64Extensions.cs index 721cc83..2789a69 100644 --- a/X10D/src/Int64Extensions/Int64Extensions.cs +++ b/X10D/src/Int64Extensions/Int64Extensions.cs @@ -21,7 +21,7 @@ namespace X10D { return DateTimeOffset.FromUnixTimeMilliseconds(value); } - + /// /// Converts a Unix time expressed as the number of seconds that have elapsed since 1970-01-01T00:00:00Z to a /// value. @@ -35,7 +35,7 @@ namespace X10D { return DateTimeOffset.FromUnixTimeSeconds(value); } - + /// /// Returns the current 64-bit signed integer value as an array of bytes. /// @@ -45,6 +45,7 @@ namespace X10D { return BitConverter.GetBytes(value); } + /// /// Returns a value indicating whether the current value is evenly divisible by 2. /// diff --git a/X10D/src/RandomExtensions/RandomExtensions.cs b/X10D/src/RandomExtensions/RandomExtensions.cs index 483ce4b..7f37561 100644 --- a/X10D/src/RandomExtensions/RandomExtensions.cs +++ b/X10D/src/RandomExtensions/RandomExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Drawing; using System.Globalization; @@ -58,7 +58,7 @@ namespace X10D } /// - /// Returns a random color + /// Returns a random color. /// /// /// @@ -212,7 +212,7 @@ namespace X10D /// /// A 64-bit signed integer that is greater than or equal to 0, and less than ; that is, /// the range of return values ordinarily includes 0 but not . However, if - /// equals 0, is returned. + /// equals 0, is returned. /// /// must be greater than or equal to 0. /// is . diff --git a/X10D/src/ReflectionExtensions/MemberInfoExtensions.cs b/X10D/src/ReflectionExtensions/MemberInfoExtensions.cs index 01b66d9..a661b9b 100644 --- a/X10D/src/ReflectionExtensions/MemberInfoExtensions.cs +++ b/X10D/src/ReflectionExtensions/MemberInfoExtensions.cs @@ -77,8 +77,9 @@ namespace X10D /// -or- /// is . /// - public static TReturn? SelectFromCustomAttribute(this MemberInfo member, - Func selector) + public static TReturn? SelectFromCustomAttribute( + this MemberInfo member, + Func selector) where TAttribute : Attribute { if (member is null) diff --git a/X10D/src/SingleExtensions/SingleExtensions.cs b/X10D/src/SingleExtensions/SingleExtensions.cs index 6a1452d..f86584d 100644 --- a/X10D/src/SingleExtensions/SingleExtensions.cs +++ b/X10D/src/SingleExtensions/SingleExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.CompilerServices; namespace X10D @@ -124,7 +124,7 @@ namespace X10D /// /// The value to round. /// The nearest multiple to which should be rounded. - /// rounded to the nearest multiple of . + /// rounded to the nearest multiple of . public static float Round(this float value, float nearest) { return (float)((double)value).Round(nearest); diff --git a/X10D/src/StreamExtensions/StreamExtensions.cs b/X10D/src/StreamExtensions/StreamExtensions.cs index 3f88da6..3a6b6a5 100644 --- a/X10D/src/StreamExtensions/StreamExtensions.cs +++ b/X10D/src/StreamExtensions/StreamExtensions.cs @@ -1,9 +1,9 @@ using System; +using System.IO; +using System.Security.Cryptography; #if NET5_0 using System.Buffers.Binary; #endif -using System.IO; -using System.Security.Cryptography; namespace X10D { diff --git a/X10D/src/StringExtensions/StringExtensions.cs b/X10D/src/StringExtensions/StringExtensions.cs index 0c64baf..5b4b87b 100644 --- a/X10D/src/StringExtensions/StringExtensions.cs +++ b/X10D/src/StringExtensions/StringExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -134,14 +134,14 @@ namespace X10D throw new ArgumentException(Resource.EnumParseEmptyStringException, nameof(value)); } - var t = typeof(T); + var type = typeof(T); - if (!t.IsEnum) + if (!type.IsEnum) { throw new ArgumentException(Resource.EnumParseNotEnumException); } - return (T)Enum.Parse(t, value, ignoreCase); + return (T)Enum.Parse(type, value, ignoreCase); } /// diff --git a/X10D/src/TimeSpanParser.cs b/X10D/src/TimeSpanParser.cs index e681f57..270f509 100644 --- a/X10D/src/TimeSpanParser.cs +++ b/X10D/src/TimeSpanParser.cs @@ -45,8 +45,8 @@ namespace X10D { parsedResult = 0; - return match.Groups[@group].Success - && double.TryParse(match.Groups[@group].Value, NumberStyles.Number, provider, out parsedResult); + return match.Groups[group].Success + && double.TryParse(match.Groups[group].Value, NumberStyles.Number, provider, out parsedResult); } if (!TryParseAt(1, out var years))