-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Allow ExternalTypeMap to have duplicates entries with identical mapping but different trimTarget #120519
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
base: main
Are you sure you want to change the base?
Conversation
…ng but different trimTarget
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR allows ExternalTypeMap to have duplicate entries with identical mapping but different trim targets, fixing issue #120160. The change enables multiple TypeMap attributes with the same key and target type but different trim targets to coexist without throwing duplicate key exceptions.
Key changes:
- Modified duplicate detection logic to only throw exceptions when mappings conflict (same key but different target types)
- Added test cases to verify duplicate mappings with different trim targets are properly handled
- Updated nullable annotations in test code for better type safety
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
TypeMapLazyDictionary.cs | Modified duplicate detection logic and added Equals method for TypeNameUtf8 comparison |
TypeMap.cs | Added test cases for duplicate mappings and updated nullable annotations |
...libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs
Outdated
Show resolved
Hide resolved
Tagging subscribers to this area: @dotnet/interop-contrib |
…pServices/TypeMapLazyDictionary.cs Co-authored-by: Copilot <[email protected]>
...libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs
Show resolved
Hide resolved
...libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs
Outdated
Show resolved
Hide resolved
...libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs
Show resolved
Hide resolved
- Use Span for UTF8 string comparison - Negate name check for duplicate check - Add branch to avoid re-adding for duplicate entries
…r/runtime into AllowDuplicateTypeMaps
...libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime.InteropServices/tests/TrimmingTests/TypeMap.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #120160