[typemap] Reject duplicate generated JCW names - #12569
Open
simonrozsival wants to merge 2 commits into
Open
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
27 tasks
Contributor
There was a problem hiding this comment.
Copilot review overview
Review tier: Lite
Findings: 2
New issues introduced by this change (2)
| Severity | Finding |
|---|---|
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildWithLibraryTests.cs — 💡 suggestion — errors is never null because Where(...) returns a non-null enumerable.… |
|
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. |
Comment on lines
694
to
695
| IEnumerable<string> errors = appb.LastBuildOutput.Where (x => x.Contains ("error XA4215")); | ||
| Assert.NotNull (errors, "Error should be XA4215"); |
Comment on lines
+127
to
+131
| Assert.False (CreateGenerator ().ValidateJavaNames (peers)); | ||
| Assert.Contains (logMessages, message => message.Contains ("XA4215") && message.Contains ("examplelib.DuplicatePeer")); | ||
| Assert.Contains (logMessages, message => message.Contains ("Library1.FirstPeer, Library1")); | ||
| Assert.Contains (logMessages, message => message.Contains ("Library2.SecondPeer, Library2")); | ||
| } |
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.

Summary
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:
GenerateTrimmableTypeMaptask tests: 14/14Part of #12561