[TrimmableTypeMap] Add trimmable typemap runtime coverage tests - #11337
Merged
jonathanpeppers merged 1 commit intoMay 13, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds new runtime/device tests to the Mono.Android.NET-Tests suite to validate key Java→managed marshalling and activation behaviors when the trimmable typemap runtime path is enabled, extending coverage beyond constructor activation.
Changes:
- Add a new focused NUnit fixture (
TrimmableTypeMapRuntimeCoverageTests) gated byRuntimeFeature.TrimmableTypeMap. - Cover common callback shapes (string-like + primitives, framework object parameter,
Object[]parameter) plus Java-activated peer disposal behavior and closed-genericJavaList<string>wrapping from a Java-createdArrayList. - Wire the new test file into
Mono.Android.NET-Testscompilation inputs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj | Includes the new runtime coverage test source file in the test project build. |
| tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/TrimmableTypeMapRuntimeCoverageTests.cs | Adds new trimmable-typemap runtime coverage tests for Java→managed callbacks, activation/disposal, and generic collection wrapping. |
jonathanpeppers
approved these changes
May 13, 2026
jonathanpeppers
deleted the
dev/simonrozsival/broaden-trimmable-typemap-runtime-coverage
branch
May 13, 2026 20:12
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Adds focused Mono.Android.NET-Tests coverage for trimmable typemap runtime behavior beyond constructor activation.
Test coverage
JavaToManagedTextWatcherCallback_MarshalsStringAndPrimitiveParametersJava calls managed
ITextWatcher.OnTextChanged(ICharSequence, int, int, int)through the generated interface invoker. This covers callback marshalling with a Java string-like object plus primitive parameters. It is a common Android callback shape and verifies trimmable typemap metadata keeps the managed implementation discoverable.JavaToManagedClickCallback_MarshalsObjectParameterJava calls managed
View.IOnClickListener.OnClick(View). This covers callback marshalling where the parameter is a framework object that must be materialized as the correct managed peer, protecting a very common listener/event path.JavaToManagedInvocationHandlerCallback_MarshalsObjectArrayParameterJava calls managed
IInvocationHandler.Invoke(Object, Method, Object[]). This covers object-array marshalling across the Java-to-managed boundary. Arrays are a distinct typemap/marshalling shape from scalar objects and primitives, so this closes a separate runtime gap.JavaActivatedPeer_DisposeCanAccessThisAndInvokeVirtualMemberA registered managed peer is created through the Java activation path, then disposed while accessing
thisand invoking a virtual member. This extends coverage beyond constructor activation into lifetime behavior and verifies the trimmable typemap path still supports peer identity, handle use, and virtual dispatch during disposal.ClosedGenericJavaList_CanWrapJavaCreatedArrayListHandleA Java-created
java.util.ArrayListhandle is wrapped asJavaList<string>and used from managed code. This covers closed generic Java collection wrappers under trimmable typemap lookup and protects generic wrapper activation and typed collection operations, which differ from simple non-generic peer activation.Validation
MSBUILDDISABLENODEREUSE=1 ./dotnet-local.sh build tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj \ -t:RunTestApp -c Release \ -p:_AndroidTypeMapImplementation=trimmable \ -p:UseMonoRuntime=false \ -p:IncludeCategories=TrimmableTypeMapRuntimeCoverage \ -nr:falseResult: 5 total, 5 passed.
Full trimmable lane also runs these new tests successfully, but the overall lane remains red due to existing
Java.InteropTests.JniPeerMembersTestsremap failures unrelated to this fixture.