From d4ee9be240af4e09b399cc1d717e45d31a983d82 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Mon, 13 Apr 2026 14:14:31 +0200 Subject: [PATCH 1/3] Add trimmable typemap test plumbing and CI lane Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../yaml-templates/stage-package-tests.yaml | 12 +++++++++++- .../Java.Interop/JavaObjectExtensionsTests.cs | 2 +- .../Mono.Android-Tests/Java.Interop/JnienvTest.cs | 4 ++-- .../Mono.Android.NET-Tests.csproj | 6 ++++++ .../NUnitInstrumentation.cs | 14 ++++++++++++++ 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/build-tools/automation/yaml-templates/stage-package-tests.yaml b/build-tools/automation/yaml-templates/stage-package-tests.yaml index 869ac45cee1..0133dd5d0cd 100644 --- a/build-tools/automation/yaml-templates/stage-package-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-package-tests.yaml @@ -199,10 +199,20 @@ stages: testName: Mono.Android.NET_Tests-CoreCLR project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)CoreCLR.xml - extraBuildArgs: -p:TestsFlavor=CoreCLR -p:UseMonoRuntime=false + extraBuildArgs: -p:_AndroidTypeMapImplementation=llvm-ir artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab artifactFolder: $(DotNetTargetFramework)-CoreCLR + - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml + parameters: + configuration: $(XA.Build.Configuration) + testName: Mono.Android.NET_Tests-CoreCLRTrimmable + project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj + testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)CoreCLRTrimmable.xml + extraBuildArgs: -p:_AndroidTypeMapImplementation=trimmable -p:UseMonoRuntime=false + artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab + artifactFolder: $(DotNetTargetFramework)-CoreCLRTrimmable + - template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml parameters: configuration: $(XA.Build.Configuration) diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JavaObjectExtensionsTests.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JavaObjectExtensionsTests.cs index 1b13316cc3d..1ef98e558e7 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JavaObjectExtensionsTests.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JavaObjectExtensionsTests.cs @@ -15,7 +15,7 @@ namespace Java.InteropTests { [TestFixture] public class JavaObjectExtensionsTests { - [Test] + [Test, Category ("TrimmableIgnore")] public void JavaCast_BaseToGenericWrapper () { using (var list = new JavaList (new[]{ 1, 2, 3 })) diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs index a563f56fd3a..be5347a780a 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/JnienvTest.cs @@ -121,7 +121,7 @@ public void InvokingNullInstanceDoesNotCrashDalvik () } } - [Test] + [Test, Category ("TrimmableIgnore")] public void NewOpenGenericTypeThrows () { try { @@ -301,7 +301,7 @@ public void ActivatedDirectObjectSubclassesShouldBeRegistered () } } - [Test] + [Test, Category ("TrimmableIgnore")] public void ActivatedDirectThrowableSubclassesShouldBeRegistered () { if (Build.VERSION.SdkInt <= BuildVersionCodes.GingerbreadMr1) diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj b/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj index 33bb45ed65c..02951579dc8 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj @@ -37,6 +37,12 @@ $(ExcludeCategories):InetAccess:NetworkInterfaces + + false + CoreCLRTrimmable + $(ExcludeCategories):NativeTypeMap:TrimmableIgnore:SSL + + diff --git a/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.RuntimeTests/NUnitInstrumentation.cs b/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.RuntimeTests/NUnitInstrumentation.cs index 215fde081a9..867dab2ffb9 100644 --- a/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.RuntimeTests/NUnitInstrumentation.cs +++ b/tests/Mono.Android-Tests/Mono.Android-Tests/Xamarin.Android.RuntimeTests/NUnitInstrumentation.cs @@ -25,6 +25,20 @@ protected override string LogTag protected NUnitInstrumentation(IntPtr handle, JniHandleOwnership transfer) : base(handle, transfer) { + if (Microsoft.Android.Runtime.RuntimeFeature.TrimmableTypeMap) { + // Java.Interop-Tests fixtures that use JavaObject types (not Java.Lang.Object) + // don't have JCW Java classes in the trimmable APK, and method remapping + // tests require Java-side support not present in the trimmable path. + // Exclude these entire fixtures to prevent ClassNotFoundException crashes. + ExcludedTestNames = new [] { + "Java.InteropTests.JavaObjectTest", + "Java.InteropTests.InvokeVirtualFromConstructorTests", + "Java.InteropTests.JniPeerMembersTests", + "Java.InteropTests.JniTypeManagerTests", + "Java.InteropTests.JniValueMarshaler_object_ContractTests", + "Java.InteropTests.JavaExceptionTests.InnerExceptionIsNotAProxy", + }; + } } protected override IList GetTestAssemblies() From ff2c15fb60b3a26e4ef5ecc70ffcf7cc603906bf Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Mon, 13 Apr 2026 14:21:45 +0200 Subject: [PATCH 2/3] Keep CoreCLR test flavor naming in CI Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- build-tools/automation/yaml-templates/stage-package-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-tools/automation/yaml-templates/stage-package-tests.yaml b/build-tools/automation/yaml-templates/stage-package-tests.yaml index 0133dd5d0cd..a824c974f39 100644 --- a/build-tools/automation/yaml-templates/stage-package-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-package-tests.yaml @@ -199,7 +199,7 @@ stages: testName: Mono.Android.NET_Tests-CoreCLR project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)CoreCLR.xml - extraBuildArgs: -p:_AndroidTypeMapImplementation=llvm-ir + extraBuildArgs: -p:TestsFlavor=CoreCLR -p:_AndroidTypeMapImplementation=llvm-ir artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab artifactFolder: $(DotNetTargetFramework)-CoreCLR From e084238a0ad0146ef193514eb1d4c891a5f59f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Rozs=C3=ADval?= Date: Tue, 14 Apr 2026 09:12:37 +0200 Subject: [PATCH 3/3] Update extraBuildArgs for Mono.Android.NET tests --- .../automation/yaml-templates/stage-package-tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-tools/automation/yaml-templates/stage-package-tests.yaml b/build-tools/automation/yaml-templates/stage-package-tests.yaml index a824c974f39..592eed5c2fc 100644 --- a/build-tools/automation/yaml-templates/stage-package-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-package-tests.yaml @@ -199,7 +199,7 @@ stages: testName: Mono.Android.NET_Tests-CoreCLR project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)CoreCLR.xml - extraBuildArgs: -p:TestsFlavor=CoreCLR -p:_AndroidTypeMapImplementation=llvm-ir + extraBuildArgs: -p:TestsFlavor=CoreCLR -p:_AndroidTypeMapImplementation=llvm-ir -p:UseMonoRuntime=false artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab artifactFolder: $(DotNetTargetFramework)-CoreCLR @@ -209,7 +209,7 @@ stages: testName: Mono.Android.NET_Tests-CoreCLRTrimmable project: tests/Mono.Android-Tests/Mono.Android-Tests/Mono.Android.NET-Tests.csproj testResultsFiles: TestResult-Mono.Android.NET_Tests-$(XA.Build.Configuration)CoreCLRTrimmable.xml - extraBuildArgs: -p:_AndroidTypeMapImplementation=trimmable -p:UseMonoRuntime=false + extraBuildArgs: -p:TestsFlavor=CoreCLRTrimmable -p:_AndroidTypeMapImplementation=trimmable -p:UseMonoRuntime=false artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab artifactFolder: $(DotNetTargetFramework)-CoreCLRTrimmable