Repository navigation
Enforce ConfigureAwait in shared Android tooling libraries - #13402
Merged
simonrozsival merged 1 commit intoNov 6, 2026
Merged
simonrozsival merged 1 commit into
simonrozsival merged 1 commit into
Conversation
Enable CA2007 as an error for AndroidSdk and BaseTasks while retaining the existing application and test baseline. Fixes dotnet#12087 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the scoped CA2007 configuration change.
No open issues 🎉
What changed in this PR
Adds build-time enforcement of explicit ConfigureAwait usage in the shared Android tooling libraries, addressing #12087 without changing runtime code.
Changes:
- Enables CA2007 as an error for BaseTasks and AndroidSdk C# and VB files, including nested directories.
- Preserves existing analyzer defaults for application, installer, and test code.
- Allows intentional context capture through explicit
ConfigureAwait(true).
| File | Description |
|---|---|
src/.editorconfig |
Adds a scoped CA2007 error rule for the two shared tooling libraries. |
Review effort: Balanced
simonrozsival
approved these changes
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Missing
ConfigureAwait(false)in reusable tooling can capture a caller's synchronization context. Enable CA2007 as an error for the AndroidSdk and BaseTasks libraries, retaining the existing suppression for application, installer, and test code. Existing library awaits already specifyConfigureAwait(false), so no runtime changes are needed. Intentional capture remains possible through explicitConfigureAwait(true).Fixes #12087
Validation:
dotnet build src/Microsoft.Android.Build.BaseTasks/Microsoft.Android.Build.BaseTasks.csproj --nologo -v:minimalanddotnet build src/Xamarin.Android.Tools.AndroidSdk/Xamarin.Android.Tools.AndroidSdk.csproj --nologo -v:minimal: passed with zero warnings/errors. Temporarily adding an unconfigured await to each library caused its build to fail with CA2007, including in AndroidSdk's nestedRunners/directory; probes were removed afterward.dotnet test tests/Microsoft.Android.Build.BaseTasks-Tests/Microsoft.Android.Build.BaseTasks-Tests.csproj -v:minimal: 154 passed, 4 skipped.dotnet test tests/Xamarin.Android.Tools.AndroidSdk-Tests/Xamarin.Android.Tools.AndroidSdk-Tests.csproj --no-build -v:minimal -p:AndroidToolsDisableMultiTargeting=false -p:DotNetTargetFrameworkVersion=11.0 --filter 'FullyQualifiedName~AdbClientTests|FullyQualifiedName~AdbDeviceTrackerTests|FullyQualifiedName~AdbRunnerTests|FullyQualifiedName~AvdManagerRunnerTests|FullyQualifiedName~EmulatorRunnerTests|FullyQualifiedName~ProcessUtilsTests|FullyQualifiedName~DownloadUtilsTests|FullyQualifiedName~CommandLineToolsResolverTests' --blame-hang --blame-hang-timeout 60s --blame-hang-dump-type none: 269 passed.Constructor_SetValuesFromPath. A non-integration rerun excluding that test passed 233 tests, skipped 1, then hit the 60-second inactivity limit inChecksumOverrideDoesNotIgnoreInvalidHost(True). These unrelated discovery/installer issues were left unchanged.