Re-enable xunit warning 2005 (dotnet/corefx#39866)
authorStephen Toub <stoub@microsoft.com>
Tue, 30 Jul 2019 00:56:11 +0000 (20:56 -0400)
committerGitHub <noreply@github.com>
Tue, 30 Jul 2019 00:56:11 +0000 (20:56 -0400)
Commit migrated from https://github.com/dotnet/corefx/commit/7b013c44b8d38df51f3ec8db64bdcb1f83a8b421

13 files changed:
src/libraries/CodeAnalysis.ruleset
src/libraries/System.Collections.Immutable/tests/ImmutableTestBase.cs
src/libraries/System.Collections/tests/Generic/HashSet/HashSet.Generic.Tests.netcoreapp.cs
src/libraries/System.Collections/tests/Generic/SortedSet/SortedSet.Generic.Tests.netcoreapp.cs
src/libraries/System.Drawing.Common/tests/IconTests.cs
src/libraries/System.Linq.Expressions/tests/Ternary/TernaryTests.cs
src/libraries/System.Memory/tests/Memory/ImplicitConversion.cs
src/libraries/System.Memory/tests/ReadOnlyMemory/ImplicitConversion.cs
src/libraries/System.Memory/tests/TestHelpers.cs
src/libraries/System.Runtime/tests/System/Reflection/InvokeRefReturn.netcoreapp.cs
src/libraries/System.Security.Cryptography.Encoding/tests/OidCollectionTests.cs
src/libraries/System.Threading.Overlapped/tests/OverlappedTests.cs
src/libraries/System.Threading.Tasks/tests/UnwrapTests.cs

index c1b0bf9..3298b4f 100644 (file)
@@ -77,7 +77,6 @@
     <Rule Id="xUnit1019" Action="None" /> <!-- MemberData must reference a member providing a valid data type -->
     <Rule Id="xUnit1024" Action="None" /> <!-- Test methods cannot have overloads -->
     <Rule Id="xUnit1026" Action="None" /> <!-- Theory methods should use all of their parameters -->
-    <Rule Id="xUnit2005" Action="None" /> <!-- Do not use identity check on value type -->
     <Rule Id="xUnit2013" Action="None" /> <!-- Do not use equality check to check for collection size. -->
     <Rule Id="xUnit2017" Action="None" /> <!-- Do not use Contains() to check if a value exists in a collection -->
     <Rule Id="xUnit2018" Action="None" /> <!-- Do not compare an object's exact type to an abstract class or interface -->
index 1972ec9..95146be 100644 (file)
@@ -29,7 +29,7 @@ namespace System.Collections.Immutable.Tests
             }
             else
             {
-                Assert.Same(expected, actual); //, message, formattingArgs);
+                Assert.Same((object)expected, (object)actual); //, message, formattingArgs);
             }
         }
 
index 2f9226d..432cabc 100644 (file)
@@ -97,7 +97,7 @@ namespace System.Collections.Tests
             Assert.Equal(value, actualValue);
             if (!typeof(T).IsValueType)
             {
-                Assert.Same(value, actualValue);
+                Assert.Same((object)value, (object)actualValue);
             }
         }
 
@@ -112,7 +112,7 @@ namespace System.Collections.Tests
             Assert.Equal(value, actualValue);
             if (!typeof(T).IsValueType)
             {
-                Assert.Same(value, actualValue);
+                Assert.Same((object)value, (object)actualValue);
             }
         }
 
index f71a88a..d3b3f1b 100644 (file)
@@ -26,7 +26,7 @@ namespace System.Collections.Tests
             Assert.Equal(value, actualValue);
             if (!typeof(T).IsValueType)
             {
-                Assert.Same(value, actualValue);
+                Assert.Same((object)value, (object)actualValue);
             }
         }
 
@@ -41,7 +41,7 @@ namespace System.Collections.Tests
             Assert.Equal(value, actualValue);
             if (!typeof(T).IsValueType)
             {
-                Assert.Same(value, actualValue);
+                Assert.Same((object)value, (object)actualValue);
             }
         }
 
index fc85c60..2d235e4 100644 (file)
@@ -239,7 +239,7 @@ namespace System.Drawing.Tests
                 Assert.Equal(expectedSize.Width, icon.Width);
                 Assert.Equal(expectedSize.Height, icon.Height);
                 Assert.Equal(expectedSize, icon.Size);
-                Assert.NotSame(sourceIcon.Handle, icon.Handle);
+                Assert.NotEqual(sourceIcon.Handle, icon.Handle);
             }
         }
 
@@ -254,7 +254,7 @@ namespace System.Drawing.Tests
                 Assert.Equal(expectedSize.Width, icon.Width);
                 Assert.Equal(expectedSize.Height, icon.Height);
                 Assert.Equal(expectedSize, icon.Size);
-                Assert.NotSame(sourceIcon.Handle, icon.Handle);
+                Assert.NotEqual(sourceIcon.Handle, icon.Handle);
             }
         }
 
@@ -319,7 +319,7 @@ namespace System.Drawing.Tests
             using (Icon clone = Assert.IsType<Icon>(icon.Clone()))
             {
                 Assert.NotSame(icon, clone);
-                Assert.NotSame(icon.Handle, clone.Handle);
+                Assert.NotEqual(icon.Handle, clone.Handle);
                 Assert.Equal(32, clone.Width);
                 Assert.Equal(32, clone.Height);
                 Assert.Equal(new Size(32, 32), clone.Size);
@@ -333,7 +333,7 @@ namespace System.Drawing.Tests
             using (Icon clone = Assert.IsType<Icon>(icon.Clone()))
             {
                 Assert.NotSame(icon, clone);
-                Assert.NotSame(icon.Handle, clone.Handle);
+                Assert.NotEqual(icon.Handle, clone.Handle);
                 Assert.Equal(SystemIcons.Hand.Width, clone.Width);
                 Assert.Equal(SystemIcons.Hand.Height, clone.Height);
                 Assert.Equal(SystemIcons.Hand.Size, clone.Size);
index 10b66b1..1532e91 100644 (file)
@@ -1109,12 +1109,12 @@ namespace System.Linq.Expressions.Tests
             Func<T> f = e.Compile(useInterpreter);
 
             if (default(T) == null)
-                Assert.Same(condition ? a : b, f());
+                Assert.Same((object)(condition ? a : b), (object)f());
             else
                 Assert.Equal(condition ? a : b, f());
         }
 
-        private static void VerifyGenericWithClassRestriction<Tc>(bool condition, Tc a, Tc b, bool useInterpreter)
+        private static void VerifyGenericWithClassRestriction<Tc>(bool condition, Tc a, Tc b, bool useInterpreter) where Tc : class
         {
             Expression<Func<Tc>> e =
                 Expression.Lambda<Func<Tc>>(
@@ -1128,7 +1128,7 @@ namespace System.Linq.Expressions.Tests
             Assert.Same(condition ? a : b, f());
         }
 
-        private static void VerifyGenericWithSubClassRestriction<TC>(bool condition, TC a, TC b, bool useInterpreter)
+        private static void VerifyGenericWithSubClassRestriction<TC>(bool condition, TC a, TC b, bool useInterpreter) where TC : class
         {
             Expression<Func<TC>> e =
                 Expression.Lambda<Func<TC>>(
@@ -1142,7 +1142,7 @@ namespace System.Linq.Expressions.Tests
             Assert.Same(condition ? a : b, f());
         }
 
-        private static void VerifyGenericWithClassAndNewRestriction<Tcn>(bool condition, Tcn a, Tcn b, bool useInterpreter)
+        private static void VerifyGenericWithClassAndNewRestriction<Tcn>(bool condition, Tcn a, Tcn b, bool useInterpreter) where Tcn : class
         {
             Expression<Func<Tcn>> e =
                 Expression.Lambda<Func<Tcn>>(
@@ -1156,7 +1156,7 @@ namespace System.Linq.Expressions.Tests
             Assert.Same(condition ? a : b, f());
         }
 
-        private static void VerifyGenericWithSubClassAndNewRestriction<TCn>(bool condition, TCn a, TCn b, bool useInterpreter)
+        private static void VerifyGenericWithSubClassAndNewRestriction<TCn>(bool condition, TCn a, TCn b, bool useInterpreter) where TCn : class
         {
             Expression<Func<TCn>> e =
                 Expression.Lambda<Func<TCn>>(
index 21b5d7f..4086eb1 100644 (file)
@@ -126,7 +126,7 @@ namespace System.MemoryTests
             memory.Validate(expected);
         }
 
-        private static void CastReference<T>(Memory<T> memory, params T[] expected)
+        private static void CastReference<T>(Memory<T> memory, params T[] expected) where T : class
         {
             memory.ValidateReferenceType(expected);
         }
@@ -136,7 +136,7 @@ namespace System.MemoryTests
             memory.Validate(expected);
         }
 
-        private static void CastReadOnlyReference<T>(ReadOnlyMemory<T> memory, params T[] expected)
+        private static void CastReadOnlyReference<T>(ReadOnlyMemory<T> memory, params T[] expected) where T : class
         {
             memory.ValidateReferenceType(expected);
         }
index 13fd5f3..927e603 100644 (file)
@@ -80,7 +80,7 @@ namespace System.MemoryTests
             memory.Validate(expected);
         }
 
-        private static void CastReadOnlyReference<T>(ReadOnlyMemory<T> memory, params T[] expected)
+        private static void CastReadOnlyReference<T>(ReadOnlyMemory<T> memory, params T[] expected) where T : class
         {
             memory.ValidateReferenceType(expected);
         }
index 7e3485c..7692df9 100644 (file)
@@ -20,7 +20,7 @@ namespace System
             Assert.True(span.SequenceEqual(expected));
         }
 
-        public static void ValidateReferenceType<T>(this Span<T> span, params T[] expected)
+        public static void ValidateReferenceType<T>(this Span<T> span, params T[] expected) where T : class
         {
             Assert.Equal(span.Length, expected.Length);
             for (int i = 0; i < expected.Length; i++)
@@ -84,7 +84,7 @@ namespace System
             Assert.True(span.SequenceEqual(expected));
         }
 
-        public static void ValidateReferenceType<T>(this ReadOnlySpan<T> span, params T[] expected)
+        public static void ValidateReferenceType<T>(this ReadOnlySpan<T> span, params T[] expected) where T : class
         {
             Assert.Equal(span.Length, expected.Length);
             for (int i = 0; i < expected.Length; i++)
@@ -148,7 +148,7 @@ namespace System
             Assert.True(memory.Span.SequenceEqual(expected));
         }
 
-        public static void ValidateReferenceType<T>(this Memory<T> memory, params T[] expected)
+        public static void ValidateReferenceType<T>(this Memory<T> memory, params T[] expected) where T : class
         {
             T[] bufferArray = memory.ToArray();
             Assert.Equal(memory.Length, expected.Length);
@@ -164,7 +164,7 @@ namespace System
             Assert.True(memory.Span.SequenceEqual(expected));
         }
 
-        public static void ValidateReferenceType<T>(this ReadOnlyMemory<T> memory, params T[] expected)
+        public static void ValidateReferenceType<T>(this ReadOnlyMemory<T> memory, params T[] expected) where T : class
         {
             T[] bufferArray = memory.ToArray();
             Assert.Equal(memory.Length, expected.Length);
index 9c59a6b..86b41aa 100644 (file)
@@ -135,7 +135,7 @@ namespace System.Reflection.Tests
             }
             else
             {
-                Assert.Same(value, rv);
+                Assert.Same((object)value, rv);
             }
         }
 
index 08dbff1..57219a2 100644 (file)
@@ -151,7 +151,9 @@ namespace System.Security.Cryptography.Encoding.Tests
 
         private static void ValidateEnumerator<TEnumerator, TCurrent>(
             Func<OidCollection, TEnumerator> getEnumerator,
-            Func<TEnumerator, TCurrent> getCurrent) where TEnumerator : IEnumerator
+            Func<TEnumerator, TCurrent> getCurrent)
+            where TEnumerator : IEnumerator
+            where TCurrent : class
         {
             var item1 = new Oid(Sha1Oid, Sha1Name);
             var item2 = new Oid(Sha256Oid, Sha256Name);
index fb39493..0fa4d30 100644 (file)
@@ -28,7 +28,7 @@ public static partial class OverlappedTests
 #pragma warning restore 618
 
         var _handle = new ManualResetEvent(false).SafeWaitHandle;
-        Assert.NotSame(IntPtr.Zero, obj.EventHandleIntPtr);
+        Assert.NotEqual(IntPtr.Zero, obj.EventHandleIntPtr);
         obj.EventHandleIntPtr = _handle.DangerousGetHandle();
         Assert.Equal(_handle.DangerousGetHandle(), obj.EventHandleIntPtr);
 
index e73919d..b5808d6 100644 (file)
@@ -546,7 +546,7 @@ namespace System.Threading.Tasks.Tests
                 if (typeof(T).GetTypeInfo().IsValueType)
                     Assert.Equal(expected.Result, actual.Result);
                 else
-                    Assert.Same(expected.Result, actual.Result);
+                    Assert.Same((object)expected.Result, (object)actual.Result);
             }
         }