Skip to content

[TrimmableTypeMap] Preserve trimmable typemap outputs on no-op builds#11472

Open
simonrozsival wants to merge 1 commit into
mainfrom
dev/simonrozsival/trimmable-typemap-incremental-clean
Open

[TrimmableTypeMap] Preserve trimmable typemap outputs on no-op builds#11472
simonrozsival wants to merge 1 commit into
mainfrom
dev/simonrozsival/trimmable-typemap-incremental-clean

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

@simonrozsival simonrozsival commented May 24, 2026

Summary

  • replay generated trimmable typemap assemblies and Java outputs into FileWrites before IncrementalClean
  • keep generated typemap DLL metadata stable for packaging/native config consumers
  • extend the trimmable typemap incremental test to assert generated DLLs survive a no-op rebuild

Related to #10958.

Relevant sub-issues:

Validation

  • ./dotnet-local.sh build src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj -c Debug -v:minimal -nr:false
  • MSBUILDDISABLENODEREUSE=1 ./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter "Name~Build_WithTrimmableTypeMap_IncrementalBuild" -v:minimal (skipped locally because commercial build targets are unavailable)

Generated trimmable typemap outputs are dynamic, so no-op builds can skip the targets that normally add them to FileWrites. Replay the prior generated outputs before IncrementalClean so they are not treated as orphaned and removed before packaging evaluates its inputs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival changed the title Preserve trimmable typemap outputs on no-op builds [TrimmableTypeMap] Preserve trimmable typemap outputs on no-op builds May 24, 2026
@simonrozsival simonrozsival added copilot `copilot-cli` or other AIs were used to author this trimmable-type-map labels May 24, 2026
@simonrozsival simonrozsival marked this pull request as ready for review May 25, 2026 08:32
Copilot AI review requested due to automatic review settings May 25, 2026 08:32
@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label May 25, 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

This PR addresses a trimmable typemap incremental-build issue where MSBuild’s IncrementalClean could delete previously generated typemap DLLs / Java outputs on no-op builds (because skipped targets don’t re-populate @(FileWrites)). It replays the prior dynamic outputs into @(FileWrites) early in the build and strengthens the incremental test to ensure the generated typemap assemblies survive a no-op rebuild.

Changes:

  • Add a _RecordTrimmableTypeMapFileWrites target that re-emits typemap-generated DLL/Java outputs into @(FileWrites) before _CleanGetCurrentAndPriorFileWrites runs.
  • Refactor typemap assembly item construction via a dedicated @(_TrimmableTypeMapResolvedAssemblies) item list and then feed it into both @(_ResolvedAssemblies) and @(_ShrunkAssemblies).
  • Extend Build_WithTrimmableTypeMap_IncrementalBuild to assert typemap DLLs from the first build still exist after a no-op second build.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/TrimmableTypeMapBuildTests.cs Adds an assertion that typemap DLL outputs persist across a no-op rebuild where _GenerateJavaStubs is skipped.
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets Replays prior dynamic typemap outputs into @(FileWrites) before IncrementalClean and slightly restructures typemap DLL item population for packaging/native config.

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 ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). trimmable-type-map

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants