Uh oh!
There was an error while loading. Please reload this page.
[TrimmableTypeMap] Keep array rank anchors private - #11297
Conversation
Include ArrayMapAnchors.cs in Mono.Android so generated per-rank array TypeMap entries can resolve their shared Microsoft.Android.Runtime.__ArrayMapRankN anchor types at NativeAOT compile time. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the shared array typemap anchor types in an existing compiled Mono.Android runtime source file so the project does not need a separate Compile item for ArrayMapAnchors.cs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename the typemap abstraction to ITypeMap and move array lookup behind the unified runtime wrapper. Generated typemap assemblies now define private __ArrayMapRankN anchors, and the root loader builds per-assembly/per-rank array maps instead of referencing shared Mono.Android anchors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Emit TypeMapAssemblyTargetAttribute entries for each per-assembly array rank anchor so NativeAOT TypeMapping sees the same private rank groups requested by TypeMapLoader.Initialize. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the TrimmableTypeMap pipeline so that __ArrayMapRank{N} anchors are emitted as internal types within each generated per-assembly typemap, instead of referencing shared anchors from Mono.Android. The root typemap generator is updated to emit matching TypeMapAssemblyTargetAttribute<T> metadata for these per-assembly rank anchors and to pass per-assembly/per-rank array dictionaries to the runtime initializer.
Changes:
- Emit
__ArrayMapRank{N}as internal TypeDefs inside each generated typemap assembly and stop referencing sharedMono.Androidrank anchors. - Update the root typemap generator to emit per-assembly rank
TypeMapAssemblyTargetAttribute<T>entries and to buildarrayMapsByAssemblyAndRankfor initialization. - Refactor runtime typemap abstractions (
ITypeMap) so array-type lookup goes through the typemap interface and supports per-universe/per-assembly rank maps.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/TypeMapModelBuilderTests.cs | Updates expectations so per-assembly typemaps define rank anchors and do not TypeRef Mono.Android for them. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/RootTypeMapAssemblyGeneratorTests.cs | Adds coverage ensuring root target attributes and TypeRefs point to per-assembly rank anchors, and updates IgnoresAccessChecksTo expectations. |
| src/Mono.Android/Mono.Android.csproj | Switches compile include from the old interface file to the new ITypeMap.cs. |
| src/Mono.Android/Microsoft.Android.Runtime/TrimmableTypeMap.cs | Refactors initialization and array lookup to use ITypeMap.TryGetArrayType, and adds per-assembly array-map initialization support. |
| src/Mono.Android/Microsoft.Android.Runtime/SingleUniverseTypeMap.cs | Implements ITypeMap and adds array-map lookup across provided per-universe/per-assembly rank dictionaries. |
| src/Mono.Android/Microsoft.Android.Runtime/ITypeMap.cs | Renames/redefines the typemap abstraction and adds TryGetArrayType. |
| src/Mono.Android/Microsoft.Android.Runtime/ArrayMapAnchors.cs | Removes shared rank-anchor types from Mono.Android. |
| src/Mono.Android/Microsoft.Android.Runtime/AggregateTypeMap.cs | Updates to ITypeMap and forwards array-type lookup across universes. |
| src/Microsoft.Android.Sdk.TrimmableTypeMap/TrimmableTypeMapGenerator.cs | Removes the hardcoded max-rank limit that was tied to shared Mono.Android anchor availability. |
| src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/TypeMapAssemblyEmitter.cs | Emits internal __ArrayMapRank{N} TypeDefs into each generated typemap assembly. |
| src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/RootTypeMapAssemblyGenerator.cs | Emits per-assembly rank target attributes and generates initialization IL that constructs arrayMapsByAssemblyAndRank. |
Uh oh!
There was an error while loading. Please reload this page.
…mmable-private-array-typemap
simonrozsival
commented
May 7, 2026
CI failures are unrelated |
Uh oh!
There was an error while loading. Please reload this page.
Moves the generated array rank marker cleanup out of the NativeAOT PR.
This keeps array rank anchors private to each generated typemap assembly and emits matching root TypeMapAssemblyTargetAttribute metadata for the per-assembly rank groups.