dotnet / dotnet/sdk

Analyzer to catch multiple enumerations of `IAsyncEnumerable<T>` (like CA1851)

Open
#54,925 0 comments 1 reaction 0 assignees View on GitHub
Area-Microsoft.CodeAnalysis.NetAnalyzers untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Is your feature request related to a problem?

Developers may enumerate an [`IAsyncEnumerable`](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1) multiple times, which is not guaranteed to be supported by the interface contract and may work for some types/instances and not for others, creating lingering issues in the code.

### Describe the solution you'd like

To enhance analyzer [CA1851](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/CA1851) (or create a similar analyzer) to check `IAsyncEnumerable` in addition to `IEnumerable`.

### Alternatives you've considered

It could be handled by third-party analyzers like Roslynator or SonarSource.

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the CA1851 documentation and comparing its treatment of IEnumerable with the requested IAsyncEnumerable case. Done means the .NET analyzer reports multiple enumerations of IAsyncEnumerable, either by enhancing CA1851 or by adding a similar analyzer.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.