Skip to content

[typemap] Honor explicit interface invokers - #12565

Open
simonrozsival wants to merge 3 commits into
mainfrom
simonrozsival-invoker-constructor-parity
Open

[typemap] Honor explicit interface invokers#12565
simonrozsival wants to merge 3 commits into
mainfrom
simonrozsival-invoker-constructor-parity

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Summary

  • consume same-assembly JniTypeSignatureAttribute.InvokerType metadata
  • resolve the invoker activation constructor style from its declaring assembly
  • prefer the validated explicit proxy for requested interface and abstract targets
  • retain existing most-derived hierarchy behavior for concrete targets
  • ignore unsupported cross-assembly invoker metadata
  • add constructor-based XA, Java.Interop, inherited-interface, abstract-type, and peer-identity coverage

TDD 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:

  • llvm-ir + CoreCLR: 4/4
  • trimmable + CoreCLR: 4/4
  • trimmable + NativeAOT: 4/4

Microsoft.Android.Sdk.TrimmableTypeMap.Tests: 774/774.

Part of #12561

simonrozsival and others added 3 commits August 28, 2026 12:34
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>
Copilot AI lite review requested due to automatic review settings August 28, 2026 12:07

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: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants