Skip to content

[Xamarin.Android.Build.Tasks] Remove obsolete manifest code - #13525

Merged
simonrozsival merged 2 commits into
mainfrom
jonathanpeppers-obsolete-manifest-removal
Nov 13, 2026
Merged

simonrozsival merged 2 commits into
mainfrom
jonathanpeppers-obsolete-manifest-removal

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

The trimmable manifest generator replaced ManifestDocument.Merge(), but the old implementation and its attribute converters were still compiled. Remove them, their build inputs, and tests that only exercised the old generator.

Also stop manifest-attribute-codegen from emitting the old mapping blocks and regenerate the attributes. Keep supported public attributes, public task inputs, and the XML/version-code operations still used by aapt2 and the manifest merger.

Overlaps #13479.

Local validation: builds passed; 9 manifest tests passed

These commands passed using the worktree's pinned .NET SDK:

.\bin\Debug\dotnet\dotnet.exe build build-tools\manifest-attribute-codegen\manifest-attribute-codegen.csproj -v minimal -nr:false
.\bin\Debug\dotnet\dotnet.exe build src\Mono.Android\Mono.Android.csproj -v minimal -nr:false -p:AndroidSdkDirectory=D:\android-toolchain\sdk -p:JavaSdkDirectory=D:\android-toolchain\jdk-21 -p:AndroidNdkDirectory=D:\android-toolchain\ndk
.\bin\Debug\dotnet\dotnet.exe build src\Xamarin.Android.Build.Tasks\Tests\Xamarin.Android.Build.Tests\Xamarin.Android.Build.Tests.csproj -v minimal -nr:false -p:AndroidSdkDirectory=D:\android-toolchain\sdk -p:JavaSdkDirectory=D:\android-toolchain\jdk-21 -p:AndroidNdkDirectory=D:\android-toolchain\ndk
.\bin\Debug\dotnet\dotnet.exe test src\Microsoft.Android.Build.Tasks\Tests\Microsoft.Android.Build.Tasks.Tests\Microsoft.Android.Build.Tasks.Tests.csproj -v minimal -nr:false --filter FullyQualifiedName~TrimmableTypeMapManifestAliasTests -p:AndroidSdkDirectory=D:\android-toolchain\sdk -p:JavaSdkDirectory=D:\android-toolchain\jdk-21 -p:AndroidNdkDirectory=D:\android-toolchain\ndk

Regeneration was repeatable. All 18 generated attribute files match the original public source after excluding the 17 deleted mapping blocks. No app or device tests were run; this removes unused code.

The trimmable manifest generator replaced ManifestDocument.Merge().
Remove the unused implementation, attribute converters, mapping-generation
code, build inputs, and tests that only exercised the old generator.

Keep live XML and version-code operations, supported public attributes,
the public version resolver contract, and existing task inputs.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 15:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The review records no active issues for the legacy manifest-generator removal.

No open issues 🎉

1 file not reviewed
  • src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Generated file
What changed in this PR

Removes the legacy manifest generator now superseded by Microsoft.Android.Sdk.TrimmableTypeMap, reducing obsolete code and build dependencies in Xamarin.Android.Build.Tasks while retaining supported public attributes and manifest post-processing.

Changes:

  • Removes ManifestDocument.Merge(), legacy attribute converters, associated diagnostics, and tests specific to the old generator.
  • Stops generating legacy mapping blocks and updates generated attributes, metadata, and documentation.
  • Removes obsolete compilation inputs and adapts aapt2 and manifest-merger callers to the simplified ManifestDocument constructor.
File Description
src/​Xamarin.Android.NamingCustomAttributes/​Android.Content/​ContentProviderAttribute.cs Removes legacy provider mapping; preserves public properties.
src/​Xamarin.Android.NamingCustomAttributes/​Android.Content/​BroadcastReceiverAttribute.cs Removes legacy receiver mapping.
src/​Xamarin.Android.NamingCustomAttributes/​Android.App/​ServiceAttribute.cs Removes legacy service mapping.
src/​Xamarin.Android.NamingCustomAttributes/​Android.App/​LayoutAttribute.cs Removes legacy layout mapping.
src/​Xamarin.Android.NamingCustomAttributes/​Android.App/​InstrumentationAttribute.cs Removes legacy instrumentation mapping.
src/​Xamarin.Android.NamingCustomAttributes/​Android.App/​ApplicationAttribute.cs Removes legacy application mapping.
src/​Xamarin.Android.NamingCustomAttributes/​Android.App/​ActivityAttribute.cs Removes legacy activity mapping.
src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Build.Tasks.targets Removes the obsolete enum-generation target.
src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Build.Tasks.csproj Removes legacy attribute inputs, generated enums, and Mono.Android build dependency.
src/​Xamarin.Android.Build.Tasks/​Utilities/​ManifestDocumentElement.cs Deletes legacy attribute-to-XML conversion infrastructure.
src/​Xamarin.Android.Build.Tasks/​Utilities/​ManifestDocument.cs Removes legacy generation while retaining XML and version-code operations.
src/​Xamarin.Android.Build.Tasks/​Utilities/​InvalidActivityNameException.cs Deletes the legacy generator’s exception type.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​ResolveSdksTaskTests.cs Removes assertions for the deleted manifest version resolver.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​ManifestTest.cs Removes legacy converter tests, fixtures, and resolver setup.
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​ManifestDocumentTest.cs Deletes tests of the removed merge implementation.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ManifestMerger.cs Uses the simplified manifest constructor.
src/​Xamarin.Android.Build.Tasks/​Tasks/​Aapt2Link.cs Uses the simplified manifest constructor.
src/​Xamarin.Android.Build.Tasks/​Properties/​Resources.resx Removes obsolete XA4213 and XA4228 messages.
src/​Xamarin.Android.Build.Tasks/​Properties/​Resources.Designer.cs Removes accessors for the deleted messages.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​UsesPermissionAttribute.Partial.cs Deletes the legacy permission-use converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​UsesLibraryAttribute.Partial.cs Deletes the legacy library-use converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​UsesFeatureAttribute.Partial.cs Deletes the legacy feature converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​UsesConfigurationAttribute.Partial.cs Deletes the legacy configuration converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​SupportsGLTextureAttribute.Partial.cs Deletes the legacy texture-support converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​ServiceAttribute.Partial.cs Deletes the legacy service converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​PropertyAttribute.Partial.cs Deletes the legacy property converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​PermissionTreeAttribute.Partial.cs Deletes the legacy permission-tree converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​PermissionGroupAttribute.Partial.cs Deletes the legacy permission-group converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​PermissionAttribute.Partial.cs Deletes the legacy permission converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​MetaDataAttribute.Partial.cs Deletes the legacy metadata converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​LayoutAttribute.Partial.cs Deletes the legacy layout converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​IntentFilterAttribute.Partial.cs Deletes the legacy intent-filter converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​InstrumentationAttribute.Partial.cs Deletes the legacy instrumentation converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​GrantUriPermissionAttribute.Partial.cs Deletes the legacy URI-permission converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​ContentProviderAttribute.Partial.cs Deletes the legacy provider converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​BroadcastReceiverAttribute.Partial.cs Deletes the legacy receiver converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​ApplicationAttribute.Partial.cs Deletes the legacy application converter.
src/​Xamarin.Android.Build.Tasks/​Mono.Android/​ActivityAttribute.Partial.cs Deletes the legacy activity converter.
src/​Mono.Android/​Android.Content/​GrantUriPermissionAttribute.cs Removes legacy URI-permission mapping.
src/​Mono.Android/​Android.App/​UsesPermissionAttribute.cs Removes legacy permission-use mapping.
src/​Mono.Android/​Android.App/​UsesLibraryAttribute.cs Removes legacy library-use mapping.
src/​Mono.Android/​Android.App/​UsesFeatureAttribute.cs Removes legacy feature mapping.
src/​Mono.Android/​Android.App/​UsesConfigurationAttribute.cs Removes legacy configuration mapping.
src/​Mono.Android/​Android.App/​PropertyAttribute.cs Removes legacy property mapping.
src/​Mono.Android/​Android.App/​PermissionTreeAttribute.cs Removes legacy permission-tree mapping.
src/​Mono.Android/​Android.App/​PermissionGroupAttribute.cs Removes legacy permission-group mapping.
src/​Mono.Android/​Android.App/​PermissionAttribute.cs Removes legacy permission mapping.
src/​Mono.Android/​Android.App/​MetaDataAttribute.cs Removes legacy metadata mapping.
build-tools/​manifest-attribute-codegen/​SourceWriters/​AttributeMappingStaticConstructor.cs Deletes mapping-constructor generation.
build-tools/​manifest-attribute-codegen/​SourceWriters/​AttributeMappingManualInitializer.cs Deletes manual-mapping hook generation.
build-tools/​manifest-attribute-codegen/​SourceWriters/​AttributeMappingField.cs Deletes mapping-field generation.
build-tools/​manifest-attribute-codegen/​SourceWriters/​AttributeDataClass.cs Stops emitting conditional mapping blocks.
build-tools/​manifest-attribute-codegen/​README.md Documents the separated generators and removes obsolete options.
build-tools/​manifest-attribute-codegen/​Models/​MetadataSource.cs Removes mapping-only metadata properties and parsing.
build-tools/​manifest-attribute-codegen/​metadata.xml Removes obsolete mapping directives.
build-tools/​manifest-attribute-codegen/​manifest-attribute-codegen.csproj Removes unused generation properties.

Review effort: Balanced

@jonathanpeppers

Copy link
Copy Markdown
Member Author

/review

@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #13525

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ LGTM

0 errors · 0 warnings · 1 non-blocking suggestion.

Reviewed all 56 changed files, the removed implementations, and the remaining manifest callers. The cleanup removes the unused Cecil generation path and its build inputs without changing the supported public attribute declarations. The XML serialization, placeholder handling, duplicate/node removal, and version-code operations still used by Aapt2Link and ManifestMerger remain intact. Removing mapping emission from the generator as well as the generated files keeps regeneration consistent.

CI: All 41 GitHub checks report success for head 343bbf53, including the aggregate Azure DevOps dotnet-android check for build 1677795. Direct Azure build/timeline verification was unavailable because az devops invoke required authentication; no Azure failure investigation was performed. No local builds or tests were run for this review.

The inline suggestion covers one remaining unused resolver interface; no functional regressions were identified.

Generated by Android PR Reviewer for #13525 · copilot · gpt61 · 77.8 AIC · ⌖ 7.8 AIC · ⊞ 19.5K
Comment /review to run again

The obsolete manifest generator was its only consumer, and there are no external callers.

Co-authored-by: Copilot App <[email protected]>
@jonathanpeppers
jonathanpeppers enabled stacked auto-merge (squash) November 12, 2026 19:16
@jonathanpeppers
jonathanpeppers disabled stacked auto-merge November 12, 2026 21:47
@simonrozsival
simonrozsival merged commit f15fa66 into main Nov 13, 2026
40 checks passed
@simonrozsival
simonrozsival deleted the jonathanpeppers-obsolete-manifest-removal branch November 13, 2026 09:54
simonrozsival added a commit that referenced this pull request Nov 13, 2026
…id.Build.Tasks

Context: #12981
Context: #13476
Context: #13525

`Aapt2Daemon` keeps a persistent `aapt2 daemon` process per worker and never reads its stdout. Fixing that with the .NET 11 `Process` APIs (`File.OpenNullHandle()`, `ProcessStartInfo.StandardOutputHandle`, and friends) is not possible while the code lives in Xamarin.Android.Build.Tasks, which targets netstandard2.0. Microsoft.Android.Build.Tasks targets net12.0.

Move `<Aapt2Compile/>`, `<Aapt2Link/>`, `<Aapt2LinkAssetPack/>`, their `Aapt2` base class, `Aapt2Daemon`, and `OutputLine` into Microsoft.Android.Build.Tasks and the `Microsoft.Android.Tasks` namespace, as #13476 did for `<CheckForInvalidResourceFileNames/>`:

  * Register the tasks with the existing Full/Core `<UsingTask/>` pair. .NET MSBuild loads them in-proc and full MSBuild uses `TaskHostFactory`. The unqualified task invocations in the `.targets` files are unchanged.
  * The previous commit scoped each `Aapt2Daemon` to a single task, so nothing depends on sharing a daemon across task-host processes.
  * Move the helpers that both assemblies need (`ItemGroupToCaseMap()`, `FixUpAndroidResourcePath()`, `TryParseApiLevel()`, `GetSupportedVersions()`, `LogInternalExceptions`, and `Aapt2.IsInvalidFilename()`, now `MonoAndroidHelper.IsInvalidFilename()`) from `MonoAndroidHelper.cs` and `MonoAndroidHelper.Nullable.cs` into a new shared `MonoAndroidHelper.Tasks.cs`. `<CollectNonEmptyDirectories/>` and `<AndroidComputeResPaths/>` still use `IsInvalidFilename()`.
  * `<ManifestMerger/>` still uses `ManifestDocument` and `AndroidResource`, so link them into Microsoft.Android.Build.Tasks instead of moving them. #13525 removed `ManifestDocument`'s Mono.Cecil dependencies, which is what makes this possible. `ManifestDocument` uses `XABuildConfig`, so Microsoft.Android.Build.Tasks now references `AndroidBuildConfig.csproj`, and the installer ships `tools/net/AndroidBuildConfig.dll`.
  * Microsoft.Android.Build.Tasks treats CA1305 and nullable warnings as errors. Pass `CultureInfo.InvariantCulture` for numbers, paths, and other machine-readable strings, and `CultureInfo.CurrentCulture` for localized `Resources` messages. Handle the `string?`/`XElement?` values that net12.0 annotates without using `!`.

Tests:

  * Move `Aapt2Tests` into Microsoft.Android.Build.Tasks.Tests. A small `AndroidSdkTestHelper` finds `aapt2` and `android.jar` the same way `NativeToolTestHelper` finds the NDK: `$TEST_ANDROID_SDK_PATH`, `$ANDROID_SDK_ROOT`, `~/android-toolchain/sdk`, then the build-time `$(AndroidSdkDirectory)`.
  * `CollectNonEmptyDirectoriesTest` covers a Xamarin.Android.Build.Tasks task, so it stays behind in a new `CollectNonEmptyDirectoriesTests.cs`.
  * `ManagedResourceParserTests.CompareAapt2AndManagedParserOutput` compares Xamarin.Android.Build.Tasks' `<GenerateResourceDesigner/>` with aapt2's `R.txt`, and the net11.0 test assembly cannot reference net12.0 Microsoft.Android.Build.Tasks. It now runs `aapt2 compile`/`aapt2 link` directly with the arguments the tasks pass.

Co-authored-by: Copilot App <[email protected]>
jonathanpeppers added a commit that referenced this pull request Nov 13, 2026
…for `-mt` (#13537)

Stacked on #13525. This layer contains no manifest deletion or generator behavior fix.

`AssemblyModifierPipeline` still wrote the process-wide Java naming policy after its naming consumers were removed. Delete that write and unused task input. Pass policy explicitly in the binding generator, retaining its existing `LowercaseCrc64` behavior, and ban the implicit-policy APIs in both build projects.

Keep existing public naming overloads for runtime and external tooling callers. Add one focused test showing explicit policy calls ignore changes to global state. Task MT remains disabled.

Co-authored-by: Copilot App <[email protected]>
jonathanpeppers added a commit that referenced this pull request Nov 17, 2026
…13515)

Context: #12981
Context: https://devblogs.microsoft.com/dotnet/process-api-improvements-in-dotnet-11/
Context: #13476
Context: #13525

`Aapt2Daemon` keeps an `aapt2 daemon` process per worker, redirects its stdout, and never reads it. The .NET 11 `Process` APIs fix this, but Xamarin.Android.Build.Tasks targets netstandard2.0. This PR moves the AAPT2 tasks to Microsoft.Android.Build.Tasks (net12.0) and uses the new APIs.

### Move the AAPT2 tasks to Microsoft.Android.Build.Tasks

Same approach as #13476. The tasks, `Aapt2Daemon`, and `OutputLine` move to `Microsoft.Android.Tasks` with the Full/Core `<UsingTask/>` pair.

  * Helpers that both assemblies use move to `MonoAndroidHelper.Tasks.cs`.
  * `ManifestDocument` and `AndroidResource` are linked, not moved, because `<ManifestMerger/>` still uses them. `ManifestDocument` reads `XABuildConfig`, so the installer ships `tools/net/AndroidBuildConfig.dll` next to the .NET task assembly.
  * The moved code passes explicit cultures (CA1305) and fixes the net12.0 nullable errors.
  * `Aapt2Tests` moves to Microsoft.Android.Build.Tasks.Tests. `CompareAapt2AndManagedParserOutput` runs `aapt2` directly, because the net11.0 test assembly cannot reference net12.0 Microsoft.Android.Build.Tasks.

### Keep one daemon pool for the build

The AAPT2 tasks still share one daemon pool for the whole build through `RegisterTaskObject()`. Under full MSBuild, all AAPT2 tasks in a build run in the same .NET task host, so the pool is shared there too. For HelloWorld, this starts 5 `aapt2 daemon` processes instead of 9 with a pool per task.

  * A cancelled task returns `false` right away. Its running job finishes on the shared worker.
  * When MSBuild disposes the pool at the end of the build, it kills an aapt2 that does not respond, and fails pending jobs.

### Use the .NET 11 Process APIs

  * stdout goes to `File.OpenNullHandle()` instead of an undrained pipe.
  * `StandardInputEncoding` is UTF-8 without a BOM. This replaces the reflection lookup and the `Console.InputEncoding` swap under a lock.
  * `InheritedHandles = []` stops daemons from inheriting each other's pipes.
  * `KillOnParentExit` is set on Windows and Linux.
  * The daemon is killed if it has not exited 5 s after `quit`.

Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Jonathan Peppers <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants