Repository navigation
[TrimmableTypeMap] Add coverage for XML custom-view precision roots #11279
Description
Part of #10788.
Problem
The trimmable TypeMap path currently has pieces of XML custom-view support, but we do not have targeted coverage for the future precision model where unused user ACWs can be trimmed while XML-referenced custom views remain rooted.
This is easy to mis-frame as "XML custom-view scanning is missing", but that is not accurate:
- [Xamarin.Android.Build.Tasks] Add ConvertCustomView Task #2129 added
ConvertCustomViewfor second-pass layout custom-view fixup. - [trimming] preserve custom views and
$(AndroidHttpClientHandlerType)#8954 wired$(_CustomViewMapFile)into the legacyMarkJavaObjectstrimmer step so XML-only custom views are preserved. - [TrimmableTypeMap] Generate per-assembly acw-map.txt from scanner results #10959 added trimmable
AcwMapWritersupport. - [TrimmableTypeMap] Wire AcwMapWriter to populate acw-map.txt #11015 wired
AcwMapWriterintoGenerateTrimmableTypeMapso trimmable builds populateacw-map.txt. - [TrimmableTypeMap] Build pipeline: targets, stubs, manifest integration, feature switches #11036 kept
acw-map.txtin the final trimmable build pipeline.
The remaining gap is test coverage and future precision: the production trimmable generator does not currently accept CustomViewMapFile or use layout-derived roots directly when deciding TypeMap entry unconditional vs conditional shape. This is not currently a correctness bug because ModelBuilder.IsUnconditionalEntry() treats all user-defined ACW classes as unconditional, and ForceUnconditionalEntries = true is broader still.
If we later narrow unconditional user-ACW rooting to recover more trimming wins, we must preserve the #8954 behavior by feeding layout custom-view roots into the trimmable TypeMap generator.
Existing coverage
ConvertResourcesCasesTestscoversConvertResourcesCases+ConvertCustomViewat task level with layout XML custom view tags/fragments andacwmap.txt.IncrementalBuildTest.ConvertCustomView(...)covers the product build pipeline and incremental behavior for custom-view fixup.AcwMapWriterTestscovers trimmableacw-map.txtformat and scanned fixture output.- Legacy
MarkJavaObjectscoverage exists for$(_CustomViewMapFile)-based preservation from [trimming] preserve custom views and$(AndroidHttpClientHandlerType)#8954.
Missing coverage
- End-to-end trimmable build coverage for a custom view referenced only from XML.
- A future precision-rooting test with:
- one custom view referenced only from layout XML;
- one unused user ACW not referenced anywhere;
- expected future behavior: XML custom view survives, unrelated unused user ACW can trim.
- A generator/task-level test proving
customview-map.txtaffects trimmable TypeMap entry classification once broad user-ACW roots are narrowed. - R8/ProGuard evidence that Java wrappers remain consistent with managed trimming: no missing XML custom-view class and no unnecessary stale wrapper for an unused trimmed peer.
Suggested test locations
- End-to-end trimmable build test:
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/TrimmableTypeMapBuildTests.cs - Task-level
CustomViewMapFilewiring:src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/GenerateTrimmableTypeMapTests.cs - Pure generator classification:
tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/TrimmableTypeMapGeneratorTests.csor a new focused generator test file - Runtime/device inflation smoke test: only add later in
tests/MSBuildDeviceIntegrationortests/Mono.Android-Testsif artifact-level coverage proves insufficient
Acceptance criteria
- Add coverage proving the current trimmable path supports XML custom-view fixup with generated
acw-map.txt. - Add or stage coverage for the future precision model before relaxing broad user-ACW unconditional rooting.
- Document the distinction between implemented XML scanner/fixup support and the missing precision-root input to the trimmable generator.
- If implementing precision rooting, add
CustomViewMapFileinput toGenerateTrimmableTypeMapand mark layout-referenced peers unconditional while allowing unrelated user ACWs to become conditional.
Activity