diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.CoreCLR.cs index b9145526273a2..8815eeca43982 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.CoreCLR.cs @@ -121,7 +121,11 @@ public override string ToString() } public override bool Equals(object? obj) => - obj is RuntimeConstructorInfo ci && m_handle == ci.m_handle; + ReferenceEquals(this, obj) || + (MetadataUpdater.IsSupported && + obj is RuntimeConstructorInfo ci && + MetadataToken == ci.MetadataToken && + m_declaringType.Equals(ci.m_declaringType)); public override int GetHashCode() => RuntimeHelpers.GetHashCodeOfPtr(m_handle); #endregion diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs index 212ecc62f8f60..4f643dd827b78 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs @@ -160,10 +160,12 @@ public override string ToString() public override int GetHashCode() => RuntimeHelpers.GetHashCodeOfPtr(m_handle); - public override bool Equals(object? obj) - { - return obj is RuntimeMethodInfo m && m_handle == m.m_handle; - } + public override bool Equals(object? obj) => + ReferenceEquals(this, obj) || + (MetadataUpdater.IsSupported && + obj is RuntimeMethodInfo m && + m.MetadataToken == MetadataToken && + m_declaringType.Equals(m.m_declaringType)); #endregion #region ICustomAttributeProvider