Skip to content

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

Open
simonrozsival wants to merge 5 commits intomainfrom
dev/simonrozsival/scanner-gap-fixes
Open

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

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

@simonrozsival simonrozsival commented Mar 30, 2026

Summary

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

Changes

Scanner

  • SupportsGLTexture: Add SupportsGLTextureInfo record and SupportsGLTextureAttribute handling in ScanAssemblyAttributes
  • UsesPermissionFlags: Add UsesPermissionFlags property to UsesPermissionInfo, extract in scanner
  • Perf: Guard ParseNameAndProperties with KnownAssemblyAttributes HashSet to skip non-manifest attributes early

Generator

  • SupportsGLTexture: Emit <supports-gl-texture> element in AssemblyLevelElementBuilder
  • UsesPermissionFlags: Emit android:usesPermissionFlags attribute on <uses-permission>
  • RoundIcon: Add android:roundIcon mapping for <permission>, <permission-group>, and <permission-tree> elements
  • BackupAgent/ManageSpaceActivity: Resolve managed type name strings to JNI names via scanned peers and emit android:backupAgent / android:manageSpaceActivity on <application>
  • Dedup: Deduplicate <permission-group> and <permission-tree> against manifest template (matching existing <permission> and <uses-permission> dedup)

Cleanup

  • Remove redundant #nullable enable from AssemblyLevelElementBuilder.cs
  • Dispose JavaPeerScanner in FixtureTestBase after scan completes
  • Remove unused parameters from ToComponentInfo
  • Use HashSet.Add() pattern for all dedup sets to prevent cross-assembly duplicates

Tests

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

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 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
@simonrozsival simonrozsival force-pushed the dev/simonrozsival/scanner-gap-fixes branch from eadfbb3 to ab21c88 Compare March 31, 2026 16:01
@simonrozsival simonrozsival marked this pull request as ready for review March 31, 2026 16:02
simonrozsival and others added 4 commits April 1, 2026 16:40
- 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>
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 force-pushed the dev/simonrozsival/scanner-gap-fixes branch from ab21c88 to 2b54030 Compare April 1, 2026 14:42
Copy link
Copy Markdown
Member Author

@simonrozsival simonrozsival left a comment

Choose a reason for hiding this comment

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

🤖 AI Review Summary

Verdict: ⚠️ Needs Changes

Found 1 issue (1 warning):

  • ⚠️ Error handling: ApplyTypeProperty silently does nothing when the managed type cannot be resolved to a Java peer (AssemblyLevelElementBuilder.cs:207-212)

👍 Good changes overall:

  • HashSet.Add() pattern for dedup is correct per Postmortem #41
  • KnownAssemblyAttributes HashSet guard is a smart perf optimization to skip non-manifest attributes early
  • SupportsGLTexture and UsesPermissionFlags follow existing patterns well
  • Proper using var scanner in test base
  • Assembly-qualified name stripping handles "TypeName, AssemblyName" format correctly

Review generated by android-reviewer from review guidelines.

app.SetAttributeValue (AndroidNs + xmlAttrName, peer.JavaName.Replace ('/', '.'));
return;
}
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🤖 ⚠️ Error handling — When the foreach loop ends without finding a peer matching managedName, the method silently returns. The user's BackupAgent or ManageSpaceActivity attribute is ignored with no diagnostic. This is hard to debug — the manifest will be generated without android:backupAgent / android:manageSpaceActivity and the user won't know why.

Consider logging a warning when the type cannot be resolved:

foreach (var peer in allPeers) {
	if (peer.ManagedTypeName == managedName) {
		app.SetAttributeValue (AndroidNs + xmlAttrName, peer.JavaName.Replace ('/', '.'));
		return;
	}
}
// Type not found — user misconfiguration or missing assembly
log?.Invoke ($"Could not resolve {propertyName} type '{managedName}' to a Java peer for android:{xmlAttrName}.");

This would require adding a logging callback to the method (or using the builder's existing log mechanism).

Rule: Log messages must have context (Postmortem #6)

Add warning callback to ApplyTypeProperty so users get diagnostic
output when a managed type name cannot be resolved to a Java peer
for android:backupAgent or android:manageSpaceActivity attributes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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