Skip to content

[Xamarin.Android.Build.Tasks] Enable multithreaded cache reads - #13284

Merged
jonathanpeppers merged 1 commit into
mainfrom
jonathanpeppers-imported-libraries-cache-mt
Oct 27, 2026
Merged

jonathanpeppers merged 1 commit into
mainfrom
jonathanpeppers-imported-libraries-cache-mt

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Allow <ReadImportedLibrariesCache/> to run in the MSBuild process with -mt, instead of using a separate task host. Use the existing MultithreadedAndroidTask base, declare [MSBuildMultiThreadableTask] directly, and resolve CacheFile through TaskEnvironment before file access.

Keep the existing missing-cache behavior, output item paths, metadata, duplicate order, and XML errors. Add four focused test cases: missing cache, empty cache, and ordinary/strict multithreaded builds of two projects with the same relative cache filename. The build tests also check project-relative FullPath values and malformed XML. Register test folders for automatic cleanup and failure log attachments.

Validation uses an isolated .NET SDK 11.0.100-rc.2.26504.105, MSBuild 18.12, and .NET 11 runtime/reference/ILLink/MonoTargets pins. Temporary build settings are not included in this PR.

  • dotnet-local.cmd build Microsoft.Android.slnx -t:BuildDotNet -c Release --no-restore -nr:false -v:minimal — passed; zero errors.
  • dotnet-local.cmd build src\Xamarin.Android.Build.Tasks\Tests\Xamarin.Android.Build.Tests\Xamarin.Android.Build.Tests.csproj -c Release --no-restore -nr:false -v:minimal — passed after the cleanup fix; zero errors.
  • dotnet-local.cmd test bin\TestRelease\net10.0\Xamarin.Android.Build.Tests.dll --filter "FullyQualifiedName~ReadImportedLibrariesCacheTests|FullyQualifiedName~MultiThreadedMigrationTests" — five passed, zero failures or skips.

The project tests use -m:2 -mt -nr:false -warnaserror:MSB4286,MSB4287,MSB4288 for strict multithreaded execution. binlogtool inspection confirmed actual reader execution without task-host routing, correct output paths, and no strict-mode path errors. No wall-time performance claim is made.

No linked issue.


Pull Request
title and
description
should follow the
commit-messages.md workflow documentation, and in particular should include:

  • Useful description of why the change is necessary.
  • Links to issues fixed
  • Unit tests

Allow ReadImportedLibrariesCache to run in the MSBuild process with -mt instead of a separate task host.  Use MultithreadedAndroidTask and resolve CacheFile through TaskEnvironment while preserving output paths, metadata, ordering and diagnostics.

Add focused missing-cache, empty-cache and ordinary/strict multithreaded project tests.  Register test folders for cleanup and failure log attachments.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 27, 2026 14:45

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 narrow migration uses existing multithreading infrastructure, includes focused regression coverage, and has no unresolved review findings.

No open issues 🎉

What changed in this PR

Enables ReadImportedLibrariesCache to run in-process with MSBuild multithreading while preserving existing cache behavior and output semantics.

Changes:

  • Uses MultithreadedAndroidTask and declares [MSBuildMultiThreadableTask].
  • Resolves the cache filename through TaskEnvironment before file access.
  • Adds regression coverage for missing and empty caches, concurrent project builds, output paths and metadata, and malformed XML.
File Description
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​ReadImportedLibrariesCacheTests.cs Adds cache behavior and ordinary/strict multithreaded build tests.
src/​Xamarin.Android.Build.Tasks/​Tasks/​ReadImportedLibrariesCache.cs Enables multithreaded execution and project-relative cache resolution.

Review effort: Balanced

@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@jonathanpeppers
jonathanpeppers enabled auto-merge (squash) October 27, 2026 19:43

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the complete 2-file task/test change and the relevant task base, MSBuild environment/routing, production consumers and source tests. ReadImportedLibrariesCache roots cache I/O in TaskEnvironment while preserving item order, metadata and error contracts. No high-confidence blockers remain in the bounded static review.

@jonathanpeppers
jonathanpeppers merged commit e5f6c2c into main Oct 27, 2026
42 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers-imported-libraries-cache-mt branch October 27, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants