Skip to content

Commit

Permalink
Fix analyzer errors
Browse files Browse the repository at this point in the history
- Add DefaultProblemDetailsFactory.cs constructor and methods to PublicAPI.Unshipped.txt

- Remove duplicated xml comments from methods
  • Loading branch information
GiovanniBraconi committed May 15, 2024
1 parent 9671a96 commit 36c1701
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.Extensions.Options;

namespace Microsoft.AspNetCore.Mvc.Infrastructure;

/// <summary>
/// The `DefaultProblemDetailsFactory` is a concrete implementation of the `ProblemDetailsFactory` abstract class.
/// It provides methods to create instances of `ProblemDetails` and `ValidationProblemDetails` with default settings.
Expand All @@ -18,6 +19,7 @@ public sealed class DefaultProblemDetailsFactory : ProblemDetailsFactory
{
private readonly ApiBehaviorOptions _options;
private readonly Action<ProblemDetailsContext>? _configure;

/// <summary>
/// Initializes a new instance of the <see cref="DefaultProblemDetailsFactory"/> class.
/// </summary>
Expand All @@ -30,16 +32,9 @@ public DefaultProblemDetailsFactory(
_options = options?.Value ?? throw new ArgumentNullException(nameof(options));
_configure = problemDetailsOptions?.Value?.CustomizeProblemDetails;
}
/// <summary>
/// Creates a new instance of the <see cref="ProblemDetails"/> class with the specified parameters.
/// </summary>
/// <param name="httpContext">The HTTP context.</param>
/// <param name="statusCode">The status code.</param>
/// <param name="title">The title.</param>
/// <param name="type">The type.</param>
/// <param name="detail">The detail.</param>
/// <param name="instance">The instance.</param>
/// <returns>A new instance of the <see cref="ProblemDetails"/> class.</returns>


/// <inheritdoc />
public override ProblemDetails CreateProblemDetails(
HttpContext httpContext,
int? statusCode = null,
Expand All @@ -63,18 +58,8 @@ public override ProblemDetails CreateProblemDetails(

return problemDetails;
}
/// <summary>
/// Creates a new instance of the <see cref="ValidationProblemDetails"/> class with the specified parameters.
/// This method uses the provided ModelStateDictionary to initialize the ValidationProblemDetails instance.
/// </summary>
/// <param name="httpContext">The HTTP context.</param>
/// <param name="modelStateDictionary">The ModelStateDictionary containing the validation errors.</param>
/// <param name="statusCode">The status code. Defaults to 400 if not provided.</param>
/// <param name="title">The title.</param>
/// <param name="type">The type.</param>
/// <param name="detail">The detail.</param>
/// <param name="instance">The instance.</param>
/// <returns>A new instance of the <see cref="ValidationProblemDetails"/> class.</returns>

/// <inheritdoc />
public override ValidationProblemDetails CreateValidationProblemDetails(
HttpContext httpContext,
ModelStateDictionary modelStateDictionary,
Expand Down Expand Up @@ -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});
}
}
4 changes: 4 additions & 0 deletions src/Mvc/Mvc.Core/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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<string!, object?>? 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<string!, object?>? extensions = null) -> Microsoft.AspNetCore.Mvc.ActionResult!
Microsoft.AspNetCore.Mvc.Infrastructure.DefaultProblemDetailsFactory
Microsoft.AspNetCore.Mvc.Infrastructure.DefaultProblemDetailsFactory.DefaultProblemDetailsFactory(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.ApiBehaviorOptions!>! options, Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Http.ProblemDetailsOptions!>? 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!

0 comments on commit 36c1701

Please sign in to comment.