Skip to content

[TrimmableTypeMap] Fix manifest builder gaps: SupportsGLTexture, UsesPermissionFlags, RoundIcon, dedup#11044

Draft
simonrozsival wants to merge 12 commits intomainfrom
dev/simonrozsival/scanner-gap-fixes
Draft

[TrimmableTypeMap] Fix manifest builder gaps: SupportsGLTexture, UsesPermissionFlags, RoundIcon, dedup#11044
simonrozsival wants to merge 12 commits intomainfrom
dev/simonrozsival/scanner-gap-fixes

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

Summary

Fix gaps in the assembly-level manifest builder compared to the old ManifestDocument path.

Depends on #11035

Changes

  • SupportsGLTexture: Add SupportsGLTextureInfo record, scanner handling in ScanAssemblyAttributes, and <supports-gl-texture> emission in AssemblyLevelElementBuilder
  • UsesPermissionFlags: Add UsesPermissionFlags property to UsesPermissionInfo, extract in scanner, emit as android:usesPermissionFlags
  • RoundIcon: Add android:roundIcon mapping for <permission>, <permission-group>, and <permission-tree> elements
  • TODO: Add comment for deferred BackupAgent/ManageSpaceActivity emission (needs type→JNI-name resolution)
  • Dedup: Add deduplication for <permission-group> and <permission-tree> against manifest template
  • Perf: Guard ParseNameAndProperties with KnownAssemblyAttributes HashSet to skip non-manifest attributes
  • Cleanup: Remove redundant #nullable enable from AssemblyLevelElementBuilder.cs

Tests

  • Scanner tests: SupportsGLTexture_ConstructorArg, UsesPermission_Flags
  • Generator tests: AssemblyLevel_SupportsGLTexture, AssemblyLevel_UsesPermissionFlags, AssemblyLevel_PermissionRoundIcon

simonrozsival and others added 10 commits March 27, 2026 11:53
Add scanning for assembly-level attributes ([Application], [Activity],
[Service], [BroadcastReceiver], [ContentProvider], permissions, etc.)
and wire them into the manifest generator via Generate(XDocument?) overload.

Replace ManifestModel.cs with individual Scanner/ record types for
better composability.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… types

Add assembly-level manifest attribute scanning to the TrimmableTypeMap scanner:

- AssemblyIndex.ScanAssemblyAttributes(): parses 9 assembly-level attribute types
  (UsesPermission, UsesLibrary, UsesFeature, UsesConfiguration, Permission,
  PermissionGroup, PermissionTree, MetaData, Property)
- JavaPeerScanner.ScanAssemblyManifestInfo(): aggregates attributes across assemblies
- JavaPeerScanner.ToComponentInfo()/HasPublicParameterlessCtor(): attaches component
  info to scanned peers
- ManifestGenerator.Generate(XDocument?): new overload accepting pre-loaded template
- ManifestGenerator.CreateDefaultManifest(): extracted from LoadOrCreateManifest
- Replace ManifestModel.cs (105-line flat class) with 12 focused record types
- Update JavaPeerInfo.ComponentAttribute doc comment

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e enable

- Fix ParseAttributes: collect IntentFilter/MetaData in local lists and attach
  after the loop to avoid creating attrInfo with wrong AttributeName when
  [IntentFilter] appears before [Activity]
- Remove redundant #nullable enable from 13 files (project has <Nullable>enable)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e name

UsesFeatureAttribute.Name has a private setter and is set via the
(string name) constructor. The parser only read NamedArguments, so
the feature name was always null when set via the constructor,
causing <uses-feature> entries to be silently skipped.

Read FixedArguments[0] first (matching ParseUsesPermissionAttribute
and ParseUsesLibraryAttribute), then allow NamedArguments to override.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add stub attributes (UsesFeatureAttribute with private-setter Name,
UsesPermissionAttribute, UsesLibraryAttribute, MetaDataAttribute,
IntentFilterAttribute) and assembly-level usages in TestFixtures.

Expose ScanAssemblyManifestInfo() via FixtureTestBase and add 6 tests
in AssemblyAttributeScanningTests covering constructor-arg parsing for
UsesFeature, UsesPermission, UsesLibrary, MetaData, and the GLESVersion
named-arg-only variant.

The UsesFeature_ConstructorArg and UsesFeature_ConstructorArgWithNamedProperty
tests are regression tests for the ParseUsesFeatureAttribute fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove leading blank lines from 13 files (leftover from #nullable enable removal)
- Remove unnecessary XML doc comments on internal record types
- Remove unused HasPublicDefaultConstructor property and HasPublicParameterlessCtor method
- Enhance ParseNameAndProperties to also read FixedArguments[0] for constructor-arg names
- Refactor individual Parse*Attribute methods into static Create*Info methods that
  accept pre-parsed (name, props) from ParseNameAndProperties, eliminating duplicated
  DecodeAttribute calls and NamedArguments iteration

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…overload

- Move ParseNameAndProperties(ca) call before the switch in ScanAssemblyAttributes
  so it runs once instead of being duplicated in every case
- Inline trivial CreatePermissionInfo/CreatePermissionGroupInfo/CreatePermissionTreeInfo
  one-liners directly at the call site
- Remove the file-path Generate() overload from ManifestGenerator; IO belongs in the caller
- Fix leading blank line in ManifestGeneratorTests.cs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
UsesLibraryAttribute(string, bool) puts Required in FixedArguments[1].
ParseNameAndProperties now stores additional bool ctor args in props
so CreateUsesLibraryInfo can read them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add SupportsGLTextureAttribute scanning + <supports-gl-texture> emission
- Add UsesPermissionFlags to UsesPermissionInfo + android:usesPermissionFlags emission
- Add RoundIcon mapping for <permission>, <permission-group>, <permission-tree>
- Add TODO comment for deferred BackupAgent/ManageSpaceActivity emission
- Add scanner + generator tests for all three gaps
- Add stub attributes + assembly-level usages in TestFixtures

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add KnownAssemblyAttributes guard to skip non-manifest attributes
- Add dedup for <permission-group> and <permission-tree> against template
- Remove redundant #nullable enable from AssemblyLevelElementBuilder.cs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 30, 2026 12:11
@simonrozsival simonrozsival added copilot `copilot-cli` or other AIs were used to author this trimmable-type-map labels Mar 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Closes feature gaps in the TrimmableTypeMap assembly-level manifest generation path so it matches the legacy ManifestDocument behavior (adds missing attribute scanning/emission and improves template dedup/perf).

Changes:

  • Add scanning + manifest emission for SupportsGLTexture, UsesPermissionFlags, and permission RoundIcon attributes.
  • Add assembly-level attribute filtering (KnownAssemblyAttributes) to reduce scanning overhead.
  • Update unit tests/fixtures to cover new assembly-attribute scanning and manifest generation.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/TestFixtures/StubAttributes.cs Adds stub attribute types used by scanning tests (UsesFeature/Permission/Library/MetaData/IntentFilter/SupportsGLTexture).
tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/TestFixtures/AssemblyAttributes.cs Adds assembly-level attributes for scanner fixture coverage.
tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Scanner/AssemblyAttributeScanningTests.cs New tests for assembly-level attribute scanning (including UsesPermissionFlags + SupportsGLTexture).
tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/ManifestGeneratorTests.cs Updates generator test helper to pass preloaded template; adds tests for new manifest emissions.
tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/FixtureTestBase.cs Caches both peers + scanned AssemblyManifestInfo for reuse across tests.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/UsesPermissionInfo.cs Adds UsesPermissionFlags support to uses-permission model.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/UsesLibraryInfo.cs Model for <uses-library>.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/UsesFeatureInfo.cs Model for <uses-feature> including GLESVersion/Required.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/UsesConfigurationInfo.cs Model for <uses-configuration>.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/SupportsGLTextureInfo.cs Model for <supports-gl-texture>.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/PropertyInfo.cs Model for <property>.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/PermissionTreeInfo.cs Model for <permission-tree>.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/PermissionInfo.cs Model for <permission>.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/PermissionGroupInfo.cs Model for <permission-group>.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/MetaDataInfo.cs Model for <meta-data> (record with required Name).
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/JavaPeerScanner.cs Adds ScanAssemblyManifestInfo() and wires per-type ComponentAttribute into peers.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/JavaPeerInfo.cs Clarifies comment for ComponentAttribute.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/IntentFilterInfo.cs Model for intent filters (actions/categories/properties).
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/ComponentInfo.cs Public component attribute model used for manifest generation.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/AssemblyManifestInfo.cs Aggregates assembly-level manifest info lists + application properties.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/AssemblyIndex.cs Implements assembly attribute scanning, known-attribute guard, and intent-filter/meta-data ordering fix.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/ManifestModel.cs Removes legacy manifest model types (replaced by scanner records).
src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/ManifestGenerator.cs Changes Generate() to accept optional preloaded template XDocument and refactors default manifest creation.
src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/AssemblyLevelElementBuilder.cs Emits new attributes/elements (RoundIcon, UsesPermissionFlags, supports-gl-texture) and adds dedup checks.

@simonrozsival simonrozsival changed the base branch from main to dev/simonrozsival/scanner-manifest-attributes March 30, 2026 12:16
simonrozsival and others added 2 commits March 30, 2026 15:05
Replace the TODO with actual implementation: resolve managed type name
strings from ApplicationProperties to JNI names via the scanned peers
list, and emit android:backupAgent / android:manageSpaceActivity on
the <application> element.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Dispose JavaPeerScanner in FixtureTestBase after scan completes
- Remove unused typeDef/index params from ToComponentInfo
- Use HashSet.Add() pattern for all dedup sets so cross-assembly
  duplicates are also prevented (not just template duplicates)
- Fix squashed closing brace in permission-group block

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival marked this pull request as draft March 30, 2026 16:25
Base automatically changed from dev/simonrozsival/scanner-manifest-attributes to main March 31, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot `copilot-cli` or other AIs were used to author this trimmable-type-map

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants