Skip to content

Track remaining Mono.Android trimming/AOT warning waivers #13618

Open

Description

@simonrozsival

Android framework version

net12.0-android (Preview)

Affected platform version

.NET 12 / NativeAOT and trimmed Android builds

Description

There are existing IL2xxx/IL3xxx waivers in src/Mono.Android that predate the warning-policy cleanup. They need a dedicated follow-up so each site is either:

  1. annotated with RequiresUnreferencedCode / RequiresDynamicCode and those contracts propagated to callers, or
  2. redesigned so the unsafe reflection/dynamic-code path is not reachable, or
  3. retained only with a narrowly scoped, proven-safe justification when neither is possible.

The immediate audit inventory is:

  • Android.Runtime/JNIEnv.cs: IL2067 around the dictionary-based peer constructor lookup.
  • Java.Interop/JavaConvert.cs: IL2055 / IL2067 around dynamically closed collection converter discovery.
  • Microsoft.Android.Runtime/TrimmableTypeMapTypeManager.cs: IL2026 for CoreCLR array reconstruction.
  • Android.Runtime/ResourceDesignerAttribute.cs: IL2026 / IL2073 fallbacks for non-assembly-qualified type names.
  • Java.Interop/SafeArrayFactory.cs, ValueTypeFactory.cs, and SafeJavaCollectionFactory.cs: IL3050, IL2055, IL2071, and IL2072 around runtime generic/array construction.
  • Java.Interop/ValueTypeDictionaryFactory.cs: IL2026 around typemap attribute interpretation.
  • Microsoft.Android.Runtime/RuntimeEventSource.cs: four IL2026 waivers for event-source payload serialization.

#8724 previously tracked a broad set of AOT warnings, but it is closed and is not a sufficiently current contract-by-contract record. This issue should track only the remaining waivers and their resolution rationale.

Warning-policy cleanup in PR #13428 does not add new IL waivers: it replaces applicable test IL3050 suppressions with RequiresDynamicCode, preserves pre-existing source waivers unchanged, and removes an invalid array-waiver case.

Steps to Reproduce

  1. Build src/Mono.Android/Mono.Android.csproj with -p:EnableAotAnalyzer=true.
  2. Audit any IL2xxx/IL3xxx diagnostics suppressed by UnconditionalSuppressMessage or scoped pragmas.
  3. For each site, prefer RequiresUnreferencedCode / RequiresDynamicCode propagation and verify the public/internal caller contracts.

Did you find any workaround?

Existing waivers let the analyzer run, but they are not a fix. #8724 is the historical reference; this issue is intended to replace it as the focused tracker for the remaining sites.

Relevant log output

See the IL2026/IL2055/IL2067/IL2071/IL2072/IL3050 sites listed above.

Activity

  1. added
    needs-triage
    on Nov 18, 2026
  2. removed
    needs-triage
    on Nov 19, 2026
  3. added this to the .NET 12 milestone on Nov 19, 2026
  4. added
    Area: Trimming
    Area: NativeAOT
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: NativeAOTArea: Trimming

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions