Skip to content

Add analyzer to force ConfigureAwait(false) on all awaits #31132

@JamesNK

Description

@JamesNK

We don't add ConfigureAwait(false) to ASP.NET Core code because there is no sync context. Microsoft.Extensions.* code could execute in client apps. Not using ConfigureAwait(false) can create deadlocks when a user mixes sync with async, e.g. dotnet/extensions#999.

Consider introducing an analyzer to enforce ConfigureAwait(false) everywhere. A quick search of this repos source code displays many non-test awaits that don't follow best practice.

I just had some good success using https://www.nuget.org/packages/ConfigureAwaitChecker.Analyzer/

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-infrastructureIncludes: MSBuild projects/targets, build scripts, CI, Installers and shared framework

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions