Skip to content

[typemap] Reject duplicate generated JCW names - #12569

Merged
simonrozsival merged 5 commits into
mainfrom
simonrozsival-duplicate-jcw-names
Sep 3, 2026
Merged

simonrozsival merged 5 commits into
mainfrom
simonrozsival-duplicate-jcw-names

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Summary

  • capture llvm-ir XA4214/XA4215 behavior with cross-assembly duplicate Java wrapper fixtures
  • reject conflicting generated JCW names before writing typemap, Java, or ACW-map outputs
  • emit existing localized XA4215 header/detail diagnostics deterministically
  • preserve intentional alias groups and legacy same-module behavior

TDD evidence

Before the fix, the unchanged fixture failed with XA4215 under llvm-ir but succeeded under trimmable CoreCLR and NativeAOT. Trimmable wrote duplicate ACW-map entries, overwrote one DuplicatePeer.java, and retained inconsistent mappings.

After the fix, the focused llvm-ir, trimmable CoreCLR, and trimmable NativeAOT fixture passes 3/3. Additional validation:

  • standalone trimmable typemap suite: 771/771
  • GenerateTrimmableTypeMap task tests: 14/14

Part of #12561

Copilot AI lite review requested due to automatic review settings August 28, 2026 12:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

Review tier: Lite
Findings: 2 Low severity

New issues introduced by this change (2)
Severity Finding
Low severity src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildWithLibraryTests.cs — 💡 suggestion — errors is never null because Where(...) returns a non-null enumerable.…
Low severity tests/​Microsoft.Android.Sdk.TrimmableTypeMap.Tests/​Generator/​TrimmableTypeMapGeneratorTests.cs — 💡 suggestion — The new XA4215 regression test uses broad Contains predicates, which can…
What changed in this PR

This PR closes a feature-parity gap in the trimmable typemap pipeline by detecting cross-assembly collisions in generated Java wrapper (JCW) names early and emitting deterministic, localized XA4215 diagnostics, preventing ambiguous Java/acw-map/typemap outputs.

Changes:

  • Add duplicate generated Java type validation in TrimmableTypeMapGenerator.ValidateJavaNames() and log XA4215 header + detail lines deterministically.
  • Extend the trimmable typemap logger interface and MSBuild task logger to emit XA4215 diagnostics via localized resource strings.
  • Add/expand regression coverage for duplicate generated JCW names across llvm-ir, trimmable CoreCLR, and trimmable NativeAOT builds.
File Description
tests/​Microsoft.Android.Sdk.TrimmableTypeMap.Tests/​Generator/​TrimmableTypeMapGeneratorTests.cs Adds a focused unit test asserting XA4215 emission for duplicate generated JCW names.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildWithLibraryTests.cs Expands integration coverage to validate XA4215 behavior and output artifacts across typemap implementations/runtimes.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GenerateTrimmableTypeMap.cs Implements new XA4215 logging methods in the MSBuild logger using localized resources.
src/​Microsoft.Android.Sdk.TrimmableTypeMap/​TrimmableTypeMapGenerator.cs Adds early cross-assembly duplicate JCW name rejection with deterministic XA4215 logging.
src/​Microsoft.Android.Sdk.TrimmableTypeMap/​ITrimmableTypeMapLogger.cs Extends the logging interface with XA4215 header/detail methods.

simonrozsival and others added 3 commits August 31, 2026 11:37
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #12569

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: ✅ LGTM

Findings: 0 errors · 0 warnings · 1 suggestion

The collision check correctly runs before typemap, Java, and ACW-map output generation; XA4215 diagnostics are localized and deterministic; and the integration matrix covers llvm-ir, trimmable CoreCLR, and NativeAOT. All 44 CI checks pass. The inline suggestion is non-blocking and asks only for direct coverage of the intentionally preserved same-assembly alias branch.

Generated by Android PR Reviewer for #12569 · gpt56 · 140 AIC · ⌖ 8.89 AIC · ⊞ 25.7K
Comment /review to run again

@simonrozsival
simonrozsival merged commit 466b467 into main Sep 3, 2026
44 checks passed
@simonrozsival
simonrozsival deleted the simonrozsival-duplicate-jcw-names branch September 3, 2026 06:00
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). trimmable-type-map

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants