Skip to content

Commit 9e97941

Browse files
committed
Moving to Routing
1 parent df207a0 commit 9e97941

9 files changed

+34
-39
lines changed
Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using Microsoft.AspNetCore.Http;
54
using Microsoft.AspNetCore.Http.Json;
6-
using Microsoft.AspNetCore.Internal;
7-
using Microsoft.Extensions.DependencyInjection.Extensions;
8-
using Microsoft.Extensions.Options;
95

106
namespace Microsoft.Extensions.DependencyInjection;
117

@@ -29,23 +25,4 @@ public static IServiceCollection ConfigureHttpJsonOptions(this IServiceCollectio
2925
services.Configure<JsonOptions>(configureOptions);
3026
return services;
3127
}
32-
33-
/// <summary>
34-
///
35-
/// </summary>
36-
/// <param name="services"></param>
37-
/// <returns></returns>
38-
public static IServiceCollection ConfigureDefaultHttpJsonOptions(this IServiceCollection services)
39-
{
40-
if (!TrimmingAppContextSwitches.EnsureJsonTrimmability)
41-
{
42-
#pragma warning disable IL2026 // Suppressed in Microsoft.AspNetCore.Http.Extensions.WarningSuppressions.xml
43-
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
44-
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<JsonOptions>, DefaultHttpJsonOptionsSetup>());
45-
#pragma warning restore IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
46-
#pragma warning restore IL2026 // Suppressed in Microsoft.AspNetCore.Http.Extensions.WarningSuppressions.xml
47-
}
48-
49-
return services;
50-
}
5128
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<linker>
33
<assembly fullname="Microsoft.AspNetCore.Http.Extensions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
44
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
55
<argument>ILLink</argument>
66
<argument>IL2026</argument>
77
<property name="Scope">member</property>
88
<property name="Target">M:Microsoft.Extensions.DependencyInjection.HttpJsonServiceExtensions.ConfigureDefaultHttpJsonOptions(Microsoft.Extensions.DependencyInjection.IServiceCollection)</property>
9-
<property name="Justification">This warning is left in the product so developers get an ILLink warning when trimming an app only when Microsoft.AspNetCore.EnsureJsonTrimmability=false.</property>
109
</attribute>
1110
</assembly>
12-
</linker>
11+
</linker>

src/Http/Http.Extensions/src/Microsoft.AspNetCore.Http.Extensions.csproj

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@
2323
<Compile Include="$(SharedSourceRoot)ProblemDetails\ProblemDetailsDefaults.cs" LinkBase="Shared" />
2424
<Compile Include="$(SharedSourceRoot)ValueStringBuilder\**\*.cs" LinkBase="Shared" />
2525
<Compile Include="$(SharedSourceRoot)Json\JsonSerializerExtensions.cs" LinkBase="Shared" />
26-
<Compile Include="$(SharedSourceRoot)TrimmingAppContextSwitches.cs" LinkBase="Shared" />
27-
<Compile Include="$(SharedSourceRoot)RouteHandlers\ExecuteHandlerHelper.cs" LinkBase="Shared"/>
28-
</ItemGroup>
29-
30-
<ItemGroup>
31-
<EmbeddedResource Include="Properties\ILLink.Substitutions.xml" LogicalName="ILLink.Substitutions.xml" />
26+
<Compile Include="$(SharedSourceRoot)RouteHandlers\ExecuteHandlerHelper.cs" LinkBase="Shared" />
3227
</ItemGroup>
3328

3429
<ItemGroup>
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#nullable enable
22
static Microsoft.AspNetCore.Http.HttpRequestJsonExtensions.ReadFromJsonAsync(this Microsoft.AspNetCore.Http.HttpRequest! request, System.Text.Json.Serialization.Metadata.JsonTypeInfo! jsonTypeInfo, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<object?>
33
static Microsoft.AspNetCore.Http.HttpResponseJsonExtensions.WriteAsJsonAsync(this Microsoft.AspNetCore.Http.HttpResponse! response, object? value, System.Text.Json.Serialization.Metadata.JsonTypeInfo! jsonTypeInfo, string? contentType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
4-
static Microsoft.Extensions.DependencyInjection.HttpJsonServiceExtensions.ConfigureDefaultHttpJsonOptions(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!

src/Http/Http.Extensions/src/DefaultHttpJsonOptionsSetup.cs renamed to src/Http/Routing/src/ConfigureHttpJsonOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
using Microsoft.AspNetCore.Http.Json;
77
using Microsoft.Extensions.Options;
88

9-
namespace Microsoft.AspNetCore.Http;
9+
namespace Microsoft.AspNetCore.Routing;
1010

1111
[RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Ensure Microsoft.AspNetCore.EnsureJsonTrimmability=true.")]
1212
[RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Ensure Microsoft.AspNetCore.EnsureJsonTrimmability=true.")]
13-
internal sealed class DefaultHttpJsonOptionsSetup : IPostConfigureOptions<JsonOptions>
13+
internal sealed class ConfigureHttpJsonOptions : IPostConfigureOptions<JsonOptions>
1414
{
1515
public void PostConfigure(string? name, JsonOptions options)
1616
{

src/Http/Routing/src/DependencyInjection/RoutingServiceCollectionExtensions.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Collections.ObjectModel;
5+
using Microsoft.AspNetCore.Http.Json;
6+
using Microsoft.AspNetCore.Internal;
57
using Microsoft.AspNetCore.Routing;
68
using Microsoft.AspNetCore.Routing.Internal;
79
using Microsoft.AspNetCore.Routing.Matching;
@@ -99,7 +101,14 @@ public static IServiceCollection AddRouting(this IServiceCollection services)
99101
services.TryAddEnumerable(ServiceDescriptor.Transient<IConfigureOptions<RouteHandlerOptions>, ConfigureRouteHandlerOptions>());
100102

101103
// JsonOptions
102-
services.ConfigureDefaultHttpJsonOptions();
104+
if (!TrimmingAppContextSwitches.EnsureJsonTrimmability)
105+
{
106+
#pragma warning disable IL2026 // Suppressed in Microsoft.AspNetCore.Routing.WarningSuppressions.xml
107+
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
108+
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPostConfigureOptions<JsonOptions>, ConfigureHttpJsonOptions>());
109+
#pragma warning restore IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
110+
#pragma warning restore IL2026 // Suppressed in Microsoft.AspNetCore.Routing.WarningSuppressions.xml
111+
}
103112

104113
return services;
105114
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<linker>
3+
<assembly fullname="Microsoft.AspNetCore.Routing, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
4+
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
5+
<argument>ILLink</argument>
6+
<argument>IL2026</argument>
7+
<property name="Scope">member</property>
8+
<property name="Target">M:Microsoft.Extensions.DependencyInjection.RoutingServiceCollectionExtensions.AddRouting(Microsoft.Extensions.DependencyInjection.IServiceCollection)</property>
9+
</attribute>
10+
</assembly>
11+
</linker>

src/Http/Routing/src/Microsoft.AspNetCore.Routing.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@
3131
<Compile Include="$(SharedSourceRoot)MediaType\HttpTokenParsingRule.cs" LinkBase="Shared" />
3232
<Compile Include="$(SharedSourceRoot)ApiExplorerTypes\*.cs" LinkBase="Shared" />
3333
<Compile Include="$(SharedSourceRoot)RoutingMetadata\AcceptsMetadata.cs" LinkBase="Shared" />
34-
<Compile Include="$(SharedSourceRoot)Json\JsonSerializerExtensions.cs" LinkBase="Shared"/>
35-
<Compile Include="$(SharedSourceRoot)RouteHandlers\ExecuteHandlerHelper.cs" LinkBase="Shared"/>
34+
<Compile Include="$(SharedSourceRoot)Json\JsonSerializerExtensions.cs" LinkBase="Shared" />
35+
<Compile Include="$(SharedSourceRoot)TrimmingAppContextSwitches.cs" LinkBase="Shared" />
36+
<Compile Include="$(SharedSourceRoot)RouteHandlers\ExecuteHandlerHelper.cs" LinkBase="Shared" />
37+
</ItemGroup>
38+
39+
<ItemGroup>
40+
<EmbeddedResource Include="Properties\ILLink.Substitutions.xml" LogicalName="ILLink.Substitutions.xml" />
3641
</ItemGroup>
3742

3843
<ItemGroup>

src/Http/Http.Extensions/src/Properties/ILLink.Substitutions.xml renamed to src/Http/Routing/src/Properties/ILLink.Substitutions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<linker>
3-
<assembly fullname="Microsoft.AspNetCore.Http.Extensions">
3+
<assembly fullname="Microsoft.AspNetCore.Routing">
44
<type fullname="Microsoft.AspNetCore.Internal.TrimmingAppContextSwitches">
55
<method signature="System.Boolean get_EnsureJsonTrimmability()" body="stub" value="true" feature="Microsoft.AspNetCore.EnsureJsonTrimmability" featurevalue="true" />
66
</type>

0 commit comments

Comments
 (0)