[Analyzer] Detect adding middleware services but middleware isn't used
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
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.
Developers can add the services for middleware, e.g. `AddCors`, and not realize that the middleware needs to be registered in middleware with `UseCors`. There is no error or indication to the developer about what they're missing.
### Describe the solution you'd like
An analyzer that looks at what middleware services are registered, what middleware is used in request pipeline, and warns the developer about middleware that's unused.
We can't infer what these names are so we'd hard code AddMiddleware and UseMiddleware method names.
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.