dotnet / dotnet/aspnetcore

Add analyzer to detect async void usage

Open
#28,217 15 comments 0 reactions 0 assignees View on GitHub
analyzer area-minimal area-mvc enhancement investigate
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

There are a couple of places where async void can be used by mistake in ASP.NET applications (and minimal APIs) and we should flag this and error with an analyzer:

- [ ] Startup.Configure/ConfigureServices
- [ ] MVC Controller Action methods
- [ ] Razor Page handlers (https://stackoverflow.com/questions/67794528/cannot-access-a-disposed-object-object-name-iserviceprovider-error-in-aspnet)
- [ ] MVC filters (the non IAsync*Filters)
- [ ] SignalR Hub Methods
- [ ] Minimal APIs returning void

We should flag all of these areas with a single analyzer and add more as we see fit.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.