From 51f8bb156ab8efba68d584a6dbc70a06bc25bfd8 Mon Sep 17 00:00:00 2001 From: James Ko Date: Fri, 26 Aug 2016 01:33:49 -0400 Subject: [PATCH] Implement the IEquatable interfaces on IntPtr and UIntPtr (dotnet/coreclr#6921) Commit migrated from https://github.com/dotnet/coreclr/commit/74ac12bf9966c5f0f6c58b72bbb99b08727c3d4e --- src/coreclr/src/mscorlib/src/System/IntPtr.cs | 8 +++++++- src/coreclr/src/mscorlib/src/System/UIntPtr.cs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/coreclr/src/mscorlib/src/System/IntPtr.cs b/src/coreclr/src/mscorlib/src/System/IntPtr.cs index d33cf91..c7eea36 100644 --- a/src/coreclr/src/mscorlib/src/System/IntPtr.cs +++ b/src/coreclr/src/mscorlib/src/System/IntPtr.cs @@ -24,7 +24,7 @@ namespace System { [Serializable] [System.Runtime.InteropServices.ComVisible(true)] - public struct IntPtr : ISerializable + public struct IntPtr : IEquatable, 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.Equals(IntPtr other) + { + return m_value == other.m_value; + } [System.Security.SecuritySafeCritical] // auto-generated public unsafe override int GetHashCode() { diff --git a/src/coreclr/src/mscorlib/src/System/UIntPtr.cs b/src/coreclr/src/mscorlib/src/System/UIntPtr.cs index 10a573a..ac3b811 100644 --- a/src/coreclr/src/mscorlib/src/System/UIntPtr.cs +++ b/src/coreclr/src/mscorlib/src/System/UIntPtr.cs @@ -22,7 +22,7 @@ namespace System { [Serializable] [CLSCompliant(false)] [System.Runtime.InteropServices.ComVisible(true)] - public struct UIntPtr : ISerializable + public struct UIntPtr : IEquatable, ISerializable { [SecurityCritical] unsafe private void* m_value; @@ -84,6 +84,12 @@ namespace System { } return false; } + + [SecuritySafeCritical] + unsafe bool IEquatable.Equals(UIntPtr other) + { + return m_value == other.m_value; + } [System.Security.SecuritySafeCritical] // auto-generated public unsafe override int GetHashCode() { -- 2.7.4