Set ConfigureAwait(bool) on IAsyncEnumerators in await foreach loops #6652
Labels
Area-Microsoft.CodeAnalysis.NetAnalyzers
Enhancement
False_Negative
No diagnostic is reported for a problematic case
good first issue
help wanted
The issue is up-for-grabs, and can be claimed by commenting
Milestone
Describe the problem you are trying to solve
Currently CA2007 requires ConfigureAwait(bool) to be set on all instances of awaiting a task.
It does not currently catch cases where you have awaited an IAsyncEnumerator in an await foreach loop.
If you write:
await foreach (var x in someIAsyncEnumerator) { }
I'd like to see it suggest:
await foreach (var x in someIAsyncEnumerator.ConfigureAwait(someBool)) { }
Currently: It does not recognize missing ConfigureAwait on IAsyncEnumerators
Describe suggestions on how to achieve the rule
Create a rule similar to CA2007, or modify CA2007 to correctly identify
await foreach IAsyncEnumerators
Additional context
Not having this rule lead to having deadlocks in our code, until manually fixed.
The text was updated successfully, but these errors were encountered: