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 an independent developer, .NET, C# and Firebird expert, focusing on data and business layers, language constructs, parallelism, databases and performance. He's Microsoft Most Valuable Professional and frequent speaker. You can read his articles, guides and tips and tricks at www.tabsoverspaces.com.