Skip to content

Conversation

jtschuster
Copy link
Member

Fixes #120160

@jtschuster jtschuster added this to the 11.0.0 milestone Oct 8, 2025
@jtschuster jtschuster self-assigned this Oct 8, 2025
@Copilot Copilot AI review requested due to automatic review settings October 8, 2025 00:14
Copy link
Contributor

@Copilot Copilot AI left a 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

Copy link
Contributor

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

…pServices/TypeMapLazyDictionary.cs

Co-authored-by: Copilot <[email protected]>
- Use Span for UTF8 string comparison
- Negate name check for duplicate check
- Add branch to avoid re-adding for duplicate entries
Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

TypeMap API: Support duplicate TypeMapAttributes where trimTarget differs
3 participants