Skip to content

Commit

Permalink
React to dependencies and PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK committed Jan 21, 2023
1 parent ed0cf96 commit d17dd16
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 26 deletions.
3 changes: 2 additions & 1 deletion src/Http/Http.Results/src/AcceptedAtRoute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http.Metadata;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -52,7 +53,7 @@ internal AcceptedAtRoute(
RouteValueDictionary routeValues)
{
RouteName = routeName;
RouteValues = HttpResultsHelper.EnsureValue(routeValues);
RouteValues = routeValues ?? new RouteValueDictionary();
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/Http/Http.Results/src/AcceptedAtRouteOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http.Metadata;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -58,7 +59,7 @@ internal AcceptedAtRoute(
{
Value = value;
RouteName = routeName;
RouteValues = HttpResultsHelper.EnsureValue(routeValues);
RouteValues = routeValues ?? new RouteValueDictionary();
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Http/Http.Results/src/CreatedAtRoute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http.Metadata;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -52,7 +53,7 @@ internal CreatedAtRoute(
RouteValueDictionary routeValues)
{
RouteName = routeName;
RouteValues = HttpResultsHelper.EnsureValue(routeValues);
RouteValues = routeValues ?? new RouteValueDictionary();
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/Http/Http.Results/src/CreatedAtRouteOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http.Metadata;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -58,7 +59,7 @@ internal CreatedAtRoute(
{
Value = value;
RouteName = routeName;
RouteValues = HttpResultsHelper.EnsureValue(routeValues);
RouteValues = routeValues ?? new RouteValueDictionary();
HttpResultsHelper.ApplyProblemDetailsDefaultsIfNeeded(Value, StatusCode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<Compile Include="$(SharedSourceRoot)ProblemDetails\ProblemDetailsDefaults.cs" LinkBase="Shared" />
<Compile Include="$(SharedSourceRoot)ApiExplorerTypes\*.cs" LinkBase="Shared" />
<Compile Include="$(SharedSourceRoot)RoutingMetadata\AcceptsMetadata.cs" LinkBase="Shared" />
<Compile Include="$(SharedSourceRoot)RouteValueDictionaryTrimmerWarning.cs" LinkBase="Shared" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Http.Results/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ static Microsoft.AspNetCore.Http.TypedResults.Created<TValue>(System.Uri? uri, T
*REMOVED*static Microsoft.AspNetCore.Http.TypedResults.Created(System.Uri! uri) -> Microsoft.AspNetCore.Http.HttpResults.Created!
*REMOVED*static Microsoft.AspNetCore.Http.TypedResults.Created(string! uri) -> Microsoft.AspNetCore.Http.HttpResults.Created!
*REMOVED*static Microsoft.AspNetCore.Http.TypedResults.Created<TValue>(System.Uri! uri, TValue? value) -> Microsoft.AspNetCore.Http.HttpResults.Created<TValue>!
*REMOVED*static Microsoft.AspNetCore.Http.TypedResults.Created<TValue>(string! uri, TValue? value) -> Microsoft.AspNetCore.Http.HttpResults.Created<TValue>!
*REMOVED*static Microsoft.AspNetCore.Http.TypedResults.Created<TValue>(string! uri, TValue? value) -> Microsoft.AspNetCore.Http.HttpResults.Created<TValue>!
1 change: 1 addition & 0 deletions src/Http/Http.Results/src/RedirectToRouteHttpResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand Down
4 changes: 1 addition & 3 deletions src/Http/Http.Results/src/Results.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.Net.Http.Headers;
Expand Down Expand Up @@ -674,9 +675,6 @@ public static IResult ValidationProblem(
return TypedResults.Problem(problemDetails);
}

// Remove once https://github.com/dotnet/aspnetcore/pull/45886 is done.
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]
[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "<Pending>")]
private static void CopyExtensions(IDictionary<string, object?>? extensions, HttpValidationProblemDetails problemDetails)
{
if (extensions is not null)
Expand Down
4 changes: 1 addition & 3 deletions src/Http/Http.Results/src/TypedResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.Net.Http.Headers;
Expand Down Expand Up @@ -712,9 +713,6 @@ public static ProblemHttpResult Problem(
return new(problemDetails);
}

// Remove once https://github.com/dotnet/aspnetcore/pull/45886 is done.
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]
[UnconditionalSuppressMessage("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "<Pending>")]
private static void CopyExtensions(IDictionary<string, object?>? extensions, ProblemDetails problemDetails)
{
if (extensions is not null)
Expand Down
8 changes: 4 additions & 4 deletions src/Http/Http.Results/test/ResultsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ public void Created_WithNullStringUriAndValue_SetsLocationNull()
//Arrange
object value = new { };

// Act
// Act
var result = Results.Created(default(string), value) as Created<object>;

//Assert
Expand All @@ -600,7 +600,7 @@ public void Created_WithEmptyStringUriAndValue_SetsLocationEmpty()
//Arrange
object value = new { };

// Act
// Act
var result = Results.Created(string.Empty, value) as Created<object>;

//Assert
Expand All @@ -614,7 +614,7 @@ public void Created_WithNullUriAndValue_SetsLocationNull()
//Arrange
object value = new { };

// Act
// Act
var result = Results.Created(default(Uri), value) as Created<object>;

//Assert
Expand Down Expand Up @@ -737,7 +737,7 @@ public void Json_WithAllArgs_ResultHasCorrectValues()
var options = new JsonSerializerOptions();
var contentType = "application/custom+json";
var statusCode = StatusCodes.Status208AlreadyReported;

// Act
var result = Results.Json(data, options, contentType, statusCode) as JsonHttpResult<object>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Internal;

namespace Microsoft.AspNetCore.Routing;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Internal;

namespace Microsoft.AspNetCore.Routing;

Expand Down
1 change: 1 addition & 0 deletions src/Http/Routing/src/Microsoft.AspNetCore.Routing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<Compile Include="$(SharedSourceRoot)RoutingMetadata\AcceptsMetadata.cs" LinkBase="Shared" />
<Compile Include="$(SharedSourceRoot)Json\JsonSerializerExtensions.cs" LinkBase="Shared"/>
<Compile Include="$(SharedSourceRoot)RouteHandlers\ExecuteHandlerHelper.cs" LinkBase="Shared"/>
<Compile Include="$(SharedSourceRoot)RouteValueDictionaryTrimmerWarning.cs" LinkBase="Shared" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/Http/Routing/src/Patterns/RoutePatternFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.Routing.Constraints;

namespace Microsoft.AspNetCore.Routing.Patterns;
Expand Down
10 changes: 0 additions & 10 deletions src/Http/Routing/src/RouteValueDictionaryTrimmerWarning.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.AspNetCore.Routing;
namespace Microsoft.AspNetCore.Internal;

internal static class RouteValueDictionaryTrimmerWarning
{
Expand Down

0 comments on commit d17dd16

Please sign in to comment.