ConfigureAwaitChecker
ConfigureAwaitChecker copied to clipboard
Proper rewrite for await using with variable
For example this
await using (var test = ...)
{
}
with ConfigureAwait(false)
will result in test
being ConfiguredAsyncDisposable
type.
I was just about to post this. Current version of 5.0.0 calls this example code of mine as a possibility of missing ConfigureAwait(false)
:
await using FileStream fileStream = File.Open(sentryFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
How am I expected to rewrite this bit to satisfy the warning? I've tried various ideas that came to my mind but they all resulted in error of converting System.Runtime.CompilerServices.ConfiguredAsyncDisposable
to System.IO.FileStream
(in my case).
Yeah, v5.0 was pushed few moments ago. I'm preparing the blog post.
You need to do something like this https://www.tabsoverspaces.com/233779-using-await-using-iasyncdisposable-with-configureawait.
Thanks a lot, that did the trick!
Leaving the answer for people that might stumble upon this as well:
FileStream fileStream = File.Open(sentryFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
await using (fileStream.ConfigureAwait(false)) {
// ...
}