diff --git a/UnitTests/UnitTests.HighPerformance.Shared/Buffers/Test_StringPool.cs b/UnitTests/UnitTests.HighPerformance.Shared/Buffers/Test_StringPool.cs index b679609d40a..32f14caf797 100644 --- a/UnitTests/UnitTests.HighPerformance.Shared/Buffers/Test_StringPool.cs +++ b/UnitTests/UnitTests.HighPerformance.Shared/Buffers/Test_StringPool.cs @@ -38,13 +38,13 @@ public void Test_StringPool_Cctor_Ok(int minimumSize, int x, int y, int size) Assert.AreEqual(size, pool.Size); - Array maps = (Array)typeof(StringPool).GetField("maps", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pool); + Array maps = (Array)typeof(StringPool).GetField("maps", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(pool)!; Assert.AreEqual(x, maps.Length); - Type bucketType = Type.GetType("Microsoft.Toolkit.HighPerformance.Buffers.StringPool+FixedSizePriorityMap, Microsoft.Toolkit.HighPerformance"); + Type bucketType = Type.GetType("Microsoft.Toolkit.HighPerformance.Buffers.StringPool+FixedSizePriorityMap, Microsoft.Toolkit.HighPerformance")!; - int[] buckets = (int[])bucketType.GetField("buckets", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(maps.GetValue(0)); + int[] buckets = (int[])bucketType.GetField("buckets", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(maps.GetValue(0))!; Assert.AreEqual(y, buckets.Length); } @@ -64,7 +64,7 @@ public void Test_StringPool_Cctor_Fail(int size) } catch (ArgumentOutOfRangeException e) { - var cctor = typeof(StringPool).GetConstructor(new[] { typeof(int) }); + var cctor = typeof(StringPool).GetConstructor(new[] { typeof(int) })!; Assert.AreEqual(cctor.GetParameters()[0].Name, e.ParamName); } @@ -158,7 +158,7 @@ public void Test_StringPool_Add_Overwrite() [MethodImpl(MethodImplOptions.NoInlining)] private static string ToStringNoInlining(object obj) { - return obj.ToString(); + return obj.ToString()!; } [TestCategory("StringPool")] @@ -285,15 +285,15 @@ public void Test_StringPool_GetOrAdd_Overflow() } // Get the buckets - Array maps = (Array)typeof(StringPool).GetField("maps", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pool); + Array maps = (Array)typeof(StringPool).GetField("maps", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(pool)!; - Type bucketType = Type.GetType("Microsoft.Toolkit.HighPerformance.Buffers.StringPool+FixedSizePriorityMap, Microsoft.Toolkit.HighPerformance"); - FieldInfo timestampInfo = bucketType.GetField("timestamp", BindingFlags.Instance | BindingFlags.NonPublic); + Type bucketType = Type.GetType("Microsoft.Toolkit.HighPerformance.Buffers.StringPool+FixedSizePriorityMap, Microsoft.Toolkit.HighPerformance")!; + FieldInfo timestampInfo = bucketType.GetField("timestamp", BindingFlags.Instance | BindingFlags.NonPublic)!; // Force the timestamp to be the maximum value, or the test would take too long for (int i = 0; i < maps.LongLength; i++) { - object map = maps.GetValue(i); + object map = maps.GetValue(i)!; timestampInfo.SetValue(map, uint.MaxValue); @@ -305,16 +305,16 @@ public void Test_StringPool_GetOrAdd_Overflow() _ = pool.GetOrAdd(text); - Type heapEntryType = Type.GetType("Microsoft.Toolkit.HighPerformance.Buffers.StringPool+FixedSizePriorityMap+HeapEntry, Microsoft.Toolkit.HighPerformance"); + Type heapEntryType = Type.GetType("Microsoft.Toolkit.HighPerformance.Buffers.StringPool+FixedSizePriorityMap+HeapEntry, Microsoft.Toolkit.HighPerformance")!; foreach (var map in maps) { // Get the heap for each bucket - Array heapEntries = (Array)bucketType.GetField("heapEntries", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(map); - FieldInfo fieldInfo = heapEntryType.GetField("Timestamp"); + Array heapEntries = (Array)bucketType.GetField("heapEntries", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(map)!; + FieldInfo fieldInfo = heapEntryType.GetField("Timestamp")!; // Extract the array with the timestamps in the heap nodes - uint[] array = heapEntries.Cast().Select(entry => (uint)fieldInfo.GetValue(entry)).ToArray(); + uint[] array = heapEntries.Cast().Select(entry => (uint)fieldInfo.GetValue(entry)!).ToArray(); static bool IsMinHeap(uint[] array) { diff --git a/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ArrayExtensions.1D.cs b/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ArrayExtensions.1D.cs index 7b12703be13..212d151dbd9 100644 --- a/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ArrayExtensions.1D.cs +++ b/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ArrayExtensions.1D.cs @@ -2,6 +2,7 @@ // 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.CodeAnalysis; using System.Runtime.CompilerServices; using Microsoft.Toolkit.HighPerformance.Extensions; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -9,6 +10,7 @@ namespace UnitTests.HighPerformance.Extensions { [TestClass] + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1601", Justification = "Partial test class")] public partial class Test_ArrayExtensions { [TestCategory("ArrayExtensions")] diff --git a/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ArrayExtensions.2D.cs b/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ArrayExtensions.2D.cs index 66aab7c3fb6..a25961532a7 100644 --- a/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ArrayExtensions.2D.cs +++ b/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ArrayExtensions.2D.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using Microsoft.Toolkit.HighPerformance.Enumerables; using Microsoft.Toolkit.HighPerformance.Extensions; @@ -167,8 +166,6 @@ public void Test_ArrayExtensions_2D_AsSpan2DAndFillArrayBottomRightCornerBoundar [TestCategory("ArrayExtensions")] [TestMethod] - [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1312", Justification = "Dummy loop variable")] - [SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1501", Justification = "Empty test loop")] public void Test_ArrayExtensions_2D_GetRow_Rectangle() { int[,] array = @@ -201,8 +198,6 @@ public void Test_ArrayExtensions_2D_GetRow_Rectangle() [TestCategory("ArrayExtensions")] [TestMethod] - [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1312", Justification = "Dummy loop variable")] - [SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1501", Justification = "Empty test loop")] public void Test_ArrayExtensions_2D_GetColumn_Rectangle() { int[,] array = @@ -239,8 +234,6 @@ public void Test_ArrayExtensions_2D_GetRow_Empty() [TestCategory("ArrayExtensions")] [TestMethod] - [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1312", Justification = "Dummy loop variable")] - [SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1501", Justification = "Empty test loop")] public void Test_ArrayExtensions_2D_GetRowOrColumn_Helpers() { int[,] array = @@ -337,8 +330,6 @@ public void Test_ArrayExtensions_2D_GetRowOrColumn_Helpers() [TestCategory("ArrayExtensions")] [TestMethod] - [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1312", Justification = "Dummy loop variable")] - [SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1501", Justification = "Empty test loop")] public void Test_ArrayExtensions_2D_ReadOnlyGetRowOrColumn_Helpers() { int[,] array = @@ -384,8 +375,6 @@ public void Test_ArrayExtensions_2D_ReadOnlyGetRowOrColumn_Helpers() [TestCategory("ArrayExtensions")] [TestMethod] - [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1312", Justification = "Dummy loop variable")] - [SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1501", Justification = "Empty test loop")] public void Test_ArrayExtensions_2D_RefEnumerable_Misc() { int[,] array1 = diff --git a/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ReadOnlySpanExtensions.Count.cs b/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ReadOnlySpanExtensions.Count.cs index 10f1591aeab..e06148d04bb 100644 --- a/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ReadOnlySpanExtensions.Count.cs +++ b/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ReadOnlySpanExtensions.Count.cs @@ -103,7 +103,7 @@ private sealed class Int : IEquatable public Int(int value) => Value = value; - public bool Equals(Int other) + public bool Equals(Int? other) { if (other is null) { @@ -118,7 +118,7 @@ public bool Equals(Int other) return this.Value == other.Value; } - public override bool Equals(object obj) + public override bool Equals(object? obj) { return ReferenceEquals(this, obj) || (obj is Int other && Equals(other)); } diff --git a/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ReadOnlySpanExtensions.cs b/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ReadOnlySpanExtensions.cs index 32d51fbb4a8..3bea7fcb032 100644 --- a/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ReadOnlySpanExtensions.cs +++ b/UnitTests/UnitTests.HighPerformance.Shared/Extensions/Test_ReadOnlySpanExtensions.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Microsoft.Toolkit.HighPerformance.Extensions; @@ -12,6 +13,7 @@ namespace UnitTests.HighPerformance.Extensions { [TestClass] + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1601", Justification = "Partial test class")] public partial class Test_ReadOnlySpanExtensions { [TestCategory("ReadOnlySpanExtensions")] diff --git a/UnitTests/UnitTests.HighPerformance.Shared/Memory/Test_ReadOnlySpan2D{T}.cs b/UnitTests/UnitTests.HighPerformance.Shared/Memory/Test_ReadOnlySpan2D{T}.cs index a34abc34574..e8099e280ab 100644 --- a/UnitTests/UnitTests.HighPerformance.Shared/Memory/Test_ReadOnlySpan2D{T}.cs +++ b/UnitTests/UnitTests.HighPerformance.Shared/Memory/Test_ReadOnlySpan2D{T}.cs @@ -847,8 +847,6 @@ public void Test_ReadOnlySpan2DT_GetEnumerator_Empty() [TestCategory("ReadOnlySpan2DT")] [TestMethod] - [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1312", Justification = "Dummy loop variable")] - [SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1501", Justification = "Empty test loop")] public void Test_ReadOnlySpan2DT_ReadOnlyRefEnumerable_Misc() { int[,] array1 =