[typemap] Honor explicit interface invokers - #12565
Open
simonrozsival wants to merge 3 commits into
Open
Conversation
Track Java.Interop InvokerType metadata and its owning assembly through scanner, model, associations, and emitted proxy references. Add constructor activation regression coverage for interface, inherited interface, abstract, identity, and cross-assembly invoker shapes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove speculative cross-assembly invoker support and retain same-assembly Xamarin.Android and Java.Interop constructor activation coverage. Prefer the explicitly requested interface or abstract proxy before hierarchy fallbacks so trimmable lookup matches reflection behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Parse serialized invoker type names and accept only local/default assembly ownership. Ignore unsupported cross-assembly metadata and resolve activation constructors solely from the target assembly. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/TestFixtures/InvokerFixtures.cs — 💡 suggestion: The explicit invoker/proxy type should implement the target interface; otherwise this… |
What changed in this PR
This PR closes a TrimmableTypeMap feature-parity gap by honoring explicit invoker metadata (including same-assembly JniTypeSignatureAttribute.InvokerType) and adjusting runtime proxy selection so interface/abstract targets prefer the explicitly validated proxy while concrete targets keep the existing “most-derived” behavior.
Changes:
- Update runtime proxy resolution to prefer explicit proxies for interface/abstract targets while preserving hierarchy-first behavior for concrete targets.
- Extend the trimmable typemap scanner to consume same-assembly explicit invoker metadata and resolve invoker activation constructor style from the declaring assembly (ignoring unsupported cross-assembly invokers).
- Add new device/runtime and scanner coverage for invoker activation, inherited interfaces, abstract targets, and peer identity.
| File | Description |
|---|---|
| tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj | Adds the new invoker activation test file to the device test project. |
| tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/InvokerActivationTests.cs | New device tests validating invoker selection, single activation, and identity preservation. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/TestFixtures/StubAttributes.cs | Extends the stub JniTypeSignatureAttribute to support interfaces and InvokerType. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/TestFixtures/InvokerFixtures.cs | New fixtures for explicit-invoker scanning scenarios (including cross-assembly ignore case). |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Scanner/JavaPeerScannerTests.cs | Adds scanner tests covering explicit invokers and cross-assembly ignore behavior. |
| src/Mono.Android/Microsoft.Android.Runtime/TrimmableTypeMap.cs | Adjusts runtime proxy selection ordering for interface/abstract targets. |
| src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/JavaPeerScanner.cs | Implements same-assembly invoker resolution + assembly-scoped activation ctor style lookup. |
| src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/AssemblyIndex.cs | Captures InvokerType from JniTypeSignature into RegisterInfo for scanner consumption. |
Suppressed comments (1)
tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/TestFixtures/InvokerFixtures.cs:23
- 💡 suggestion: Same as above: the proxy type used as an explicit invoker should implement the interface it is meant to represent, so the fixture reflects a valid runtime invoker shape.
public sealed class InheritedJavaInteropListProxy : Java.Lang.Object
| { | ||
| } | ||
|
|
||
| public sealed class ExplicitJavaInteropCollectionProxy : Java.Lang.Object |
27 tasks
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
JniTypeSignatureAttribute.InvokerTypemetadataTDD matrix
Before the fix, the unchanged explicit-invoker test passed with llvm-ir but selected the wrong proxy under both trimmable runtimes. After the fix:
Microsoft.Android.Sdk.TrimmableTypeMap.Tests: 774/774.Part of #12561