diff --git a/src/Common/src/System/Numerics/Hashing/HashHelpers.cs b/src/Common/src/System/Numerics/Hashing/HashHelpers.cs index 841eb04d8747..8a396e5f7ddf 100644 --- a/src/Common/src/System/Numerics/Hashing/HashHelpers.cs +++ b/src/Common/src/System/Numerics/Hashing/HashHelpers.cs @@ -19,4 +19,4 @@ public static int Combine(int h1, int h2) } } } -} \ No newline at end of file +} diff --git a/src/Common/tests/System/Buffers/NativeMemoryManager.cs b/src/Common/tests/System/Buffers/NativeMemoryManager.cs index 45488aafcf5f..7ff721a1c08c 100644 --- a/src/Common/tests/System/Buffers/NativeMemoryManager.cs +++ b/src/Common/tests/System/Buffers/NativeMemoryManager.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Buffers; using System.Diagnostics; using System.Runtime.InteropServices; @@ -55,7 +54,8 @@ public bool IsRetained public override unsafe MemoryHandle Pin(int elementIndex = 0) { - if (elementIndex < 0 || elementIndex > _length) throw new ArgumentOutOfRangeException(nameof(elementIndex)); + if (elementIndex < 0 || elementIndex > _length) + throw new ArgumentOutOfRangeException(nameof(elementIndex)); lock (this) { diff --git a/src/System.Memory/src/System/Buffers/ArrayMemoryPool.ArrayMemoryPoolBuffer.cs b/src/System.Memory/src/System/Buffers/ArrayMemoryPool.ArrayMemoryPoolBuffer.cs index a5b68a25b040..b3a28701b60d 100644 --- a/src/System.Memory/src/System/Buffers/ArrayMemoryPool.ArrayMemoryPoolBuffer.cs +++ b/src/System.Memory/src/System/Buffers/ArrayMemoryPool.ArrayMemoryPoolBuffer.cs @@ -2,14 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Runtime.InteropServices; - -#if !netstandard -using Internal.Runtime.CompilerServices; -#else -using System.Runtime.CompilerServices; -#endif - namespace System.Buffers { internal sealed partial class ArrayMemoryPool : MemoryPool diff --git a/src/System.Memory/src/System/Buffers/ArrayMemoryPool.cs b/src/System.Memory/src/System/Buffers/ArrayMemoryPool.cs index 5d8e0911d927..ab77292ca707 100644 --- a/src/System.Memory/src/System/Buffers/ArrayMemoryPool.cs +++ b/src/System.Memory/src/System/Buffers/ArrayMemoryPool.cs @@ -12,14 +12,15 @@ namespace System.Buffers { internal sealed partial class ArrayMemoryPool : MemoryPool { - private const int s_maxBufferSize = int.MaxValue; - public sealed override int MaxBufferSize => s_maxBufferSize; + private const int MaximumBufferSize = int.MaxValue; + + public sealed override int MaxBufferSize => MaximumBufferSize; public sealed override IMemoryOwner Rent(int minimumBufferSize = -1) { if (minimumBufferSize == -1) minimumBufferSize = 1 + (4095 / Unsafe.SizeOf()); - else if (((uint)minimumBufferSize) > s_maxBufferSize) + else if (((uint)minimumBufferSize) > MaximumBufferSize) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.minimumBufferSize); return new ArrayMemoryPoolBuffer(minimumBufferSize); diff --git a/src/System.Memory/src/System/Buffers/Text/Base64Decoder.cs b/src/System.Memory/src/System/Buffers/Text/Base64Decoder.cs index 29525d5c972f..d012299e7dcd 100644 --- a/src/System.Memory/src/System/Buffers/Text/Base64Decoder.cs +++ b/src/System.Memory/src/System/Buffers/Text/Base64Decoder.cs @@ -147,7 +147,7 @@ public static OperationStatus DecodeFromUtf8(ReadOnlySpan utf8, Span if (srcLength != utf8.Length) goto InvalidExit; - DoneExit: + DoneExit: bytesConsumed = sourceIndex; bytesWritten = destIndex; return OperationStatus.Done; diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Constants.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Constants.cs index bfbbdef8a48d..e2f70f0b10e9 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Constants.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Constants.cs @@ -20,8 +20,8 @@ internal static partial class Utf8Constants // Invariant formatting uses groups of 3 for each number group separated by commas. // ex. 1,234,567,890 public const int GroupSize = 3; - - public static readonly TimeSpan s_nullUtcOffset = TimeSpan.MinValue; // Utc offsets must range from -14:00 to 14:00 so this is never a valid offset. + + public static readonly TimeSpan NullUtcOffset = TimeSpan.MinValue; // Utc offsets must range from -14:00 to 14:00 so this is never a valid offset. public const int DateTimeMaxUtcOffsetHours = 14; // The UTC offset portion of a TimeSpan or DateTime can be no more than 14 hours and no less than -14 hours. diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Boolean.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Boolean.cs index e5bc21918e0a..b6452d24c6e8 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Boolean.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Boolean.cs @@ -94,11 +94,11 @@ public static bool TryFormat(bool value, Span destination, out int bytesWr return true; } -BufferTooSmall: + BufferTooSmall: bytesWritten = 0; return false; -BadFormat: + BadFormat: return ThrowHelper.TryFormatThrowFormatException(out bytesWritten); } } diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Date.G.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Date.G.cs index 7aad6fef0f03..7c4a2e342d89 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Date.G.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Date.G.cs @@ -25,7 +25,7 @@ private static bool TryFormatDateTimeG(DateTime value, TimeSpan offset, Span destination, o return false; } - var dayAbbrev = DayAbbreviationsLowercase[(int)value.DayOfWeek]; + uint dayAbbrev = s_dayAbbreviationsLowercase[(int)value.DayOfWeek]; destination[0] = (byte)dayAbbrev; dayAbbrev >>= 8; @@ -35,7 +35,7 @@ private static bool TryFormatDateTimeL(DateTime value, Span destination, o FormattingHelpers.WriteTwoDecimalDigits((uint)value.Day, destination, 5); destination[7] = Utf8Constants.Space; - var monthAbbrev = MonthAbbreviationsLowercase[value.Month - 1]; + uint monthAbbrev = s_monthAbbreviationsLowercase[value.Month - 1]; destination[8] = (byte)monthAbbrev; monthAbbrev >>= 8; destination[9] = (byte)monthAbbrev; diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Date.O.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Date.O.cs index 5a2a7bfadbc5..d9b7b181bc44 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Date.O.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Date.O.cs @@ -22,7 +22,7 @@ private static bool TryFormatDateTimeO(DateTime value, TimeSpan offset, Span destination, o return false; } - var dayAbbrev = DayAbbreviations[(int)value.DayOfWeek]; + uint dayAbbrev = s_dayAbbreviations[(int)value.DayOfWeek]; destination[0] = (byte)dayAbbrev; dayAbbrev >>= 8; @@ -35,7 +35,7 @@ private static bool TryFormatDateTimeR(DateTime value, Span destination, o FormattingHelpers.WriteTwoDecimalDigits((uint)value.Day, destination, 5); destination[7] = Utf8Constants.Space; - var monthAbbrev = MonthAbbreviations[value.Month - 1]; + uint monthAbbrev = s_monthAbbreviations[value.Month - 1]; destination[8] = (byte)monthAbbrev; monthAbbrev >>= 8; destination[9] = (byte)monthAbbrev; diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Date.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Date.cs index 6b188ff11707..5fbf3b736209 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Date.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Date.cs @@ -19,7 +19,7 @@ public static partial class Utf8Formatter // The three-letter abbreviation is packed into a 24-bit unsigned integer // where the least significant byte represents the first letter. - private static readonly uint[] DayAbbreviations = new uint[] + private static readonly uint[] s_dayAbbreviations = new uint[] { 'S' + ('u' << 8) + ('n' << 16), 'M' + ('o' << 8) + ('n' << 16), @@ -30,7 +30,7 @@ public static partial class Utf8Formatter 'S' + ('a' << 8) + ('t' << 16), }; - private static readonly uint[] DayAbbreviationsLowercase = new uint[] + private static readonly uint[] s_dayAbbreviationsLowercase = new uint[] { 's' + ('u' << 8) + ('n' << 16), 'm' + ('o' << 8) + ('n' << 16), @@ -41,7 +41,7 @@ public static partial class Utf8Formatter 's' + ('a' << 8) + ('t' << 16) }; - private static readonly uint[] MonthAbbreviations = new uint[] + private static readonly uint[] s_monthAbbreviations = new uint[] { 'J' + ('a' << 8) + ('n' << 16), 'F' + ('e' << 8) + ('b' << 16), @@ -57,7 +57,7 @@ public static partial class Utf8Formatter 'D' + ('e' << 8) + ('c' << 16), }; - private static readonly uint[] MonthAbbreviationsLowercase = new uint[] + private static readonly uint[] s_monthAbbreviationsLowercase = new uint[] { 'j' + ('a' << 8) + ('n' << 16), 'f' + ('e' << 8) + ('b' << 16), @@ -97,7 +97,7 @@ public static partial class Utf8Formatter /// public static bool TryFormat(DateTimeOffset value, Span destination, out int bytesWritten, StandardFormat format = default) { - TimeSpan offset = Utf8Constants.s_nullUtcOffset; + TimeSpan offset = Utf8Constants.NullUtcOffset; char symbol = format.Symbol; if (format.IsDefault) { @@ -158,10 +158,10 @@ public static bool TryFormat(DateTime value, Span destination, out int byt return TryFormatDateTimeL(value, destination, out bytesWritten); case 'O': - return TryFormatDateTimeO(value, Utf8Constants.s_nullUtcOffset, destination, out bytesWritten); + return TryFormatDateTimeO(value, Utf8Constants.NullUtcOffset, destination, out bytesWritten); case 'G': - return TryFormatDateTimeG(value, Utf8Constants.s_nullUtcOffset, destination, out bytesWritten); + return TryFormatDateTimeG(value, Utf8Constants.NullUtcOffset, destination, out bytesWritten); default: return ThrowHelper.TryFormatThrowFormatException(out bytesWritten); diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Decimal.G.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Decimal.G.cs index b8aa6d75efae..e9149ad8a917 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Decimal.G.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Decimal.G.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Diagnostics; -using System.Runtime.CompilerServices; namespace System.Buffers.Text { diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Integer.Signed.Default.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Integer.Signed.Default.cs index 961c75a685d9..69cf16999c18 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Integer.Signed.Default.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.Integer.Signed.Default.cs @@ -19,7 +19,7 @@ private static bool TryFormatInt64Default(long value, Span destination, ou { return TryFormatUInt32SingleDigit((uint)value, destination, out bytesWritten); } - + if (IntPtr.Size == 8) // x64 { return TryFormatInt64MultipleDigits(value, destination, out bytesWritten); @@ -34,13 +34,13 @@ private static bool TryFormatInt64Default(long value, Span destination, ou { if (value <= (long)Utf8Constants.BillionMaxUIntValue && value >= -(long)Utf8Constants.BillionMaxUIntValue) { - return value < 0 ? + return value < 0 ? TryFormatInt64MoreThanNegativeBillionMaxUInt(-value, destination, out bytesWritten) : - TryFormatUInt64LessThanBillionMaxUInt((ulong)value, destination, out bytesWritten); + TryFormatUInt64LessThanBillionMaxUInt((ulong)value, destination, out bytesWritten); } else { - return value < 0 ? + return value < 0 ? TryFormatInt64LessThanNegativeBillionMaxUInt(-value, destination, out bytesWritten) : TryFormatUInt64MoreThanBillionMaxUInt((ulong)value, destination, out bytesWritten); } diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.TimeSpan.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.TimeSpan.cs index 3f40291e46ec..1e29383bf7b9 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.TimeSpan.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.TimeSpan.cs @@ -62,7 +62,7 @@ public static bool TryFormat(TimeSpan value, Span destination, out int byt ticks = -ticks; if (ticks < 0) { - Debug.Assert(ticks == Int64.MinValue /* -9223372036854775808 */); + Debug.Assert(ticks == long.MinValue /* -9223372036854775808 */); // We computed these ahead of time; they're straight from the decimal representation of Int64.MinValue. fraction = 4775808; @@ -75,7 +75,7 @@ public static bool TryFormat(TimeSpan value, Span destination, out int byt fraction = (uint)fraction64; } -AfterComputeFraction: + AfterComputeFraction: int fractionDigits = 0; if (symbol == 'c') @@ -131,7 +131,7 @@ public static bool TryFormat(TimeSpan value, Span destination, out int byt Debug.Assert(minutes < 60); // At this point, we can switch over to 32-bit divmod since the data has shrunk far enough. - Debug.Assert(totalHoursRemaining <= UInt32.MaxValue); + Debug.Assert(totalHoursRemaining <= uint.MaxValue); uint days = 0; uint hours = 0; diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Date.G.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Date.G.cs index ed18c7ba3115..6e8edbcbdf85 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Date.G.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Date.G.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Diagnostics; - namespace System.Buffers.Text { public static partial class Utf8Parser diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Date.Helpers.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Date.Helpers.cs index b284ba548852..d2fb06829a6f 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Date.Helpers.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Date.Helpers.cs @@ -156,7 +156,7 @@ private static bool TryCreateDateTime(int year, int month, int day, int hour, in return true; } - private static readonly int[] s_daysToMonth365 = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; - private static readonly int[] s_daysToMonth366 = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366}; + private static readonly int[] s_daysToMonth365 = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }; + private static readonly int[] s_daysToMonth366 = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }; } } diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Float.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Float.cs index b00ae277eece..8d178e296018 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Float.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Float.cs @@ -40,7 +40,7 @@ public static bool TryParse(ReadOnlySpan source, out float value, out int return true; } - return TryParseAsSpecialFloatingPoint(source, float.PositiveInfinity, float.NegativeInfinity, float.NaN, out value, out bytesConsumed); + return TryParseAsSpecialFloatingPoint(source, float.PositiveInfinity, float.NegativeInfinity, float.NaN, out value, out bytesConsumed); } /// @@ -68,7 +68,7 @@ public static bool TryParse(ReadOnlySpan source, out double value, out int if (TryParseNormalAsFloatingPoint(source, out value, out bytesConsumed, standardFormat)) return true; - return TryParseAsSpecialFloatingPoint(source, double.PositiveInfinity, double.NegativeInfinity, double.NaN, out value, out bytesConsumed); + return TryParseAsSpecialFloatingPoint(source, double.PositiveInfinity, double.NegativeInfinity, double.NaN, out value, out bytesConsumed); } // diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Integer.Signed.N.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Integer.Signed.N.cs index e08704159892..fd8ce572f271 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Integer.Signed.N.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Integer.Signed.N.cs @@ -65,7 +65,7 @@ private static bool TryParseSByteN(ReadOnlySpan source, out sbyte value, o goto FalseExit; // Overflow } -FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. + FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. answer = 0; index++; if ((uint)index >= (uint)source.Length) @@ -73,7 +73,7 @@ private static bool TryParseSByteN(ReadOnlySpan source, out sbyte value, o if (source[index] != '0') goto FalseExit; -FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. + FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. do { index++; @@ -87,12 +87,12 @@ private static bool TryParseSByteN(ReadOnlySpan source, out sbyte value, o goto FalseExit; // The fractional portion contained a non-zero digit. Treat this as an error, not an early termination. goto Done; -FalseExit: + FalseExit: bytesConsumed = default; value = default; return false; -Done: + Done: bytesConsumed = index; value = (sbyte)(answer * sign); return true; @@ -157,7 +157,7 @@ private static bool TryParseInt16N(ReadOnlySpan source, out short value, o goto FalseExit; // Overflow } -FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. + FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. answer = 0; index++; if ((uint)index >= (uint)source.Length) @@ -165,7 +165,7 @@ private static bool TryParseInt16N(ReadOnlySpan source, out short value, o if (source[index] != '0') goto FalseExit; -FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. + FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. do { index++; @@ -179,12 +179,12 @@ private static bool TryParseInt16N(ReadOnlySpan source, out short value, o goto FalseExit; // The fractional portion contained a non-zero digit. Treat this as an error, not an early termination. goto Done; -FalseExit: + FalseExit: bytesConsumed = default; value = default; return false; -Done: + Done: bytesConsumed = index; value = (short)(answer * sign); return true; @@ -252,7 +252,7 @@ private static bool TryParseInt32N(ReadOnlySpan source, out int value, out goto FalseExit; // Overflow } -FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. + FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. answer = 0; index++; if ((uint)index >= (uint)source.Length) @@ -260,7 +260,7 @@ private static bool TryParseInt32N(ReadOnlySpan source, out int value, out if (source[index] != '0') goto FalseExit; -FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. + FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. do { index++; @@ -274,12 +274,12 @@ private static bool TryParseInt32N(ReadOnlySpan source, out int value, out goto FalseExit; // The fractional portion contained a non-zero digit. Treat this as an error, not an early termination. goto Done; -FalseExit: + FalseExit: bytesConsumed = default; value = default; return false; -Done: + Done: bytesConsumed = index; value = answer * sign; return true; @@ -347,7 +347,7 @@ private static bool TryParseInt64N(ReadOnlySpan source, out long value, ou goto FalseExit; // Overflow } -FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. + FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. answer = 0; index++; if ((uint)index >= (uint)source.Length) @@ -355,7 +355,7 @@ private static bool TryParseInt64N(ReadOnlySpan source, out long value, ou if (source[index] != '0') goto FalseExit; -FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. + FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. do { index++; @@ -369,12 +369,12 @@ private static bool TryParseInt64N(ReadOnlySpan source, out long value, ou goto FalseExit; // The fractional portion contained a non-zero digit. Treat this as an error, not an early termination. goto Done; -FalseExit: + FalseExit: bytesConsumed = default; value = default; return false; -Done: + Done: bytesConsumed = index; value = answer * sign; return true; diff --git a/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Integer.Unsigned.N.cs b/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Integer.Unsigned.N.cs index bb535fb6cb14..2db20c127011 100644 --- a/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Integer.Unsigned.N.cs +++ b/src/System.Memory/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Integer.Unsigned.N.cs @@ -57,7 +57,7 @@ private static bool TryParseByteN(ReadOnlySpan source, out byte value, out goto FalseExit; // Overflow } -FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. + FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. answer = 0; index++; if ((uint)index >= (uint)source.Length) @@ -65,7 +65,7 @@ private static bool TryParseByteN(ReadOnlySpan source, out byte value, out if (source[index] != '0') goto FalseExit; -FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. + FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. do { index++; @@ -79,12 +79,12 @@ private static bool TryParseByteN(ReadOnlySpan source, out byte value, out goto FalseExit; // The fractional portion contained a non-zero digit. Treat this as an error, not an early termination. goto Done; -FalseExit: + FalseExit: bytesConsumed = default; value = default; return false; -Done: + Done: bytesConsumed = index; value = (byte)answer; return true; @@ -138,7 +138,7 @@ private static bool TryParseUInt16N(ReadOnlySpan source, out ushort value, goto FalseExit; // Overflow } -FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. + FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. answer = 0; index++; if ((uint)index >= (uint)source.Length) @@ -146,7 +146,7 @@ private static bool TryParseUInt16N(ReadOnlySpan source, out ushort value, if (source[index] != '0') goto FalseExit; -FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. + FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. do { index++; @@ -160,12 +160,12 @@ private static bool TryParseUInt16N(ReadOnlySpan source, out ushort value, goto FalseExit; // The fractional portion contained a non-zero digit. Treat this as an error, not an early termination. goto Done; -FalseExit: + FalseExit: bytesConsumed = default; value = default; return false; -Done: + Done: bytesConsumed = index; value = (ushort)answer; return true; @@ -219,7 +219,7 @@ private static bool TryParseUInt32N(ReadOnlySpan source, out uint value, o answer = answer * 10 + c - '0'; } -FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. + FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. answer = 0; index++; if ((uint)index >= (uint)source.Length) @@ -227,7 +227,7 @@ private static bool TryParseUInt32N(ReadOnlySpan source, out uint value, o if (source[index] != '0') goto FalseExit; -FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. + FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. do { index++; @@ -241,12 +241,12 @@ private static bool TryParseUInt32N(ReadOnlySpan source, out uint value, o goto FalseExit; // The fractional portion contained a non-zero digit. Treat this as an error, not an early termination. goto Done; -FalseExit: + FalseExit: bytesConsumed = default; value = default; return false; -Done: + Done: bytesConsumed = index; value = (uint)answer; return true; @@ -300,7 +300,7 @@ private static bool TryParseUInt64N(ReadOnlySpan source, out ulong value, answer = answer * 10 + c - '0'; } -FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. + FractionalPartWithoutLeadingDigits: // If we got here, we found a decimal point before we found any digits. This is legal as long as there's at least one zero after the decimal point. answer = 0; index++; if ((uint)index >= (uint)source.Length) @@ -308,7 +308,7 @@ private static bool TryParseUInt64N(ReadOnlySpan source, out ulong value, if (source[index] != '0') goto FalseExit; -FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. + FractionalDigits: // "N" format allows a fractional portion despite being an integer format but only if the post-fraction digits are all 0. do { index++; @@ -322,12 +322,12 @@ private static bool TryParseUInt64N(ReadOnlySpan source, out ulong value, goto FalseExit; // The fractional portion contained a non-zero digit. Treat this as an error, not an early termination. goto Done; -FalseExit: + FalseExit: bytesConsumed = default; value = default; return false; -Done: + Done: bytesConsumed = index; value = (ulong)answer; return true; diff --git a/src/System.Memory/tests/Memory/Equality.cs b/src/System.Memory/tests/Memory/Equality.cs index f82d0edebe5a..86f8d61b49ae 100644 --- a/src/System.Memory/tests/Memory/Equality.cs +++ b/src/System.Memory/tests/Memory/Equality.cs @@ -6,8 +6,6 @@ using System.Linq; using Xunit; -#pragma warning disable 1718 //Comparison made to same variable; did you mean to compare something else? - namespace System.MemoryTests { public static partial class MemoryTests diff --git a/src/System.Memory/tests/MemoryPool/MemoryPool.cs b/src/System.Memory/tests/MemoryPool/MemoryPool.cs index 9e2312f65b02..cb9ded08a6f4 100644 --- a/src/System.Memory/tests/MemoryPool/MemoryPool.cs +++ b/src/System.Memory/tests/MemoryPool/MemoryPool.cs @@ -237,12 +237,12 @@ public static void ExtraDisposesAreIgnored() block.Dispose(); } - [Fact] - public static void NoMemoryAfterDispose() - { - IMemoryOwner block = MemoryPool.Shared.Rent(42); - block.Dispose(); - Assert.Throws(() => block.Memory); - } + [Fact] + public static void NoMemoryAfterDispose() + { + IMemoryOwner block = MemoryPool.Shared.Rent(42); + block.Dispose(); + Assert.Throws(() => block.Memory); + } } } diff --git a/src/System.Memory/tests/ParsersAndFormatters/TestData.cs b/src/System.Memory/tests/ParsersAndFormatters/TestData.cs index 4e95b808fe54..48a2f96c936d 100644 --- a/src/System.Memory/tests/ParsersAndFormatters/TestData.cs +++ b/src/System.Memory/tests/ParsersAndFormatters/TestData.cs @@ -137,7 +137,7 @@ public static IEnumerable Int64TestData yield return -1234L; yield return 12345L; yield return -12345L; - + yield return 4294967294999999999L; // uint.MaxValue * Billion - 1 yield return 4294967295000000000L; // uint.MaxValue * Billion yield return 4294967295000000001L; // uint.MaxValue * Billion + 1 diff --git a/src/System.Memory/tests/ReadOnlyMemory/Equality.cs b/src/System.Memory/tests/ReadOnlyMemory/Equality.cs index a6dd5a900010..a6a53eeefa21 100644 --- a/src/System.Memory/tests/ReadOnlyMemory/Equality.cs +++ b/src/System.Memory/tests/ReadOnlyMemory/Equality.cs @@ -6,8 +6,6 @@ using System.Linq; using Xunit; -#pragma warning disable 1718 //Comparison made to same variable; did you mean to compare something else? - namespace System.MemoryTests { public static partial class ReadOnlyMemoryTests diff --git a/src/System.Memory/tests/ReadOnlySpan/Contains.cs b/src/System.Memory/tests/ReadOnlySpan/Contains.cs index 91ee3135274a..bf262c1ff35f 100644 --- a/src/System.Memory/tests/ReadOnlySpan/Contains.cs +++ b/src/System.Memory/tests/ReadOnlySpan/Contains.cs @@ -114,7 +114,7 @@ public static void ContainsNoMatch_StringComparison() Assert.False(firstSpan.Contains(secondSpan, StringComparison.Ordinal)); Assert.False(firstSpan.Contains(secondSpan, StringComparison.OrdinalIgnoreCase)); - + // Different behavior depending on OS Assert.Equal( firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCulture), diff --git a/src/System.Memory/tests/ReadOnlySpan/CtorPointerInt.cs b/src/System.Memory/tests/ReadOnlySpan/CtorPointerInt.cs index 9cd75b18d50e..5eeecdadaeae 100644 --- a/src/System.Memory/tests/ReadOnlySpan/CtorPointerInt.cs +++ b/src/System.Memory/tests/ReadOnlySpan/CtorPointerInt.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#pragma warning disable 0649 //Field 'SpanTests.InnerStruct.J' is never assigned to, and will always have its default value 0 - namespace System.SpanTests { public static partial class ReadOnlySpanTests diff --git a/src/System.Memory/tests/ReadOnlySpan/EndsWith.StringComparison.cs b/src/System.Memory/tests/ReadOnlySpan/EndsWith.StringComparison.cs index 883181a4d426..3be5615a7269 100644 --- a/src/System.Memory/tests/ReadOnlySpan/EndsWith.StringComparison.cs +++ b/src/System.Memory/tests/ReadOnlySpan/EndsWith.StringComparison.cs @@ -206,7 +206,7 @@ public static void EndsWithMatchNonOrdinal_StringComparison() value = new char[] { '\u0049', '\u0073', '\u0073', '\u0049' }; // IssI Assert.False(span.EndsWith(value, StringComparison.OrdinalIgnoreCase)); Assert.False(span.EndsWith(value, StringComparison.InvariantCulture)); - // Different behavior depending on OS - True on Windows, False on Unix + // Different behavior depending on OS - True on Windows, False on Unix Assert.Equal( span.ToString().EndsWith(value.ToString(), StringComparison.InvariantCultureIgnoreCase), span.EndsWith(value, StringComparison.InvariantCultureIgnoreCase)); diff --git a/src/System.Memory/tests/ReadOnlySpan/Equality.cs b/src/System.Memory/tests/ReadOnlySpan/Equality.cs index a884be495d16..17b4abbf8550 100644 --- a/src/System.Memory/tests/ReadOnlySpan/Equality.cs +++ b/src/System.Memory/tests/ReadOnlySpan/Equality.cs @@ -4,8 +4,6 @@ using Xunit; -#pragma warning disable 1718 //Comparison made to same variable; did you mean to compare something else? - namespace System.SpanTests { public static partial class ReadOnlySpanTests @@ -27,8 +25,10 @@ public static void EqualityReflexivity() int[] a = { 91, 92, 93, 94, 95 }; ReadOnlySpan left = new ReadOnlySpan(a, 2, 3); +#pragma warning disable 1718 // Comparison made to same variable; did you mean to compare something else? Assert.True(left == left); Assert.True(!(left != left)); +#pragma warning restore 1718 } [Fact] diff --git a/src/System.Memory/tests/ReadOnlySpan/Equals.cs b/src/System.Memory/tests/ReadOnlySpan/Equals.cs index 77ea760f7690..013d2eea1ea8 100644 --- a/src/System.Memory/tests/ReadOnlySpan/Equals.cs +++ b/src/System.Memory/tests/ReadOnlySpan/Equals.cs @@ -117,7 +117,7 @@ public static void EqualsNoMatch_StringComparison() Assert.False(firstSpan.Equals(secondSpan, StringComparison.Ordinal)); Assert.False(firstSpan.Equals(secondSpan, StringComparison.OrdinalIgnoreCase)); - + // Different behavior depending on OS Assert.Equal( firstSpan.ToString().Equals(secondSpan.ToString(), StringComparison.CurrentCulture), diff --git a/src/System.Memory/tests/ReadOnlySpan/IsWhiteSpace.cs b/src/System.Memory/tests/ReadOnlySpan/IsWhiteSpace.cs index ddcd1f9da5f1..a244aafce8cb 100644 --- a/src/System.Memory/tests/ReadOnlySpan/IsWhiteSpace.cs +++ b/src/System.Memory/tests/ReadOnlySpan/IsWhiteSpace.cs @@ -84,10 +84,10 @@ public static void IsWhiteSpaceFalse() a[length - 1] = ' '; // character in the middle is not a white-space character - a[length/2] = 'a'; + a[length / 2] = 'a'; result = ((ReadOnlySpan)span).IsWhiteSpace(); Assert.Equal(string.IsNullOrWhiteSpace(new string(span.ToArray())), result); - a[length/2] = ' '; + a[length / 2] = ' '; // no character is a white-space character span.Fill('a'); diff --git a/src/System.Memory/tests/ReadOnlySpan/SequenceCompareTo.T.cs b/src/System.Memory/tests/ReadOnlySpan/SequenceCompareTo.T.cs index 0924295bdc4b..195d6612d2aa 100644 --- a/src/System.Memory/tests/ReadOnlySpan/SequenceCompareTo.T.cs +++ b/src/System.Memory/tests/ReadOnlySpan/SequenceCompareTo.T.cs @@ -79,7 +79,7 @@ public static void SequenceCompareToNoMatch() var first = new TInt[length]; var second = new TInt[length]; - + for (int i = 0; i < length; i++) { first[i] = new TInt(i + 1, log); diff --git a/src/System.Memory/tests/ReadOnlySpan/SequenceCompareTo.bool.cs b/src/System.Memory/tests/ReadOnlySpan/SequenceCompareTo.bool.cs index 964492edbd71..e6ece96a1915 100644 --- a/src/System.Memory/tests/ReadOnlySpan/SequenceCompareTo.bool.cs +++ b/src/System.Memory/tests/ReadOnlySpan/SequenceCompareTo.bool.cs @@ -40,7 +40,7 @@ public static void SequenceCompareToArrayImplicit_Bool() [Fact] public static void SequenceCompareToArraySegmentImplicit_Bool() { - bool[] src = { true, true, true}; + bool[] src = { true, true, true }; bool[] dst = { false, true, true, true, false }; var segment = new ArraySegment(dst, 1, 3); diff --git a/src/System.Memory/tests/ReadOnlySpan/StartsWith.StringComparison.cs b/src/System.Memory/tests/ReadOnlySpan/StartsWith.StringComparison.cs index ce831d1a6480..1aa12fa6f2da 100644 --- a/src/System.Memory/tests/ReadOnlySpan/StartsWith.StringComparison.cs +++ b/src/System.Memory/tests/ReadOnlySpan/StartsWith.StringComparison.cs @@ -118,7 +118,7 @@ public static void StartsWithNoMatch_StringComparison() Assert.False(firstSpan.StartsWith(secondSpan, StringComparison.Ordinal)); Assert.False(firstSpan.StartsWith(secondSpan, StringComparison.OrdinalIgnoreCase)); - + // Different behavior depending on OS Assert.Equal( firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCulture), @@ -197,7 +197,7 @@ public static void StartsWithMatchNonOrdinal_StringComparison() value = new char[] { '\u0069', '\u0073', '\u0073', '\u0049' }; // issI Assert.False(span.StartsWith(value, StringComparison.Ordinal)); - // Different behavior depending on OS - True on Windows, False on Unix + // Different behavior depending on OS - True on Windows, False on Unix Assert.Equal( span.ToString().StartsWith(value.ToString(), StringComparison.InvariantCulture), span.StartsWith(value, StringComparison.InvariantCulture)); @@ -208,7 +208,7 @@ public static void StartsWithMatchNonOrdinal_StringComparison() value = new char[] { '\u0049', '\u0073', '\u0073', '\u0049' }; // IssI Assert.False(span.StartsWith(value, StringComparison.OrdinalIgnoreCase)); Assert.False(span.StartsWith(value, StringComparison.InvariantCulture)); - // Different behavior depending on OS - True on Windows, False on Unix + // Different behavior depending on OS - True on Windows, False on Unix Assert.Equal( span.ToString().StartsWith(value.ToString(), StringComparison.InvariantCultureIgnoreCase), span.StartsWith(value, StringComparison.InvariantCultureIgnoreCase)); diff --git a/src/System.Memory/tests/ReadOnlySpan/TrimAnyCharacter.cs b/src/System.Memory/tests/ReadOnlySpan/TrimAnyCharacter.cs index c1975616a0ec..a70f73ba0bf3 100644 --- a/src/System.Memory/tests/ReadOnlySpan/TrimAnyCharacter.cs +++ b/src/System.Memory/tests/ReadOnlySpan/TrimAnyCharacter.cs @@ -86,7 +86,7 @@ public static void TrimCharacterAtEnd() Assert.True(span.Slice(0, length - 1).SequenceEqual(span.TrimEnd('a'))); } } - + [Fact] public static void TrimCharacterAtStartAndEnd() { diff --git a/src/System.Memory/tests/ReadOnlySpan/TrimManyCharacters.cs b/src/System.Memory/tests/ReadOnlySpan/TrimManyCharacters.cs index afade2c2c8bb..ea214836f079 100644 --- a/src/System.Memory/tests/ReadOnlySpan/TrimManyCharacters.cs +++ b/src/System.Memory/tests/ReadOnlySpan/TrimManyCharacters.cs @@ -101,7 +101,7 @@ public static void TrimCharactersAtStart() char[] a = new char[length]; for (int i = 0; i < length; i++) { - a[i] = 'f'; + a[i] = 'f'; } a[0] = 'c'; ReadOnlySpan span = new ReadOnlySpan(a); diff --git a/src/System.Memory/tests/ReadOnlySpan/TrimWhiteSpace.cs b/src/System.Memory/tests/ReadOnlySpan/TrimWhiteSpace.cs index 15c94f9603c2..dd6f3efb5b21 100644 --- a/src/System.Memory/tests/ReadOnlySpan/TrimWhiteSpace.cs +++ b/src/System.Memory/tests/ReadOnlySpan/TrimWhiteSpace.cs @@ -86,7 +86,7 @@ public static void WhiteSpaceAtEndTrim() Assert.True(span.Slice(0, length - 1).SequenceEqual(span.TrimEnd())); } } - + [Fact] public static void WhiteSpaceAtStartAndEndTrim() { diff --git a/src/System.Memory/tests/Span/Clear.cs b/src/System.Memory/tests/Span/Clear.cs index 5f7c75ca0b73..707cb6e6ad7a 100644 --- a/src/System.Memory/tests/Span/Clear.cs +++ b/src/System.Memory/tests/Span/Clear.cs @@ -227,7 +227,7 @@ public static void ClearReferenceTypeSlice() [Fact] public static void ClearEnumType() { - TestEnum[] actual = { TestEnum.e0, TestEnum.e1, TestEnum.e2 }; + TestEnum[] actual = { TestEnum.E0, TestEnum.E1, TestEnum.E2 }; TestEnum[] expected = { default, default, default }; var span = new Span(actual); diff --git a/src/System.Memory/tests/Span/CtorPointerInt.cs b/src/System.Memory/tests/Span/CtorPointerInt.cs index b4c802a347c2..b313bfd70dc5 100644 --- a/src/System.Memory/tests/Span/CtorPointerInt.cs +++ b/src/System.Memory/tests/Span/CtorPointerInt.cs @@ -6,8 +6,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#pragma warning disable 0649 //Field 'SpanTests.InnerStruct.J' is never assigned to, and will always have its default value 0 - namespace System.SpanTests { public static partial class SpanTests @@ -18,7 +16,7 @@ public static void CtorPointerInt() unsafe { int[] a = { 90, 91, 92 }; - fixed (int *pa = a) + fixed (int* pa = a) { Span span = new Span(pa, 3); span.Validate(90, 91, 92); diff --git a/src/System.Memory/tests/Span/Equality.cs b/src/System.Memory/tests/Span/Equality.cs index 921a40fbb9b2..c7c7bf18e03f 100644 --- a/src/System.Memory/tests/Span/Equality.cs +++ b/src/System.Memory/tests/Span/Equality.cs @@ -4,8 +4,6 @@ using Xunit; -#pragma warning disable 1718 //Comparison made to same variable; did you mean to compare something else? - namespace System.SpanTests { public static partial class SpanTests @@ -27,8 +25,10 @@ public static void EqualityReflexivity() int[] a = { 91, 92, 93, 94, 95 }; Span left = new Span(a, 2, 3); +#pragma warning disable 1718 // Comparison made to same variable; did you mean to compare something else? Assert.True(left == left); Assert.True(!(left != left)); +#pragma warning restore 1718 } [Fact] diff --git a/src/System.Memory/tests/Span/Reverse.cs b/src/System.Memory/tests/Span/Reverse.cs index a0d51a5c0814..2571dc6c8304 100644 --- a/src/System.Memory/tests/Span/Reverse.cs +++ b/src/System.Memory/tests/Span/Reverse.cs @@ -190,8 +190,8 @@ public static void ReverseReferenceTwiceReturnsOriginal() [Fact] public static void ReverseEnumType() { - TestEnum[] actual = { TestEnum.e0, TestEnum.e1, TestEnum.e2 }; - TestEnum[] expected = { TestEnum.e2, TestEnum.e1, TestEnum.e0 }; + TestEnum[] actual = { TestEnum.E0, TestEnum.E1, TestEnum.E2 }; + TestEnum[] expected = { TestEnum.E2, TestEnum.E1, TestEnum.E0 }; var span = new Span(actual); span.Reverse(); diff --git a/src/System.Memory/tests/Span/SequenceCompareTo.T.cs b/src/System.Memory/tests/Span/SequenceCompareTo.T.cs index ed8d66e10e36..f5b70c481f8f 100644 --- a/src/System.Memory/tests/Span/SequenceCompareTo.T.cs +++ b/src/System.Memory/tests/Span/SequenceCompareTo.T.cs @@ -79,7 +79,7 @@ public static void SequenceCompareToNoMatch() TInt[] first = new TInt[length]; TInt[] second = new TInt[length]; - + for (int i = 0; i < length; i++) { first[i] = new TInt(i + 1, log); diff --git a/src/System.Memory/tests/Span/SequenceCompareTo.bool.cs b/src/System.Memory/tests/Span/SequenceCompareTo.bool.cs index 01f8ee2f7def..6cabe55f668b 100644 --- a/src/System.Memory/tests/Span/SequenceCompareTo.bool.cs +++ b/src/System.Memory/tests/Span/SequenceCompareTo.bool.cs @@ -40,7 +40,7 @@ public static void SequenceCompareToArrayImplicit_Bool() [Fact] public static void SequenceCompareToArraySegmentImplicit_Bool() { - bool[] src = { true, true, true}; + bool[] src = { true, true, true }; bool[] dst = { false, true, true, true, false }; var segment = new ArraySegment(dst, 1, 3); diff --git a/src/System.Memory/tests/TInt.cs b/src/System.Memory/tests/TInt.cs index 87942abe8e15..0cd6a8fb64a9 100644 --- a/src/System.Memory/tests/TInt.cs +++ b/src/System.Memory/tests/TInt.cs @@ -5,8 +5,6 @@ using System.Collections.Generic; using System.Linq; -#pragma warning disable 0809 //warning CS0809: Obsolete member overrides non-obsolete member - namespace System { // A wrapped integer that invokes a custom delegate every time IEquatable.Equals() is invoked. @@ -32,27 +30,23 @@ public TInt(int value, TIntLog log) public bool Equals(TInt other) { - if (_onCompare != null) - { - _onCompare(Value, other.Value); - } + _onCompare?.Invoke(Value, other.Value); return Value == other.Value; } public int CompareTo(TInt other) { - if (_onCompare != null) - { - _onCompare(Value, other.Value); - } + _onCompare?.Invoke(Value, other.Value); return Value.CompareTo(other.Value); } +#pragma warning disable 0809 // Obsolete member 'TInt.Equals(object)' overrides non-obsolete member 'object.Equals(object)' [Obsolete("Don't call this. Call IEquatable.Equals(T)")] public override bool Equals(object obj) { throw new NotSupportedException("Unexpected use of boxing Equals()."); } +#pragma warning restore 0809 public override int GetHashCode() => Value.GetHashCode(); diff --git a/src/System.Memory/tests/TestHelpers.cs b/src/System.Memory/tests/TestHelpers.cs index 283b7dde59bc..1d8abb543179 100644 --- a/src/System.Memory/tests/TestHelpers.cs +++ b/src/System.Memory/tests/TestHelpers.cs @@ -314,11 +314,11 @@ internal struct InnerStruct public enum TestEnum { - e0, - e1, - e2, - e3, - e4, + E0, + E1, + E2, + E3, + E4, } [MethodImpl(MethodImplOptions.NoInlining)]