From 36c17010f6f4045eeace2bdc0716098568bb4e17 Mon Sep 17 00:00:00 2001 From: Giovanni Braconi Date: Tue, 14 May 2024 21:51:43 +0200 Subject: [PATCH] Fix analyzer errors - Add DefaultProblemDetailsFactory.cs constructor and methods to PublicAPI.Unshipped.txt - Remove duplicated xml comments from methods --- .../DefaultProblemDetailsFactory.cs | 31 +++++-------------- src/Mvc/Mvc.Core/src/PublicAPI.Unshipped.txt | 4 +++ 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/Mvc/Mvc.Core/src/Infrastructure/DefaultProblemDetailsFactory.cs b/src/Mvc/Mvc.Core/src/Infrastructure/DefaultProblemDetailsFactory.cs index e32f9eb3d428..cf4e9fc1843b 100644 --- a/src/Mvc/Mvc.Core/src/Infrastructure/DefaultProblemDetailsFactory.cs +++ b/src/Mvc/Mvc.Core/src/Infrastructure/DefaultProblemDetailsFactory.cs @@ -9,6 +9,7 @@ using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Mvc.Infrastructure; + /// /// The `DefaultProblemDetailsFactory` is a concrete implementation of the `ProblemDetailsFactory` abstract class. /// It provides methods to create instances of `ProblemDetails` and `ValidationProblemDetails` with default settings. @@ -18,6 +19,7 @@ public sealed class DefaultProblemDetailsFactory : ProblemDetailsFactory { private readonly ApiBehaviorOptions _options; private readonly Action? _configure; + /// /// Initializes a new instance of the class. /// @@ -30,16 +32,9 @@ public sealed class DefaultProblemDetailsFactory : ProblemDetailsFactory _options = options?.Value ?? throw new ArgumentNullException(nameof(options)); _configure = problemDetailsOptions?.Value?.CustomizeProblemDetails; } - /// - /// Creates a new instance of the class with the specified parameters. - /// - /// The HTTP context. - /// The status code. - /// The title. - /// The type. - /// The detail. - /// The instance. - /// A new instance of the class. + + + /// public override ProblemDetails CreateProblemDetails( HttpContext httpContext, int? statusCode = null, @@ -63,18 +58,8 @@ public sealed class DefaultProblemDetailsFactory : ProblemDetailsFactory return problemDetails; } - /// - /// Creates a new instance of the class with the specified parameters. - /// This method uses the provided ModelStateDictionary to initialize the ValidationProblemDetails instance. - /// - /// The HTTP context. - /// The ModelStateDictionary containing the validation errors. - /// The status code. Defaults to 400 if not provided. - /// The title. - /// The type. - /// The detail. - /// The instance. - /// A new instance of the class. + + /// public override ValidationProblemDetails CreateValidationProblemDetails( HttpContext httpContext, ModelStateDictionary modelStateDictionary, @@ -123,6 +108,6 @@ private void ApplyProblemDetailsDefaults(HttpContext httpContext, ProblemDetails problemDetails.Extensions["traceId"] = traceId; } - _configure?.Invoke(new() { HttpContext = httpContext!, ProblemDetails = problemDetails }); + _configure?.Invoke(new() {HttpContext = httpContext!, ProblemDetails = problemDetails}); } } diff --git a/src/Mvc/Mvc.Core/src/PublicAPI.Unshipped.txt b/src/Mvc/Mvc.Core/src/PublicAPI.Unshipped.txt index 82795268b6c5..b4560b45280f 100644 --- a/src/Mvc/Mvc.Core/src/PublicAPI.Unshipped.txt +++ b/src/Mvc/Mvc.Core/src/PublicAPI.Unshipped.txt @@ -5,3 +5,7 @@ virtual Microsoft.AspNetCore.Mvc.ControllerBase.Problem(string? detail, string? virtual Microsoft.AspNetCore.Mvc.ControllerBase.Problem(string? detail = null, string? instance = null, int? statusCode = null, string? title = null, string? type = null, System.Collections.Generic.IDictionary? extensions = null) -> Microsoft.AspNetCore.Mvc.ObjectResult! virtual Microsoft.AspNetCore.Mvc.ControllerBase.ValidationProblem(string? detail, string? instance, int? statusCode, string? title, string? type, Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary? modelStateDictionary) -> Microsoft.AspNetCore.Mvc.ActionResult! virtual Microsoft.AspNetCore.Mvc.ControllerBase.ValidationProblem(string? detail = null, string? instance = null, int? statusCode = null, string? title = null, string? type = null, Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary? modelStateDictionary = null, System.Collections.Generic.IDictionary? extensions = null) -> Microsoft.AspNetCore.Mvc.ActionResult! +Microsoft.AspNetCore.Mvc.Infrastructure.DefaultProblemDetailsFactory +Microsoft.AspNetCore.Mvc.Infrastructure.DefaultProblemDetailsFactory.DefaultProblemDetailsFactory(Microsoft.Extensions.Options.IOptions! options, Microsoft.Extensions.Options.IOptions? problemDetailsOptions = null) -> void +override Microsoft.AspNetCore.Mvc.Infrastructure.DefaultProblemDetailsFactory.CreateProblemDetails(Microsoft.AspNetCore.Http.HttpContext! httpContext, int? statusCode = null, string? title = null, string? type = null, string? detail = null, string? instance = null) -> Microsoft.AspNetCore.Mvc.ProblemDetails! +override Microsoft.AspNetCore.Mvc.Infrastructure.DefaultProblemDetailsFactory.CreateValidationProblemDetails(Microsoft.AspNetCore.Http.HttpContext! httpContext, Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary! modelStateDictionary, int? statusCode = null, string? title = null, string? type = null, string? detail = null, string? instance = null) -> Microsoft.AspNetCore.Mvc.ValidationProblemDetails!