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

[typemap] Reject duplicate generated JCW names#12569
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

simonrozsivaland others added 2 commits August 28, 2026 14:41
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

CopilotAI 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)
SeverityFinding
Low severitysrc/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildWithLibraryTests.cs — 💡 suggestionerrors is never null because Where(...) returns a non-null enumerable.…
Low severitytests/​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.
FileDescription
tests/​Microsoft.Android.Sdk.TrimmableTypeMap.Tests/​Generator/​TrimmableTypeMapGeneratorTests.csAdds a focused unit test asserting XA4215 emission for duplicate generated JCW names.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​BuildWithLibraryTests.csExpands integration coverage to validate XA4215 behavior and output artifacts across typemap implementations/runtimes.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GenerateTrimmableTypeMap.csImplements new XA4215 logging methods in the MSBuild logger using localized resources.
src/​Microsoft.Android.Sdk.TrimmableTypeMap/​TrimmableTypeMapGenerator.csAdds early cross-assembly duplicate JCW name rejection with deterministic XA4215 logging.
src/​Microsoft.Android.Sdk.TrimmableTypeMap/​ITrimmableTypeMapLogger.csExtends the logging interface with XA4215 header/detail methods.

simonrozsivaland others added 3 commits August 31, 2026 11:37
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival

Copy link
Copy Markdown
MemberAuthor

/review

@simonrozsivalsimonrozsival 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-actionsBot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #12569

@github-actionsgithub-actionsBot 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 mainSep 3, 2026
44 checks passed
@simonrozsival
simonrozsival deleted the simonrozsival-duplicate-jcw-names branch September 3, 2026 06:00
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-reviewThis 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

@simonrozsival@rolfbjarne