tabs ↹ over ␣ ␣ ␣ spaces

by Jiří {x2} Činčura

ConfigureAwaitChecker with support for “await using” and “await foreach”

12 Mar 2021 1 mins C#, Roslyn

It’s probably bit overdue, but I finally implemented checking for ConfigureAwait(false) in my ConfigureAwaitChecker for await using and await foreach. Why now? I simply (finally) needed it. So, what’s new?

It’s pretty straightforward. If you have an object implementing IAsyncDisposable or IAsyncEnumerable<T> and using await using or await foreach you can/should use ConfigureAwait(false) in these, similarly to when using await with Task, ValueTask, …

Await using with ConfigureAwaitChecker

Await foreach with ConfigureAwaitChecker

One remaining piece missing (tracked here) is properly extracting variable out of await using when applying the code fix, because the datatype is different after adding ConfigureAwait(false) and probably the insides of the using block will not work. I originally blogged about it here. This will be in next update.

Also, with this release I’m releasing the ConfigureAwaitChecker library that the analyzer is using as a NuGet package. In case you’d like to build some awesome stuff on top of it.

Thus, update your ConfigureAwaitChecker.Analyzer or get ConfigureAwaitChecker.Lib and enjoy (or report any issues).

Related post.

Profile Picture Jiří Činčura is .NET, C# and Firebird expert. He focuses on data and business layers, language constructs, parallelism, databases and performance. For almost two decades he contributes to open-source, i.e. FirebirdClient. He works as a senior software engineer for Microsoft. Frequent speaker and blogger at www.tabsoverspaces.com.