-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Add analyzer for custom IProblemDetailsWriter registration #49286
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
base: main
Are you sure you want to change the base?
Add analyzer for custom IProblemDetailsWriter registration #49286
Conversation
Thanks for your PR, @david-acker. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
@david-acker, Are you still working on this one? No pressure, just asking because it's been sitting in draft state for a while. |
I'm planning on working on this again fairly soon now that the API has finally approved. |
@captainsafia PTAL |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
@david-acker I saw you posted a question in the original issue about moving |
…Framework/AspNetCoreAnalyzers
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
Add analyzer for custom IProblemDetailsWriter registration
Adds an analyzer that checks that custom
IProblemDetailsWriter
s are registered in the correct order, relative toMvcServiceCollectionExtensions
method calls.Description
If a custom
IProblemDetailsWriter
is registered after aMvcServiceCollectionExtensions
method, theDefaultProblemDetailsWriter
will be used instead of the customIProblemDetailsWriter
.This analyzer reports a warning level diagnostic when an
IProblemDetailsWriter
is registered (usingAddTransient
,AddScoped
, orAddSingleton
) and appears after a call to aMvcServiceCollectionExtensions
method (AddControllers
,AddControllersWithViews
,AddMvc
, orAddRazorPages
).Diagnostic
Id: ASP0026
Title: Custom IProblemDetailsWriter is incorrectly configured
Message: The custom IProblemDetailsWriter must be registered before calling AddControllers, AddControllersWithViews, AddMvc, or AddRazorPages.
Severity: Warning
Code Examples:
Diagnostic Reported:
No Diagnostic Reported:
Analyzer Infrastructure Changes
StartupAnalyzer
-related infrastructure from the legacyMicrosoft.AspNetCore.Analyzers
projectFixes #48180