Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c1f136f
[Mono.Android] Move Mono.Android.Export rooting off the shared Export…
simonrozsival Jun 29, 2026
35489d9
Drop now-redundant IL2026 suppression on AndroidTypeManager
simonrozsival Jun 29, 2026
98e0128
Address review: cover [ExportField], remove stale apicompat file, cle…
simonrozsival Jun 29, 2026
18db45c
[tests] Update BuildReleaseArm64SimpleDotNet.CoreCLR.apkdesc
simonrozsival Jun 29, 2026
002093e
Merge remote-tracking branch 'origin/main' into dev/simonrozsival/exp…
simonrozsival Jun 30, 2026
c1214ef
[tests] Update BuildReleaseArm64 CoreCLR apkdesc for Export rooting
simonrozsival Jun 30, 2026
ff1b627
[Mono.Android] Pin only DynamicCallbackCodeGenerator.Create, not All
simonrozsival Jun 30, 2026
52f2ca4
[Mono.Android] Use trimmer-analyzable Type.GetType, drop [DynamicDepe…
simonrozsival Jun 30, 2026
d4c3b16
[Mono.Android] Chain Type.GetType()?.GetMethod() for trimmer dataflow
simonrozsival Jun 30, 2026
117fc46
Simplify
simonrozsival Jun 30, 2026
ffeaf45
Try to allow trimming Mono.Android.Export when it's not needed
simonrozsival Jul 1, 2026
1863854
Change exception message
simonrozsival Jul 1, 2026
a02928f
Merge branch 'main' into dev/simonrozsival/export-dynamic-dependency
simonrozsival Jul 1, 2026
058569e
Merge branch 'main' into dev/simonrozsival/export-dynamic-dependency
simonrozsival Jul 1, 2026
d99cf6a
Make CreateDynamicDelegate properly trimmable
simonrozsival Jul 2, 2026
558f094
Merge branch 'dev/simonrozsival/export-dynamic-dependency' of github.…
simonrozsival Jul 2, 2026
a3cb051
Merge remote-tracking branch 'origin/main' into dev/simonrozsival/exp…
simonrozsival Jul 2, 2026
ca5dc52
[tests] Use smaller apkdesc sizes for SimpleDotNet.CoreCLR
simonrozsival Jul 3, 2026
1c94329
Code cleanup
simonrozsival Jul 3, 2026
debe97a
Extend support to ExportFieldAttribute
simonrozsival Jul 3, 2026
26aab7d
Clarify Mono.Android.Export load failure diagnostic
simonrozsival Jul 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Mono.Android/Android.Runtime/AndroidRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ public override void DeleteWeakGlobalReference (ref JniObjectReference value)
}

[UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Temporary suppression for Java.Interop reflection manager base.")]
[RequiresUnreferencedCode ("AndroidTypeManager is reflection-backed (it loads Mono.Android.Export for [Export] members) and is not trimming-compatible.")]
class AndroidTypeManager : JniRuntime.ReflectionJniTypeManager {
bool jniAddNativeMethodRegistrationAttributePresent;

Expand Down Expand Up @@ -401,9 +402,10 @@ protected override IEnumerable<string> GetSimpleReferences (Type type)

static MethodInfo? dynamic_callback_gen;

// See ExportAttribute.cs
[UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Mono.Android.Export.dll is preserved when [Export] is used via [DynamicDependency].")]
[UnconditionalSuppressMessage ("Trimming", "IL2075", Justification = "Mono.Android.Export.dll is preserved when [Export] is used via [DynamicDependency].")]
// See ExportAttribute.cs. The [DynamicDependency] roots Mono.Android.Export only when this
// loader is kept by the linker (the managed/reflection [Export] path). The trimmable type map
// generates JavaPeerProxy code instead and never calls this, so it does not pull in the assembly.
Comment thread
simonrozsival marked this conversation as resolved.
Outdated
[DynamicDependency (DynamicallyAccessedMemberTypes.All, "Java.Interop.DynamicCallbackCodeGenerator", "Mono.Android.Export")]
static Delegate CreateDynamicCallback (MethodInfo method)
{
if (dynamic_callback_gen == null) {
Comment thread
simonrozsival marked this conversation as resolved.
Outdated
Expand Down
1 change: 1 addition & 0 deletions src/Mono.Android/Android.Runtime/JNIEnvInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ internal static unsafe void Initialize (JnienvInitializeArgs* args)
[UnmanagedCallConv (CallConvs = new[] { typeof (CallConvCdecl) })]
private static unsafe partial void xamarin_app_init (IntPtr env, delegate* unmanaged <int, int, int, IntPtr*, void> get_function_pointer);

[UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "The AndroidTypeManager branch is only reached when RuntimeFeature.TrimmableTypeMap is false; the linker substitutes the feature switch and trims this branch in trimmable apps.")]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 💡 Trimmer/AOT — This method-level IL2026 suppression looks redundant. The AndroidTypeManager branch it justifies is reached only through the CreateAndroidTypeManager local function below (line ~189), which already carries its own IL2026 suppression — and the parallel CreateValueManager method uses the same local-function-with-suppression pattern without a method-level attribute. Since this PR doesn't change CreateTypeManager's body or introduce a new [RequiresUnreferencedCode] call reachable outside those local functions, is the outer suppression actually necessary? If the local-function suppression turned out to be insufficient here, a one-line note would help; otherwise consider dropping it for consistency with CreateValueManager.

Rule: Trimming suppressions should be minimal and scoped to the actual warning site

internal static JniRuntime.JniTypeManager CreateTypeManager (JnienvInitializeArgs args)
{
if (RuntimeFeature.TrimmableTypeMap) {
Expand Down
2 changes: 2 additions & 0 deletions src/Mono.Android/ApiCompatLinesToAdd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CannotRemoveAttribute : Attribute 'System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute' exists on 'Java.Interop.ExportAttribute' in the contract but not the implementation.
Total Issues: 1
Comment thread
simonrozsival marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
using System;
using System.Diagnostics.CodeAnalysis;

namespace Java.Interop {

[Serializable]
[AttributeUsage (AttributeTargets.Method | AttributeTargets.Constructor,
AllowMultiple=false,
Inherited=false)]
#if !NETSTANDARD2_0
[RequiresUnreferencedCode ("[ExportAttribute] uses dynamic features.")]
#endif
#if !JCW_ONLY_TYPE_NAMES
public
#endif // !JCW_ONLY_TYPE_NAMES
partial class ExportAttribute : Attribute {

[DynamicDependency (DynamicallyAccessedMemberTypes.All, "Java.Interop.DynamicCallbackCodeGenerator", "Mono.Android.Export")]
public ExportAttribute ()
{
}

[DynamicDependency (DynamicallyAccessedMemberTypes.All, "Java.Interop.DynamicCallbackCodeGenerator", "Mono.Android.Export")]
public ExportAttribute (string name)
{
Name = name;
Comment thread
simonrozsival marked this conversation as resolved.
Outdated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ MembersMustExist : Member 'public void Android.Telecom.CallControl.RequestVideoS
TypesMustExist : Type 'Android.Text.IInputType' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'Xamarin.Android.Net.AndroidClientHandler' does not exist in the implementation but it does exist in the contract.
CannotRemoveBaseTypeOrInterface : Type 'Android.Views.InputMethods.EditorInfo' does not implement interface 'Android.Text.IInputType' in the implementation but it does in the contract.
CannotRemoveAttribute : Attribute 'System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute' exists on 'Java.Interop.ExportAttribute' in the contract but not the implementation.
Loading