[typemap] Diagnose unsupported export signatures - #12597
Open
simonrozsival wants to merge 8 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/JavaPeerScanner.cs — |
What changed in this PR
Adds early, localized diagnostics for unsupported [Export] / [ExportField] signature shapes in the trimmable typemap pipeline, so trimmable CoreCLR/NativeAOT fail deterministically (and before emitting typemap/Java/ACW-map outputs) instead of failing later in downstream steps.
Changes:
- Introduces XA4263 (“unsupported export signature type”) during trimmable scanning, while preserving XA4206 precedence for
[Export]on generic declaring types. - Tightens managed→JNI descriptor resolution to support “can we map this?” validation (via
TryManagedTypeToJniDescriptor) without changing the legacy fallback behavior used for signature generation. - Extends unit + integration parity fixtures to cover unsupported shapes and additional supported peer/interface/string-array/stream override cases, and documents XA4263.
| File | Description |
|---|---|
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/TestFixtures/TestTypes.cs | Adds fixture types covering unsupported [Export]/[ExportField] shapes (managed-only types, generics). |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/TrimmableTypeMapGeneratorTests.cs | Adds generator-level assertions for XA4263/XA4206 and ensures unsupported members aren’t emitted into peers/Java sources. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/ExportSignatureTests.cs | Adds focused fixture test ensuring unsupported signatures produce no generated members. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/JavaSourceSemanticParityTests.cs | Extends semantic parity coverage for additional supported method shapes (peer/interface/string-array/stream mapping). |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/JavaSourceParityFixture/JavaSourceParityTypes.cs | Adds new exported members used by the semantic parity fixture (peer, listener, string array, stream mapping). |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/TrimmableTypeMapBuildTests.cs | Adds build-matrix coverage for unsupported export shapes and expands “no partial outputs” checks to include acw-map.txt. |
| src/Xamarin.Android.Build.Tasks/Tasks/GenerateTrimmableTypeMap.cs | Implements new logger hooks for XA4206 and XA4263 in the MSBuild task. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.resx | Adds localized XA4263 message template. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs | Adds generated accessor for XA4263 resource. |
| src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/JavaPeerScanner.cs | Adds export signature validation and refactors managed→JNI mapping into a Try* API for “supported mapping” checks. |
| src/Microsoft.Android.Sdk.TrimmableTypeMap/ITrimmableTypeMapLogger.cs | Adds logger interface hooks for XA4206 and XA4263. |
| Documentation/docs-mobile/TOC.yml | Wires XA4263 doc into the docs TOC. |
| Documentation/docs-mobile/messages/xa4263.md | Adds documentation for XA4263. |
| Documentation/docs-mobile/messages/index.md | Adds XA4263 to the error code index. |
Files not reviewed (1)
- src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Generated file
This was referenced Aug 31, 2026
simonrozsival
force-pushed
the
simonrozsival-unsupported-export-signatures
branch
from
September 1, 2026 12:42
e40eedf to
7f245c2
Compare
simonrozsival
force-pushed
the
simonrozsival-unsupported-export-signatures
branch
2 times, most recently
from
September 1, 2026 12:54
816a31f to
b42a478
Compare
Reject unresolved managed, generic, and function-pointer export signatures during trimmable scanning with localized XA4263 diagnostics before any typemap, Java, or ACW-map output is written. Preserve legacy XA4206 precedence and supported Java mappings. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Honor ExportParameter return mappings on exported fields, reject incompatible special mappings before generation, and resolve Java peer descriptors by assembly identity through type forwarders. Add semantic, cross-assembly, and three-runtime regressions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Require special ExportParameter mappings to target exact scalar Stream or XmlReader types, and match Export, ExportParameter, and ExportField attributes by full Java.Interop identity throughout scanner validation and collection. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Ignore static exported constructors, diagnose unresolved instance constructor parameters without overlapping XA4260 shape ownership, preserve ExportParameter kinds through UCO activation, and resolve enum signatures by assembly identity. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Ignore Export name overrides on metadata constructors, assert UCO dispatch calls the managed constructor rather than a virtual method, and recursively reserve nested structural parameter shapes for XA4260. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Require Stream and XmlReader special export mappings to resolve from their framework assemblies or forwarders, preventing same-full-name user types from receiving framework adapters. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Recognize System.Private.Xml as the canonical XmlReader definition and verify both direct and multi-facade mappings without accepting same-full-name user types. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Exercise the resolved wrong-assembly branch by indexing a user assembly that defines System.Xml.XmlReader instead of relying on a missing assembly reference. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival
force-pushed
the
simonrozsival-unsupported-export-signatures
branch
from
September 1, 2026 13:15
b42a478 to
4cf3eb1
Compare
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
[Export]/[ExportField]signatures during trimmable scanning with localized XA4263 before typemap, Java, or ACW-map output[ExportParameter]mappingsJava.Interopidentity and resolve peer/enum/special framework types by assembly identity through forwardersFinal type-identity behavior
Special mappings require canonical framework identity, not just a managed full name:
System.IO.Stream:System.Runtimefacade or resolvedSystem.Private.CoreLibSystem.Xml.XmlReader:System.Xml.ReaderWriterfacade or resolvedSystem.Private.Xmlnetstandard → System.Xml.ReaderWriter → System.Private.Xmlare accepted through the existing cycle-safe forwarder resolverTests use minimal metadata assemblies for direct
System.Private.Xml, the two-hop facade chain, and a resolvedUser.Xmlassembly containingSystem.Xml.XmlReader. A separately compiled Android fixture and end-to-end builds retain the user-collision/no-output controls.Constructor diagnostics ownership
PR #12567 owns XA4260 for generic, byref, pointer, function-pointer, rectangular-array constructor parameters, including nested SZ-array forms. XA4263 owns unresolved managed types and invalid
[ExportParameter]kind/type/identity pairs. This PR does not duplicate XA4259/XA4261 analysis.An isolated composition with the latest #12567 reproduces its remaining follow-up: two XA4263-rejected overloads on the same type with default/missing
SuperArgumentsStringalso receive secondary XA4259 and XA4261. The coordinator will make that analyzer skip XA4263-rejected constructors after rebasing #12567 above this PR.Validation
GenerateExportedMembersgit diff --check; every added line at most 180 characters; full-name attribute audit cleanStacked on #12596. Tracks #12561.