Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not check object references for equality after hot reload #73009

Merged
merged 20 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ public override string ToString()
public override bool Equals(object? obj) =>
obj is RuntimeConstructorInfo ci && m_handle == ci.m_handle && ReferenceEquals(m_declaringType, ci.m_declaringType);
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved

public override int GetHashCode() => MetadataUpdater.IsSupported ?
HashCode.Combine(RuntimeHelpers.GetHashCodeOfPtr(m_handle), m_declaringType.GetHashCode()) : base.GetHashCode();
public override int GetHashCode() =>
HashCode.Combine(m_handle.GetHashCode(), m_declaringType.GetUnderlyingNativeHandle().GetHashCode());
#endregion

#region ICustomAttributeProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public override bool Equals(object? obj) =>
ReferenceEquals(this, obj) ||
(MetadataUpdater.IsSupported && CacheEquals(obj));

public override int GetHashCode() => MetadataUpdater.IsSupported ?
HashCode.Combine(m_token.GetHashCode(), m_declaringType.GetHashCode()) : base.GetHashCode();
public override int GetHashCode() =>
HashCode.Combine(m_token.GetHashCode(), m_declaringType.GetUnderlyingNativeHandle().GetHashCode());
#endregion

#region ICustomAttributeProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public override bool Equals(object? obj) =>
ReferenceEquals(this, obj) ||
(MetadataUpdater.IsSupported && CacheEquals(obj));

public override int GetHashCode() => MetadataUpdater.IsSupported ?
HashCode.Combine(MetadataToken.GetHashCode(), m_declaringType.GetHashCode()) : base.GetHashCode();
public override int GetHashCode() =>
HashCode.Combine(MetadataToken.GetHashCode(), m_declaringType.GetUnderlyingNativeHandle().GetHashCode());
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved
#endregion

#region Object Overrides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,17 @@ public override string ToString()
return m_toString;
}

public override int GetHashCode() => (MetadataUpdater.IsSupported || IsGenericMethod) ?
HashCode.Combine(RuntimeHelpers.GetHashCodeOfPtr(m_handle), m_declaringType.GetHashCode()) : base.GetHashCode();
// We cannot do simple object identity comparisons due to generic methods.
// Equals and GetHashCode will be called in CerHashTable when RuntimeType+RuntimeTypeCache.GetGenericMethodInfo()
// retrieve items from and insert items into s_methodInstantiations.

public override int GetHashCode() =>
HashCode.Combine(m_handle.GetHashCode(), m_declaringType.GetUnderlyingNativeHandle().GetHashCode());

public override bool Equals(object? obj) =>
jkotas marked this conversation as resolved.
Show resolved Hide resolved
obj is RuntimeMethodInfo m && m_handle == m.m_handle &&
ReferenceEquals(m_declaringType, m.m_declaringType) &&
ReferenceEquals(ReflectedType, m.ReflectedType);
ReferenceEquals(m_reflectedTypeCache.GetRuntimeType(), m_reflectedTypeCache.GetRuntimeType());
buyaa-n marked this conversation as resolved.
Show resolved Hide resolved

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ public override bool Equals(object? obj) =>
ReferenceEquals(this, obj) ||
(MetadataUpdater.IsSupported && CacheEquals(obj));

public override int GetHashCode() => MetadataUpdater.IsSupported ?
HashCode.Combine(m_token.GetHashCode(), m_declaringType.GetHashCode()) : base.GetHashCode();
public override int GetHashCode() =>
HashCode.Combine(m_token.GetHashCode(), m_declaringType.GetUnderlyingNativeHandle().GetHashCode());
#endregion

#region PropertyInfo Overrides
Expand Down