Skip to content

Commit 2a3e88e

Browse files
committed
API review reaction
1 parent 5579090 commit 2a3e88e

10 files changed

+139
-26
lines changed

src/Http/Http.Results/src/AcceptedAtRoute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ internal AcceptedAtRoute(string? routeName, object? routeValues)
5050
/// <param name="routeValues">The route data to use for generating the URL.</param>
5151
internal AcceptedAtRoute(
5252
string? routeName,
53-
RouteValueDictionary routeValues)
53+
RouteValueDictionary? routeValues)
5454
{
5555
RouteName = routeName;
5656
RouteValues = routeValues ?? new RouteValueDictionary();

src/Http/Http.Results/src/AcceptedAtRouteOfT.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ internal AcceptedAtRoute(string? routeName, object? routeValues, TValue? value)
5454
/// <param name="value">The value to format in the entity body.</param>
5555
internal AcceptedAtRoute(
5656
string? routeName,
57-
RouteValueDictionary routeValues,
57+
RouteValueDictionary? routeValues,
5858
TValue? value)
5959
{
6060
Value = value;

src/Http/Http.Results/src/CreatedAtRoute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ internal CreatedAtRoute(string? routeName, object? routeValues)
5050
/// <param name="routeValues">The route data to use for generating the URL.</param>
5151
internal CreatedAtRoute(
5252
string? routeName,
53-
RouteValueDictionary routeValues)
53+
RouteValueDictionary? routeValues)
5454
{
5555
RouteName = routeName;
5656
RouteValues = routeValues ?? new RouteValueDictionary();

src/Http/Http.Results/src/CreatedAtRouteOfT.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ internal CreatedAtRoute(string? routeName, object? routeValues, TValue? value)
5454
/// <param name="value">The value to format in the entity body.</param>
5555
internal CreatedAtRoute(
5656
string? routeName,
57-
RouteValueDictionary routeValues,
57+
RouteValueDictionary? routeValues,
5858
TValue? value)
5959
{
6060
Value = value;

src/Http/Http.Results/src/PublicAPI.Unshipped.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,26 @@
44
*REMOVED*static Microsoft.AspNetCore.Http.HttpResults.EmptyHttpResult.Instance.get -> Microsoft.AspNetCore.Http.HttpResults.EmptyHttpResult!
55
Microsoft.AspNetCore.Http.HttpResults.EmptyHttpResult (forwarded, contained in Microsoft.AspNetCore.Http.Abstractions)
66
Microsoft.AspNetCore.Http.HttpResults.EmptyHttpResult.ExecuteAsync(Microsoft.AspNetCore.Http.HttpContext! httpContext) -> System.Threading.Tasks.Task! (forwarded, contained in Microsoft.AspNetCore.Http.Abstractions)
7+
Microsoft.AspNetCore.Http.HttpResults.RedirectToRouteHttpResult.RouteValues.get -> Microsoft.AspNetCore.Routing.RouteValueDictionary!
78
static Microsoft.AspNetCore.Http.HttpResults.EmptyHttpResult.Instance.get -> Microsoft.AspNetCore.Http.HttpResults.EmptyHttpResult! (forwarded, contained in Microsoft.AspNetCore.Http.Abstractions)
8-
static Microsoft.AspNetCore.Http.Results.AcceptedAtRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary! routeValues, object? value = null) -> Microsoft.AspNetCore.Http.IResult!
9-
static Microsoft.AspNetCore.Http.Results.AcceptedAtRoute<TValue>(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary! routeValues, TValue? value = default(TValue?)) -> Microsoft.AspNetCore.Http.IResult!
9+
static Microsoft.AspNetCore.Http.Results.AcceptedAtRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues, object? value = null) -> Microsoft.AspNetCore.Http.IResult!
10+
static Microsoft.AspNetCore.Http.Results.AcceptedAtRoute<TValue>(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues, TValue? value = default(TValue?)) -> Microsoft.AspNetCore.Http.IResult!
1011
static Microsoft.AspNetCore.Http.Results.Created() -> Microsoft.AspNetCore.Http.IResult!
1112
*REMOVED*static Microsoft.AspNetCore.Http.Results.Created(string! uri, object? value) -> Microsoft.AspNetCore.Http.IResult!
1213
*REMOVED*static Microsoft.AspNetCore.Http.Results.Created(System.Uri! uri, object? value) -> Microsoft.AspNetCore.Http.IResult!
1314
static Microsoft.AspNetCore.Http.Results.Created(string? uri, object? value) -> Microsoft.AspNetCore.Http.IResult!
1415
static Microsoft.AspNetCore.Http.Results.Created(System.Uri? uri, object? value) -> Microsoft.AspNetCore.Http.IResult!
1516
static Microsoft.AspNetCore.Http.Results.Created<TValue>(string? uri, TValue? value) -> Microsoft.AspNetCore.Http.IResult!
1617
static Microsoft.AspNetCore.Http.Results.Created<TValue>(System.Uri? uri, TValue? value) -> Microsoft.AspNetCore.Http.IResult!
17-
static Microsoft.AspNetCore.Http.Results.CreatedAtRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary! routeValues, object? value = null) -> Microsoft.AspNetCore.Http.IResult!
18-
static Microsoft.AspNetCore.Http.Results.CreatedAtRoute<TValue>(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary! routeValues, TValue? value = default(TValue?)) -> Microsoft.AspNetCore.Http.IResult!
18+
static Microsoft.AspNetCore.Http.Results.CreatedAtRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues, object? value = null) -> Microsoft.AspNetCore.Http.IResult!
19+
static Microsoft.AspNetCore.Http.Results.CreatedAtRoute<TValue>(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues, TValue? value = default(TValue?)) -> Microsoft.AspNetCore.Http.IResult!
1920
static Microsoft.AspNetCore.Http.Results.Json(object? data, System.Text.Json.Serialization.Metadata.JsonTypeInfo! jsonTypeInfo, string? contentType = null, int? statusCode = null) -> Microsoft.AspNetCore.Http.IResult!
2021
static Microsoft.AspNetCore.Http.Results.Json(object? data, System.Type! type, System.Text.Json.Serialization.JsonSerializerContext! context, string? contentType = null, int? statusCode = null) -> Microsoft.AspNetCore.Http.IResult!
2122
static Microsoft.AspNetCore.Http.Results.Json<TValue>(TValue? data, System.Text.Json.Serialization.JsonSerializerContext! context, string? contentType = null, int? statusCode = null) -> Microsoft.AspNetCore.Http.IResult!
2223
static Microsoft.AspNetCore.Http.Results.Json<TValue>(TValue? data, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue>! jsonTypeInfo, string? contentType = null, int? statusCode = null) -> Microsoft.AspNetCore.Http.IResult!
2324
static Microsoft.AspNetCore.Http.Results.RedirectToRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues, bool permanent = false, bool preserveMethod = false, string? fragment = null) -> Microsoft.AspNetCore.Http.IResult!
24-
static Microsoft.AspNetCore.Http.TypedResults.AcceptedAtRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary! routeValues) -> Microsoft.AspNetCore.Http.HttpResults.AcceptedAtRoute!
25-
static Microsoft.AspNetCore.Http.TypedResults.AcceptedAtRoute<TValue>(TValue? value, string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary! routeValues) -> Microsoft.AspNetCore.Http.HttpResults.AcceptedAtRoute<TValue>!
25+
static Microsoft.AspNetCore.Http.TypedResults.AcceptedAtRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues) -> Microsoft.AspNetCore.Http.HttpResults.AcceptedAtRoute!
26+
static Microsoft.AspNetCore.Http.TypedResults.AcceptedAtRoute<TValue>(TValue? value, string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues) -> Microsoft.AspNetCore.Http.HttpResults.AcceptedAtRoute<TValue>!
2627
static Microsoft.AspNetCore.Http.TypedResults.Created() -> Microsoft.AspNetCore.Http.HttpResults.Created!
2728
static Microsoft.AspNetCore.Http.TypedResults.Created(string? uri) -> Microsoft.AspNetCore.Http.HttpResults.Created!
2829
static Microsoft.AspNetCore.Http.TypedResults.Created(System.Uri? uri) -> Microsoft.AspNetCore.Http.HttpResults.Created!
@@ -34,8 +35,8 @@ static Microsoft.AspNetCore.Http.TypedResults.Created<TValue>(System.Uri? uri, T
3435
*REMOVED*static Microsoft.AspNetCore.Http.TypedResults.Created(string! uri) -> Microsoft.AspNetCore.Http.HttpResults.Created!
3536
*REMOVED*static Microsoft.AspNetCore.Http.TypedResults.Created<TValue>(System.Uri! uri, TValue? value) -> Microsoft.AspNetCore.Http.HttpResults.Created<TValue>!
3637
*REMOVED*static Microsoft.AspNetCore.Http.TypedResults.Created<TValue>(string! uri, TValue? value) -> Microsoft.AspNetCore.Http.HttpResults.Created<TValue>!
37-
static Microsoft.AspNetCore.Http.TypedResults.CreatedAtRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary! routeValues) -> Microsoft.AspNetCore.Http.HttpResults.CreatedAtRoute!
38-
static Microsoft.AspNetCore.Http.TypedResults.CreatedAtRoute<TValue>(TValue? value, string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary! routeValues) -> Microsoft.AspNetCore.Http.HttpResults.CreatedAtRoute<TValue>!
38+
static Microsoft.AspNetCore.Http.TypedResults.CreatedAtRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues) -> Microsoft.AspNetCore.Http.HttpResults.CreatedAtRoute!
39+
static Microsoft.AspNetCore.Http.TypedResults.CreatedAtRoute<TValue>(TValue? value, string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues) -> Microsoft.AspNetCore.Http.HttpResults.CreatedAtRoute<TValue>!
3940
static Microsoft.AspNetCore.Http.TypedResults.Json<TValue>(TValue? data, System.Text.Json.Serialization.JsonSerializerContext! context, string? contentType = null, int? statusCode = null) -> Microsoft.AspNetCore.Http.HttpResults.JsonHttpResult<TValue>!
4041
static Microsoft.AspNetCore.Http.TypedResults.Json<TValue>(TValue? data, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue>! jsonTypeInfo, string? contentType = null, int? statusCode = null) -> Microsoft.AspNetCore.Http.HttpResults.JsonHttpResult<TValue>!
4142
static Microsoft.AspNetCore.Http.TypedResults.RedirectToRoute(string? routeName, Microsoft.AspNetCore.Routing.RouteValueDictionary? routeValues, bool permanent = false, bool preserveMethod = false, string? fragment = null) -> Microsoft.AspNetCore.Http.HttpResults.RedirectToRouteHttpResult!

src/Http/Http.Results/src/RedirectToRouteHttpResult.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ internal RedirectToRouteHttpResult(
9696
bool preserveMethod,
9797
string? fragment) : this(
9898
routeName,
99-
routeValues == null ? null : new RouteValueDictionary(routeValues),
99+
new RouteValueDictionary(routeValues),
100100
permanent,
101101
preserveMethod,
102102
fragment)
@@ -122,7 +122,7 @@ internal RedirectToRouteHttpResult(
122122
string? fragment)
123123
{
124124
RouteName = routeName;
125-
RouteValues = routeValues;
125+
RouteValues = routeValues ?? new RouteValueDictionary();
126126
PreserveMethod = preserveMethod;
127127
Permanent = permanent;
128128
Fragment = fragment;
@@ -136,7 +136,7 @@ internal RedirectToRouteHttpResult(
136136
/// <summary>
137137
/// Gets the route data to use for generating the URL.
138138
/// </summary>
139-
public RouteValueDictionary? RouteValues { get; }
139+
public RouteValueDictionary RouteValues { get; }
140140

141141
/// <summary>
142142
/// Gets the value that specifies that the redirect should be permanent if true or temporary if false.

src/Http/Http.Results/src/Results.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ public static IResult CreatedAtRoute(string? routeName = null, object? routeValu
827827
/// <param name="value">The value to be included in the HTTP response body.</param>
828828
/// <returns>The created <see cref="IResult"/> for the response.</returns>
829829
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
830-
public static IResult CreatedAtRoute(string? routeName, RouteValueDictionary routeValues, object? value = null)
830+
public static IResult CreatedAtRoute(string? routeName, RouteValueDictionary? routeValues, object? value = null)
831831
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
832832
=> CreatedAtRoute<object>(routeName, routeValues, value);
833833

@@ -850,7 +850,7 @@ public static IResult CreatedAtRoute<TValue>(string? routeName = null, object? r
850850
/// <param name="value">The value to be included in the HTTP response body.</param>
851851
/// <returns>The created <see cref="IResult"/> for the response.</returns>
852852
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
853-
public static IResult CreatedAtRoute<TValue>(string? routeName, RouteValueDictionary routeValues, TValue? value = default)
853+
public static IResult CreatedAtRoute<TValue>(string? routeName, RouteValueDictionary? routeValues, TValue? value = default)
854854
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
855855
=> value is null ? TypedResults.CreatedAtRoute(routeName, routeValues) : TypedResults.CreatedAtRoute(value, routeName, routeValues);
856856

@@ -891,7 +891,7 @@ public static IResult AcceptedAtRoute(string? routeName = null, object? routeVal
891891
/// <param name="value">The optional content value to format in the response body.</param>
892892
/// <returns>The created <see cref="IResult"/> for the response.</returns>
893893
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
894-
public static IResult AcceptedAtRoute(string? routeName, RouteValueDictionary routeValues, object? value = null)
894+
public static IResult AcceptedAtRoute(string? routeName, RouteValueDictionary? routeValues, object? value = null)
895895
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
896896
=> AcceptedAtRoute<object>(routeName, routeValues, value);
897897

@@ -914,7 +914,7 @@ public static IResult AcceptedAtRoute<TValue>(string? routeName = null, object?
914914
/// <param name="value">The optional content value to format in the response body.</param>
915915
/// <returns>The created <see cref="IResult"/> for the response.</returns>
916916
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
917-
public static IResult AcceptedAtRoute<TValue>(string? routeName, RouteValueDictionary routeValues, TValue? value = default)
917+
public static IResult AcceptedAtRoute<TValue>(string? routeName, RouteValueDictionary? routeValues, TValue? value = default)
918918
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
919919
=> value is null ? TypedResults.AcceptedAtRoute(routeName, routeValues) : TypedResults.AcceptedAtRoute(value, routeName, routeValues);
920920

src/Http/Http.Results/src/TypedResults.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ public static CreatedAtRoute CreatedAtRoute(string? routeName = null, object? ro
906906
/// <param name="routeName">The name of the route to use for generating the URL.</param>
907907
/// <param name="routeValues">The route data to use for generating the URL.</param>
908908
/// <returns>The created <see cref="HttpResults.CreatedAtRoute"/> for the response.</returns>
909-
public static CreatedAtRoute CreatedAtRoute(string? routeName, RouteValueDictionary routeValues)
909+
public static CreatedAtRoute CreatedAtRoute(string? routeName, RouteValueDictionary? routeValues)
910910
=> new(routeName, routeValues);
911911

912912
/// <summary>
@@ -931,7 +931,7 @@ public static CreatedAtRoute<TValue> CreatedAtRoute<TValue>(TValue? value, strin
931931
/// <param name="routeValues">The route data to use for generating the URL.</param>
932932
/// <param name="value">The value to be included in the HTTP response body.</param>
933933
/// <returns>The created <see cref="HttpResults.CreatedAtRoute{TValue}"/> for the response.</returns>
934-
public static CreatedAtRoute<TValue> CreatedAtRoute<TValue>(TValue? value, string? routeName, RouteValueDictionary routeValues)
934+
public static CreatedAtRoute<TValue> CreatedAtRoute<TValue>(TValue? value, string? routeName, RouteValueDictionary? routeValues)
935935
=> new(routeName, routeValues, value);
936936

937937
/// <summary>
@@ -996,7 +996,7 @@ public static AcceptedAtRoute AcceptedAtRoute(string? routeName = null, object?
996996
/// <param name="routeName">The name of the route to use for generating the URL.</param>
997997
/// <param name="routeValues">The route data to use for generating the URL.</param>
998998
/// <returns>The created <see cref="HttpResults.AcceptedAtRoute"/> for the response.</returns>
999-
public static AcceptedAtRoute AcceptedAtRoute(string? routeName, RouteValueDictionary routeValues)
999+
public static AcceptedAtRoute AcceptedAtRoute(string? routeName, RouteValueDictionary? routeValues)
10001000
=> new(routeName, routeValues);
10011001

10021002
/// <summary>
@@ -1021,7 +1021,7 @@ public static AcceptedAtRoute<TValue> AcceptedAtRoute<TValue>(TValue? value, str
10211021
/// <param name="routeValues">The route data to use for generating the URL.</param>
10221022
/// <param name="value">The value to be included in the HTTP response body.</param>
10231023
/// <returns>The created <see cref="HttpResults.AcceptedAtRoute{TValue}"/> for the response.</returns>
1024-
public static AcceptedAtRoute<TValue> AcceptedAtRoute<TValue>(TValue? value, string? routeName, RouteValueDictionary routeValues)
1024+
public static AcceptedAtRoute<TValue> AcceptedAtRoute<TValue>(TValue? value, string? routeName, RouteValueDictionary? routeValues)
10251025
=> new(routeName, routeValues, value);
10261026

10271027
/// <summary>

src/Http/Http.Results/test/ResultsTests.cs

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,20 @@ public void AcceptedAtRoute_WithRouteNameAndRouteValueDictionaryAndValue_ResultH
112112
Assert.Equal(value, result.Value);
113113
}
114114

115+
[Fact]
116+
public void AcceptedAtRoute_WithNullRouteNameAndRouteValues_ResultHasCorrectValues()
117+
{
118+
// Arrange
119+
120+
// Act
121+
var result = Results.AcceptedAtRoute(null, null) as AcceptedAtRoute;
122+
123+
// Assert
124+
Assert.Equal(StatusCodes.Status202Accepted, result.StatusCode);
125+
Assert.Null(result.RouteName);
126+
Assert.Equal(new RouteValueDictionary(), result.RouteValues);
127+
}
128+
115129
[Fact]
116130
public void AcceptedAtRouteOfT_WithRouteNameAndRouteValuesAndValue_ResultHasCorrectValues()
117131
{
@@ -148,6 +162,20 @@ public void AcceptedAtRouteOfT_WithRouteNameAndRouteValueDictionaryAndValue_Resu
148162
Assert.Equal(value, result.Value);
149163
}
150164

165+
[Fact]
166+
public void AcceptedAtRouteOfT_WithNullRouteNameAndRouteValuesAndValue_ResultHasCorrectValues()
167+
{
168+
// Arrange
169+
170+
// Act
171+
var result = Results.AcceptedAtRoute(null, null, null) as AcceptedAtRoute;
172+
173+
// Assert
174+
Assert.Equal(StatusCodes.Status202Accepted, result.StatusCode);
175+
Assert.Null(result.RouteName);
176+
Assert.Equal(new RouteValueDictionary(), result.RouteValues);
177+
}
178+
151179
[Fact]
152180
public void AcceptedAtRoute_WithRouteNameAndRouteValues_ResultHasCorrectValues()
153181
{
@@ -696,6 +724,20 @@ public void CreatedAtRoute_WithRouteNameAndRouteValueDictionaryAndValue_ResultHa
696724
Assert.Equal(value, result.Value);
697725
}
698726

727+
[Fact]
728+
public void CreatedAtRoute_WithNullRouteNameAndRouteValues_ResultHasCorrectValues()
729+
{
730+
// Arrange
731+
732+
// Act
733+
var result = Results.CreatedAtRoute(null, null) as CreatedAtRoute;
734+
735+
// Assert
736+
Assert.Equal(StatusCodes.Status201Created, result.StatusCode);
737+
Assert.Null(result.RouteName);
738+
Assert.Equal(new RouteValueDictionary(), result.RouteValues);
739+
}
740+
699741
[Fact]
700742
public void CreatedAtRouteOfT_WithRouteNameAndRouteValuesAndValue_ResultHasCorrectValues()
701743
{
@@ -766,6 +808,20 @@ public void CreatedAtRouteOfT_WithRouteNameAndValue_ResultHasCorrectValues()
766808
Assert.Equal(value, result.Value);
767809
}
768810

811+
[Fact]
812+
public void CreatedAtRouteOfT_WithNullRouteNameAndRouteValues_ResultHasCorrectValues()
813+
{
814+
// Arrange
815+
816+
// Act
817+
var result = Results.CreatedAtRoute(null, null, null) as CreatedAtRoute;
818+
819+
// Assert
820+
Assert.Equal(StatusCodes.Status201Created, result.StatusCode);
821+
Assert.Null(result.RouteName);
822+
Assert.Equal(new RouteValueDictionary(), result.RouteValues);
823+
}
824+
769825
[Fact]
770826
public void CreatedAtRoute_WithRouteName_ResultHasCorrectValues()
771827
{
@@ -1359,7 +1415,7 @@ public void RedirectToRoute_WithNoArgs_ResultHasCorrectValues()
13591415

13601416
// Assert
13611417
Assert.Null(result.RouteName);
1362-
Assert.Null(result.RouteValues);
1418+
Assert.Equal(new RouteValueDictionary(), result.RouteValues);
13631419
}
13641420

13651421
[Fact]
@@ -1370,7 +1426,7 @@ public void RedirectToRoute_WithNoArgs_RouteValueDictionary_ResultHasCorrectValu
13701426

13711427
// Assert
13721428
Assert.Null(result.RouteName);
1373-
Assert.Null(result.RouteValues);
1429+
Assert.Equal(new RouteValueDictionary(), result.RouteValues);
13741430
}
13751431

13761432
[Fact]

0 commit comments

Comments
 (0)