Skip to content

[TrimmableTypeMap] Unify InTune/method replacement support between AndroidTypeManager and TrimmableTypeMapTypeManager #10968

Description

@simonrozsival

Part of #10788

Problem

AndroidTypeManager implements InTune/MDM support via GetReplacementTypeCore() and GetReplacementMethodInfoCore(). These handle Java library desugaring by looking up replacement types and methods via native _monodroid_lookup_replacement_type() and _monodroid_lookup_replacement_method_info() calls.

The new TrimmableTypeMapTypeManager (added in #10967) does not implement this functionality. Apps using InTune SDK or Java library desugaring will not work correctly with the trimmable typemap path.

Proposed solution

Extract the replacement logic from AndroidTypeManager into a shared base class or helper that both type managers can use. This avoids duplicating the InTune-specific code while keeping the trimmable path clean.

Key methods to share:

  • GetReplacementTypeCore() — looks up desugared types
  • GetReplacementMethodInfoCore() — maps methods to replacement implementations (instance → static conversions)
  • GetStaticMethodFallbackTypesCore() — hardcoded desugaring patterns (Desugar*$_CC, *$-CC)

Considerations

  • The native P/Invoke calls (_monodroid_lookup_replacement_type, _monodroid_lookup_replacement_method_info) may not be trimming-safe — need to verify
  • ManagedTypeManager already has a non-native implementation of GetStaticMethodFallbackTypesCore — could be reused
  • Consider whether InTune support is even needed in the trimmable (NativeAOT) path, or only CoreCLR

Activity

  1. added this to the .NET 11 milestone on Mar 18, 2026
  2. added
    needs-triage
    on Mar 18, 2026
  3. simonrozsival commented on Mar 18, 2026

    @simonrozsival
    MemberAuthor

    Implementation note: managed vs native lookups

    The remapping data is currently generated as LLVM IR (JniRemappingAssemblyGenerator : LlvmIrComposer) and compiled into the native library. The native JniRemapping::lookup_replacement_type and lookup_replacement_method_info are simple linear scans over these build-time generated arrays.

    Short-term (v1): Use the same P/Invoke (_monodroid_lookup_replacement_type, _monodroid_lookup_replacement_method_info) from TrimmableTypeMapTypeManager. The native tables exist in the binary regardless of typemap path — the P/Invoke works on all platforms (Mono, CoreCLR, NativeAOT).

    Long-term (low priority): Generate the remapping tables as managed IL (e.g., as part of the TypeMap assembly or a separate generated assembly) instead of LLVM IR. This would allow doing the lookups entirely in managed code, eliminating the P/Invoke and native dependency. Same approach as we did with the typemap itself (TypeMapping API instead of native binary tables).

  4. locked and limited conversation to collaborators on Jun 11, 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

    needs-triagetrimmable-type-map

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions