镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Enforce ConfigureAwait in shared Android tooling libraries - #13402

Merged
simonrozsival merged 1 commit into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-configureawait-analyzer
Nov 6, 2026
Merged

simonrozsival merged 1 commit into
dotnet:mainfrom
jonathanpeppers:jonathanpeppers-configureawait-analyzer

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

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 specify ConfigureAwait(false), so no runtime changes are needed. Intentional capture remains possible through explicit ConfigureAwait(true).

Fixes #12087

Validation:

  • dotnet build src/Microsoft.Android.Build.BaseTasks/Microsoft.Android.Build.BaseTasks.csproj --nologo -v:minimal and dotnet 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 nested Runners/ 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.
  • The broader AndroidSdk test command with the same framework properties built both netstandard2.0 and net11.0, but encountered a host JDK-discovery failure in Constructor_SetValuesFromPath. A non-integration rerun excluding that test passed 233 tests, skipped 1, then hit the 60-second inactivity limit in ChecksumOverrideDoesNotIgnoreInvalidHost(True). These unrelated discovery/installer issues were left unchanged.

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>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 12:49

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

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
simonrozsival merged commit 7c551d0 into dotnet:main Nov 6, 2026
40 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.

Enable ConfigureAwait(false) analyzer

3 participants