Fix Delegate.GetHashCode for type-equivalent delegates#130542
Merged
Conversation
…gate types Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
…bute
Replace plain DelegateTypeA/DelegateTypeB (same signature but different names,
which can never be type-equivalent) with a proper cross-assembly type-equivalent
delegate pair using [TypeIdentifier] attribute as defined in .NET type equivalence
docs.
- Add TestDelegateEquivalentTypeAssembly with System.Tests.EquivalentDelegate
decorated with [TypeIdentifier("guid-scope", "guid-identifier")]
- Declare System.Tests.EquivalentDelegate with the same [TypeIdentifier] values
in DelegateTests.cs (namespace-level, not nested, to avoid enclosing-type
equivalence requirements)
- Update tests to use [ConditionalFact(IsTypeEquivalenceSupported)] and load the
second assembly at runtime via Assembly.LoadFrom
- Add ProjectReference in System.Runtime.Tests.csproj so the assembly is built
and deployed alongside the test DLL
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
jkotas
July 11, 2026 03:41
View session
jkotas
reviewed
Jul 11, 2026
jkotas
reviewed
Jul 11, 2026
jkotas
reviewed
Jul 11, 2026
…ests Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Copilot
AI
requested review from
Copilot and
jkotas
and removed request for
Copilot
July 11, 2026 04:57
…em.TestEquivalentTypes; remove AutoGenerateBindingRedirects Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
jkotas
reviewed
Jul 11, 2026
…ivalentTo asserts Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Contributor
Author
All feedback addressed in the latest commit:
|
Co-authored-by: Michał Petryka <35800402+MichalPetryka@users.noreply.github.com>
jkotas
approved these changes
Jul 13, 2026
Contributor
|
Tagging subscribers to this area: @dotnet/interop-contrib |
… instead of 0 Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
jkotas
approved these changes
Jul 13, 2026
Contributor
Author
Co-authored-by: Michał Petryka <35800402+MichalPetryka@users.noreply.github.com>
Contributor
|
Can we merge this when CI is done so that I can rebase my other PR? |
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
AaronRobinsonMSFT
approved these changes
Jul 14, 2026
This was referenced Jul 14, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix Delegate.GetHashCode to return same hashcodes for type-equivalent delegates pointing to the same method. Delegate.Equals returns true for such delegates. GetHashCode contract requires hashcode to be the same in that case.
Found during codereview of #99200