Getting CA2007 after upgrading to 6.0 version of the Roslyn Analyzers

Viewed 273

We have a .net core 3.1 project that we just upgraded the roslyn analyzers to version 6.0. After doing so the following line of code started getting a "CA2007: Consider calling ConfigureAwait on the awaited task." error:

await using var memoryStream = new MemoryStream(fileByteArray);

If we tried adding the ConfigureAwait call like so:

await using var memoryStream = new MemoryStream(fileByteArray).ConfigureAwait(false);

This then causes memoryStream to be a ConfiguredAsyncDisposable instead of an actual MemoryStream which prevents further code from even compiling.

How can we add ConfigureAwait to our await using statement to remove the warning but still keep our memoryStream an actual MemoryStream? We would prefer not to have to suppress it if possible.

1 Answers
Related