You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add analyzer for custom IProblemDetailsWriter registration - #49286
Add analyzer for custom IProblemDetailsWriter registration
Adds an analyzer that checks that custom IProblemDetailsWriters are registered in the correct order, relative to MvcServiceCollectionExtensions method calls.
Description
If a custom IProblemDetailsWriter is registered after a MvcServiceCollectionExtensions method, the DefaultProblemDetailsWriter will be used instead of the custom IProblemDetailsWriter.
This analyzer reports a warning level diagnostic when an IProblemDetailsWriter is registered (using AddTransient, AddScoped, or AddSingleton) and appears after a call to a MvcServiceCollectionExtensions method (AddControllers, AddControllersWithViews, AddMvc, or AddRazorPages).
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:
services.AddControllers();// Diagnostic reported on method invocation belowservices.AddTransient<IProblemDetailsWriter,SampleProblemDetailsWriter>();
ghost
added
community-contribution
Indicates that the PR has been added by a community member
needs-area-label
Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically
labels
Jul 10, 2023
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
added
area-mvc
Includes: MVC, Actions and Controllers, Localization, CORS, most templates
old-area-web-frameworks-do-not-use
*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
and removed
needs-area-label
Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically
labels
Jul 10, 2023
@david-acker I saw you posted a question in the original issue about moving StartupAnalyzer-related infrastructure to the analyzers that get shipped in the refpack. I'm in favor of incorproating a StartupAnalyzer in that project and using source-sharing to bring in helpful dependencies like StartupFacts.
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
analyzerIndicates an issue which is related to analyzer experiencearea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etccommunity-contributionIndicates that the PR has been added by a community memberpending-ci-rerunWhen assigned to a PR indicates that the CI checks should be rerun
4 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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