-
-
Notifications
You must be signed in to change notification settings - Fork 128
Closed
Labels
Milestone
Description
Input:
ProblemDetails problemDetails = new()
{
Status = StatusCodes.Status500InternalServerError,
Title = "An unexpected error occurred. Please try again later.",
Detail = environment.IsDevelopment() ? exception.Message : null,
Instance = context.Request.Path,
};
Output:
ProblemDetails problemDetails =
new()
{
Status = StatusCodes.Status500InternalServerError,
Title = "An unexpected error occurred. Please try again later.",
Detail = environment.IsDevelopment() ? exception.Message : null,
Instance = context.Request.Path,
};
Expected behavior:
Currently, when using the new()
operator, the formatting applies differently than when using the explicit object constructor. The explicit constructor formats like this:
ProblemDetails problemDetails = new ProblemDetails
{
Status = StatusCodes.Status500InternalServerError,
Title = "An unexpected error occurred. Please try again later.",
Detail = environment.IsDevelopment() ? exception.Message : null,
Instance = context.Request.Path,
};
It would be more consistent to apply the same formatting to the new()
operator, like this:
ProblemDetails problemDetails = new()
{
Status = StatusCodes.Status500InternalServerError,
Title = "An unexpected error occurred. Please try again later.",
Detail = environment.IsDevelopment() ? exception.Message : null,
Instance = context.Request.Path,
};
The current behavior appears to contradict the formatting used for explicit object constructors.
loraderon and KennethHoff