Implement the IEquatable interfaces on IntPtr and UIntPtr (#6921)
authorJames Ko <jamesqko@gmail.com>
Fri, 26 Aug 2016 05:33:49 +0000 (01:33 -0400)
committerJan Kotas <jkotas@microsoft.com>
Fri, 26 Aug 2016 05:33:49 +0000 (22:33 -0700)
src/mscorlib/src/System/IntPtr.cs
src/mscorlib/src/System/UIntPtr.cs

index d33cf91..c7eea36 100644 (file)
@@ -24,7 +24,7 @@ namespace System {
 
     [Serializable]
     [System.Runtime.InteropServices.ComVisible(true)]
-    public struct IntPtr : ISerializable
+    public struct IntPtr : IEquatable<IntPtr>, ISerializable
     {
         [SecurityCritical]
         unsafe private void* m_value; // The compiler treats void* closest to uint hence explicit casts are required to preserve int behavior
@@ -104,6 +104,12 @@ namespace System {
             }
             return false;
         }
+
+        [SecuritySafeCritical]
+        unsafe bool IEquatable<IntPtr>.Equals(IntPtr other)
+        {
+            return m_value == other.m_value;
+        }
     
         [System.Security.SecuritySafeCritical]  // auto-generated
         public unsafe override int GetHashCode() {
index 10a573a..ac3b811 100644 (file)
@@ -22,7 +22,7 @@ namespace System {
     [Serializable]
     [CLSCompliant(false)] 
     [System.Runtime.InteropServices.ComVisible(true)]
-    public struct UIntPtr : ISerializable
+    public struct UIntPtr : IEquatable<UIntPtr>, ISerializable
     {
         [SecurityCritical]
         unsafe private void* m_value;
@@ -84,6 +84,12 @@ namespace System {
             }
             return false;
         }
+
+        [SecuritySafeCritical]
+        unsafe bool IEquatable<UIntPtr>.Equals(UIntPtr other)
+        {
+            return m_value == other.m_value;
+        }
     
         [System.Security.SecuritySafeCritical]  // auto-generated
         public unsafe override int GetHashCode() {