-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Add analyzer to suggest top level route registration #42937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
...nalyzers/test/WebApplicationBuilder/UseTopLevelRouteRegistrationInsteadOfUseEndpointsTest.cs
Show resolved
Hide resolved
src/Framework/AspNetCoreAnalyzers/src/Analyzers/DiagnosticDescriptors.cs
Outdated
Show resolved
Hide resolved
Could you add some docs for this, I didn't get what it was wanting me to do, finally I figured it out. Maybe docs like this: ASP0014
Fix by replacing Example, old: webApp.UseEndpoints(endpointRouteBuilder => {
endpointRouteBuilder.MapGrpcService<MyService>();
}); Example, new: webApp.MapGrpcService<MyService>(); Suppress via attribute: [SuppressMessage("Usage", "ASP0014:Suggest using top level route registrations")] |
@erichiller Thanks for the feedback, Eric! We can definitely add some docs for this. I'll admit I have to dust off some of the cobwebs around how we handle docs for new analyzers. I had thought that some of this was automated but turns out we'll actually have to populate some content for the new analyzers that we added in .NET 7 over at https://docs.microsoft.com/en-us/aspnet/core/diagnostics/code-analysis?view=aspnetcore-6.0. I've added #44009 to track adding these docs. |
I've seen this warning in my code and moved from endpoints to top level route. |
Hi @HarelM. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
I took a look at the app linked. I believe it might be related to the fact that you invoke |
Thanks for the tip @captainsafia! |
Hi @HarelM. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
ASP0014 analyzer: Use top level route registration.
Add analyzer ASP0014 to WAB analyzers. Suggests top level route registration instead of using UseEndpoints.
Fires in the following scenario:
Fixes #35759