Skip to content

Make IResult constructor public #41035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions src/Http/Http.Results/src/AcceptedAtRouteHttpResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,17 @@ namespace Microsoft.AspNetCore.Http;
/// </summary>
public sealed class AcceptedAtRouteHttpResult : IResult
{
/// <summary>
/// Initializes a new instance of the <see cref="AcceptedAtRouteHttpResult"/> class with the values
/// provided.
/// </summary>
/// <param name="routeValues">The route data to use for generating the URL.</param>
/// <param name="value">The value to format in the entity body.</param>
internal AcceptedAtRouteHttpResult(object? routeValues, object? value)
: this(routeName: null, routeValues: routeValues, value: value)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="AcceptedAtRouteHttpResult"/> class with the values
/// provided.
/// </summary>
/// <param name="routeName">The name of the route to use for generating the URL.</param>
/// <param name="routeValues">The route data to use for generating the URL.</param>
/// <param name="value">The value to format in the entity body.</param>
internal AcceptedAtRouteHttpResult(
string? routeName,
object? routeValues,
object? value)
public AcceptedAtRouteHttpResult(
string? routeName = null,
object? routeValues = null,
object? value = null)
{
Value = value;
RouteName = routeName;
Expand Down
8 changes: 6 additions & 2 deletions src/Http/Http.Results/src/AcceptedHttpResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public sealed class AcceptedHttpResult : IResult
/// </summary>
/// <param name="location">The location at which the status of requested content can be monitored.</param>
/// <param name="value">The value to format in the entity body.</param>
internal AcceptedHttpResult(string? location, object? value)
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
public AcceptedHttpResult(string? location, object? value = null)
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
{
Value = value;
Location = location;
Expand All @@ -33,7 +35,9 @@ internal AcceptedHttpResult(string? location, object? value)
/// </summary>
/// <param name="locationUri">The location at which the status of requested content can be monitored.</param>
/// <param name="value">The value to format in the entity body.</param>
internal AcceptedHttpResult(Uri locationUri, object? value)
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
public AcceptedHttpResult(Uri locationUri, object? value = null)
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
{
Value = value;
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Http.Results/src/BadRequestObjectHttpResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public sealed class BadRequestObjectHttpResult : IResult
/// provided.
/// </summary>
/// <param name="error">The error content to format in the entity body.</param>
internal BadRequestObjectHttpResult(object? error)
public BadRequestObjectHttpResult(object? error = null)
{
Value = error;
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
Expand All @@ -26,7 +26,7 @@ internal BadRequestObjectHttpResult(object? error)
/// <summary>
/// Gets the object result.
/// </summary>
public object? Value { get; internal init; }
public object? Value { get; }

/// <summary>
/// Gets the HTTP status code.
Expand Down
44 changes: 9 additions & 35 deletions src/Http/Http.Results/src/ChallengeHttpResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,16 @@ namespace Microsoft.AspNetCore.Http;
/// </summary>
public sealed partial class ChallengeHttpResult : IResult
{
/// <summary>
/// Initializes a new instance of <see cref="ChallengeHttpResult"/>.
/// </summary>
internal ChallengeHttpResult()
: this(Array.Empty<string>())
{
}

/// <summary>
/// Initializes a new instance of <see cref="ChallengeHttpResult"/> with the
/// specified authentication scheme.
/// </summary>
/// <param name="authenticationScheme">The authentication scheme to challenge.</param>
internal ChallengeHttpResult(string authenticationScheme)
: this(new[] { authenticationScheme })
{
}

/// <summary>
/// Initializes a new instance of <see cref="ChallengeHttpResult"/> with the
/// specified authentication schemes.
/// </summary>
/// <param name="authenticationSchemes">The authentication schemes to challenge.</param>
internal ChallengeHttpResult(IList<string> authenticationSchemes)
: this(authenticationSchemes, properties: null)
{
}

/// <summary>
/// Initializes a new instance of <see cref="ChallengeHttpResult"/> with the
/// specified <paramref name="properties"/>.
/// </summary>
/// <param name="properties"><see cref="AuthenticationProperties"/> used to perform the authentication
/// challenge.</param>
internal ChallengeHttpResult(AuthenticationProperties? properties)
: this(Array.Empty<string>(), properties)
#pragma warning disable RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
public ChallengeHttpResult(AuthenticationProperties? properties = null)
#pragma warning restore RS0027 // Public API with optional parameter(s) should have the most parameters amongst its public overloads.
: this(properties, authenticationSchemes: Array.Empty<string>())
{
}

Expand All @@ -59,8 +33,8 @@ internal ChallengeHttpResult(AuthenticationProperties? properties)
/// <param name="authenticationScheme">The authentication schemes to challenge.</param>
/// <param name="properties"><see cref="AuthenticationProperties"/> used to perform the authentication
/// challenge.</param>
internal ChallengeHttpResult(string authenticationScheme, AuthenticationProperties? properties)
: this(new[] { authenticationScheme }, properties)
public ChallengeHttpResult(AuthenticationProperties? properties, string authenticationScheme)
: this(properties, authenticationSchemes: new[] { authenticationScheme })
{
}

Expand All @@ -71,7 +45,7 @@ internal ChallengeHttpResult(string authenticationScheme, AuthenticationProperti
/// <param name="authenticationSchemes">The authentication scheme to challenge.</param>
/// <param name="properties"><see cref="AuthenticationProperties"/> used to perform the authentication
/// challenge.</param>
internal ChallengeHttpResult(IList<string> authenticationSchemes, AuthenticationProperties? properties)
public ChallengeHttpResult(AuthenticationProperties? properties, IList<string> authenticationSchemes)
{
AuthenticationSchemes = authenticationSchemes.AsReadOnly();
Properties = properties;
Expand All @@ -80,12 +54,12 @@ internal ChallengeHttpResult(IList<string> authenticationSchemes, Authentication
/// <summary>
/// Gets the authentication schemes that are challenged.
/// </summary>
public IReadOnlyList<string> AuthenticationSchemes { get; internal init; } = Array.Empty<string>();
public IReadOnlyList<string> AuthenticationSchemes { get; }

/// <summary>
/// Gets the <see cref="AuthenticationProperties"/> used to perform the sign-out operation.
/// </summary>
public AuthenticationProperties? Properties { get; internal init; }
public AuthenticationProperties? Properties { get; }

/// <inheritdoc/>
public async Task ExecuteAsync(HttpContext httpContext)
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Http.Results/src/ConflictObjectHttpResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public sealed class ConflictObjectHttpResult : IResult
/// provided.
/// </summary>
/// <param name="error">The error content to format in the entity body.</param>
internal ConflictObjectHttpResult(object? error)
public ConflictObjectHttpResult(object? error = null)
{
Value = error;
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
Expand All @@ -26,7 +26,7 @@ internal ConflictObjectHttpResult(object? error)
/// <summary>
/// Gets the object result.
/// </summary>
public object? Value { get; internal init; }
public object? Value { get; }

/// <summary>
/// Gets the HTTP status code.
Expand Down
20 changes: 4 additions & 16 deletions src/Http/Http.Results/src/ContentHttpResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,31 @@ namespace Microsoft.AspNetCore.Http;
/// </summary>
public sealed partial class ContentHttpResult : IResult
{
/// <summary>
/// Initializes a new instance of the <see cref="ContentHttpResult"/> class with the values.
/// </summary>
/// <param name="content">The value to format in the entity body.</param>
/// <param name="contentType">The Content-Type header for the response</param>
internal ContentHttpResult(string? content, string? contentType)
: this(content, contentType, statusCode: null)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="ContentHttpResult"/> class with the values
/// </summary>
/// <param name="content">The value to format in the entity body.</param>
/// <param name="statusCode">The HTTP status code of the response.</param>
/// <param name="contentType">The Content-Type header for the response</param>
internal ContentHttpResult(string? content, string? contentType, int? statusCode)
public ContentHttpResult(string? content = null, string? contentType = null)
{
Content = content;
StatusCode = statusCode;
ContentType = contentType;
}

/// <summary>
/// Gets or set the content representing the body of the response.
/// </summary>
public string? Content { get; internal init; }
public string? Content { get; }

/// <summary>
/// Gets or sets the Content-Type header for the response.
/// </summary>
public string? ContentType { get; internal init; }
public string? ContentType { get; }

/// <summary>
/// Gets the HTTP status code.
/// </summary>
public int? StatusCode { get; internal init; }
public int? StatusCode { get; init; }

/// <summary>
/// Writes the content to the HTTP response.
Expand Down
19 changes: 4 additions & 15 deletions src/Http/Http.Results/src/CreatedAtRouteHttpResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,17 @@ namespace Microsoft.AspNetCore.Http;
/// </summary>
public sealed class CreatedAtRouteHttpResult : IResult
{
/// <summary>
/// Initializes a new instance of the <see cref="CreatedAtRouteHttpResult"/> class with the values
/// provided.
/// </summary>
/// <param name="routeValues">The route data to use for generating the URL.</param>
/// <param name="value">The value to format in the entity body.</param>
internal CreatedAtRouteHttpResult(object? routeValues, object? value)
: this(routeName: null, routeValues: routeValues, value: value)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="CreatedAtRouteHttpResult"/> class with the values
/// provided.
/// </summary>
/// <param name="routeName">The name of the route to use for generating the URL.</param>
/// <param name="routeValues">The route data to use for generating the URL.</param>
/// <param name="value">The value to format in the entity body.</param>
internal CreatedAtRouteHttpResult(
string? routeName,
object? routeValues,
object? value)
public CreatedAtRouteHttpResult(
string? routeName = null,
object? routeValues = null,
object? value = null)
{
Value = value;
RouteName = routeName;
Expand Down
12 changes: 8 additions & 4 deletions src/Http/Http.Results/src/CreatedHttpResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ public sealed class CreatedHttpResult : IResult
/// Initializes a new instance of the <see cref="CreatedHttpResult"/> class with the values
/// provided.
/// </summary>
/// <param name="location">The location at which the content has been created.</param>
/// <param name="location">The location at which the status of requested content can be monitored.</param>
/// <param name="value">The value to format in the entity body.</param>
internal CreatedHttpResult(string location, object? value)
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
public CreatedHttpResult(string? location, object? value = null)
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
{
Value = value;
Location = location;
Expand All @@ -29,9 +31,11 @@ internal CreatedHttpResult(string location, object? value)
/// Initializes a new instance of the <see cref="CreatedHttpResult"/> class with the values
/// provided.
/// </summary>
/// <param name="locationUri">The location at which the content has been created.</param>
/// <param name="locationUri">The location at which the status of requested content can be monitored.</param>
/// <param name="value">The value to format in the entity body.</param>
internal CreatedHttpResult(Uri locationUri, object? value)
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
public CreatedHttpResult(Uri locationUri, object? value = null)
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
{
Value = value;
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
Expand Down
9 changes: 0 additions & 9 deletions src/Http/Http.Results/src/EmptyHttpResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ namespace Microsoft.AspNetCore.Http;
/// </summary>
public sealed class EmptyHttpResult : IResult
{
private EmptyHttpResult()
{
}

/// <summary>
/// Gets an instance of <see cref="EmptyHttpResult"/>.
/// </summary>
public static EmptyHttpResult Instance { get; } = new();

/// <inheritdoc/>
public Task ExecuteAsync(HttpContext httpContext)
{
Expand Down
Loading