A command line tool for ensuring ConfigureAwait()
is specified for all await
calls in a solution. Ideal for running in a CI pipeline.
- Run on existing codebases - existing
await
s withoutConfigureAwait()
will get a free pass on the first run of the tool. Only new/modified code on subsequent runs will flag an error, allowing you to add this to your pipeline now and fix existing code later - Supports
dynamic
- Enforces that whenawait
is called on somethingdynamic
,ConfigureAwait()
must still be present - Quickly fix invalid
await
s - Prints the project name, file name, line number and code for each invalidawait
- Integrates with CI pipelines - Uses a non-zero exit code when new invalid
await
is found, allowing you to fail the build
> Slicedbread.ConfigureAwaitEnforcer.exe MySolution.sln
Parsing command line args
Loading solution MySolution.sln
Analysing:
MyProject - 91 documents
AnotherProject - 53 documents
Found 3 new await call(s) without ConfigureAwait
MyProject - SomeFile.cs
54: await DoSomethingAsync();
70: var a = DoSomethingElseAsync();
MyProject - AnotherFile.cs
12: await DoSomethingAsync();
> Slicedbread.ConfigureAwaitEnforcer.exe MySolution.sln -strict
All await
calls without ConfigureAwait()
will cause a failure and be written to the console, regardless of whether they were present in the codebase on the first run.
Useful if you wish to find all existing invalid await
s in your codebase locally.
> Slicedbread.ConfigureAwaitEnforcer.exe MySolution.sln /excludeFiles "tests" /excludeFiles "fixture"
Ignores any file with a name containing the string passed to /excludeFiles
.
You can specify this multiple times.
This tool uses The .NET Compiler Platform (a.k.a. Roslyn).
Most of the repository is boilerplate for writing to the console etc. The interesting code, for parsing a document to find await
s without ConfigureAwait()
, is in DocumentAnalyser.cs
The tests for this code (useful for checking what syntax the tool does/does not support) are here