-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Conversation
Tagging subscribers to this area: @dotnet/area-system-reflection Issue DetailsRuntimeType member's cache is purged after hot reload, therefore same member references are not equal after hotreload which causing issue like mentioned in Hot Reload breaks MethodInfo equality Updated/added Object.Equals overloads to compare metadata token and module in case hot reload taken place instead of comparing object references. Fixes #69427
|
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs
Outdated
Show resolved
Hide resolved
...lr/System.Private.CoreLib/src/System/Reflection/Metadata/RuntimeTypeMetadataUpdateHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System/Reflection/ReflectionCacheTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System/Reflection/ReflectionCacheTests.cs
Outdated
Show resolved
Hide resolved
...lr/System.Private.CoreLib/src/System/Reflection/Metadata/RuntimeTypeMetadataUpdateHandler.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeEventInfo.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System/Reflection/ReflectionCacheTests.cs
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeEventInfo.cs
Outdated
Show resolved
Hide resolved
...lr/System.Private.CoreLib/src/System/Reflection/Metadata/RuntimeTypeMetadataUpdateHandler.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeEventInfo.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System/Reflection/ReflectionCacheTests.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeEventInfo.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/MdFieldInfo.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.CoreCLR.cs
Outdated
Show resolved
Hide resolved
No, I could not understood why, a typical failure log looks like this:
just know reverting back the Equals logic fixes those failures, will dig more |
Another log
|
… test failures" This reverts commit d4d961c.
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs
Outdated
Show resolved
Hide resolved
Looking at the test failures - the reflected type needs to be also included in Equals method. |
- No need to use GetHashCodeOfPtr when we are wrapping the hashcode using HashCode.Combine that takes care of the randomization - Use underlying type handle for type hashcodes. It is faster than the default object hashcode. - Delete special casing for MetadataUpdater.IsSupported from RuntimeMethodInfo.GetHashCode. It is actually a de-optimization for RuntimeMethodInfo with the two changes above, and about neutral for the rest. - Avoid virtual call for ReflectedType comparison - Restore comment for RuntimeMethodInfo
@buyaa-n I have pushed a commit with a bunch of perf tweaks and simplifications. The commit description has the details. Let me know if it looks good to you or if you have any questions. |
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Thanks for the description, makes sense to me |
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.CoreCLR.cs
Show resolved
Hide resolved
Looks good to me, modulo the last two comments |
Failures unrelated and known issue, merging |
RuntimeType member's cache is purged after hot reload, therefore same member references are not equal after hotreload which causing issue like mentioned in Hot Reload breaks MethodInfo equality
Updated/added Object.Equals overloads to compare metadata token and module in case hot reload taken place instead of comparing object references.
Fixes #69427