dotnet/aspnetcore

[Analyzer] : Warn when registering custom IProblemDetailsWriter after calling AddRazorPages, etc

Open

#48.180 aperta il 10 mag 2023

Vedi su GitHub
 (11 commenti) (2 reazioni) (0 assegnatari)C# (10.653 fork)batch import
analyzerapi-approvedarea-mvcbughelp wanted

Metriche repository

Star
 (37.933 star)
Metriche merge PR
 (Merge medio 16g 9h) (258 PR mergiate in 30 g)

Descrizione

Background and Motivation

Registering a custom IProblemDetailsWriter after calling AddRazorPages, etc results in the DefaultProblemDetailsWriter, not the custom IProblemDetailsWriter being called.

Proposed Analyzer

Analyzer Behavior and Message

Issue a warning when Registering a custom IProblemDetailsWriter after calling AddRazorPages, etc.

ASP0001: Authorization middleware is incorrectly configured is similar.

See https://github.com/dotnet/AspNetCore.Docs/issues/29152

Note: When using a custom IProblemDetailsWriter, the custom IProblemDetailsWriter must be registered before calling AddRazorPages, AddControllers, or AddControllersWithViews.

Category

  • Design
  • Documentation
  • Globalization
  • Interoperability
  • Maintainability
  • Naming
  • Performance
  • Reliability
  • Security
  • Style
  • Usage

Severity Level

  • Error
  • Warning
  • Info
  • Hidden

Usage Scenarios

Issue a warning when Registering a custom IProblemDetailsWriter after calling AddRazorPages, etc.

Risks

None.

Guida contributor