[Analyzer] Warn about returning `IEnumerable<T>` from action or minimal API
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
> Returning `IEnumerable` from an action results in synchronous collection iteration by the serializer. The result is the blocking of calls and a potential for thread pool starvation. To avoid synchronous enumeration, use ToListAsync before returning the enumerable.
See https://learn.microsoft.com/en-us/aspnet/core/performance/performance-best-practices?view=aspnetcore-6.0#return-ienumerablet-or-iasyncenumerablet
### Describe the solution you'd like
An analyzer that warns when `IEnumerable` is returned from a controller or minimal API.
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.