Skip to content

[Xamarin.Android.Build.Tasks] Run define constants in-process - #13283

Merged
jonathanpeppers merged 1 commit into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-define-constants-mt
Oct 27, 2026
Merged

jonathanpeppers merged 1 commit into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-define-constants-mt

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

<GetAndroidDefineConstants/> only constructs an in-memory list, but its legacy base prevents in-process execution during MSBuild -mt builds. Use the existing multithreaded base and declare [MSBuildMultiThreadableTask] directly on the task. Constant generation is unchanged.

Add five focused cases for major/minor API levels, prior QPR constants, product-version sanitizing, and invalid input. The existing migration guard checks the attribute and base class. No linked issue.

Validation

Validation used an isolated .NET 11 SDK (11.0.100-rc.2.26504.105) and temporary .NET 11 package overrides, including an explicit runtime-pack version. These overrides are not part of this PR.

  • .\dotnet-local.cmd build Microsoft.Android.slnx -t:BuildDotNet -c Release -nr:false -v:minimal - passed; 92 warnings, no errors.
  • .\dotnet-local.cmd build src\Xamarin.Android.Build.Tasks\Tests\Xamarin.Android.Build.Tests\Xamarin.Android.Build.Tests.csproj -c Release --no-restore -p:BuildProjectReferences=false -nr:false -v:minimal - passed; no warnings or errors.
  • .\dotnet-local.cmd test bin\TestRelease\net10.0\Xamarin.Android.Build.Tests.dll --filter "FullyQualifiedName~GetAndroidDefineConstantsTests|FullyQualifiedName~MultiThreadedMigrationTests" - passed, 6/6 tests, none skipped.

Separate two-project probes passed in ordinary and strict -m:2 -mt -nr:false -warnaserror:MSB4286,MSB4287,MSB4288 builds. binlogtool confirmed two task calls without task-host routing; ordered output items and metadata matched across modes. A Release APK build also confirmed .NET 11 SDK, reference, ILLink, MonoTargets, CoreCLR, and CoreLib selections.


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 <GetAndroidDefineConstants/> to run in the MSBuild process when
multithreaded builds use -mt.  The task builds an in-memory list of
constants, so it does not need a separate task host.

Use the existing multithreaded base and declare the task attribute
directly.  Keep constant generation unchanged and add focused tests
for API levels, version sanitizing, and invalid input.

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:38

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 preserves generation logic, has focused test coverage and reported strict multithreaded validation, and has no unresolved review findings.

No open issues 🎉

What changed in this PR

This PR enables GetAndroidDefineConstants to run in-process during multithreaded MSBuild builds without changing constant generation.

Changes:

  • Switches the task to MultithreadedAndroidTask and declares [MSBuildMultiThreadableTask] directly.
  • Adds five test cases covering major/minor API levels, prior QPR constants, product-version sanitizing, and invalid input.
File Description
src/​Xamarin.Android.Build.Tasks/​Tests/​Xamarin.Android.Build.Tests/​Tasks/​GetAndroidDefineConstantsTests.cs Adds focused constant-generation and invalid-input tests.
src/​Xamarin.Android.Build.Tasks/​Tasks/​GetAndroidDefineConstants.cs Enables in-process execution through the existing multithreaded task infrastructure.

Review effort: Balanced

@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

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

@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. GetAndroidDefineConstants retains stateless execution, ordered constants, parsing and MSBuild integration. No high-confidence blockers remain in the bounded static review.

@jonathanpeppers
jonathanpeppers merged commit 565b6a0 into dotnet:main Oct 27, 2026
41 checks passed
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