Add analyzer for custom IProblemDetailsWriter registration#49286
Add analyzer for custom IProblemDetailsWriter registration#49286david-acker wants to merge 24 commits intodotnet:mainfrom
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 |
|
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
IProblemDetailsWriters are registered in the correct order, relative toMvcServiceCollectionExtensionsmethod calls.Description
If a custom
IProblemDetailsWriteris registered after aMvcServiceCollectionExtensionsmethod, theDefaultProblemDetailsWriterwill be used instead of the customIProblemDetailsWriter.This analyzer reports a warning level diagnostic when an
IProblemDetailsWriteris registered (usingAddTransient,AddScoped, orAddSingleton) and appears after a call to aMvcServiceCollectionExtensionsmethod (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.AnalyzersprojectFixes #48180