-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Changing reflection-based json configuration #46303
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
brunolins16
wants to merge
56
commits into
dotnet:main
from
brunolins16:brunolins16/aot/json/reflection-json-options
Closed
Changes from 10 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
c2945c2
Mvc JsonOptions updates
brunolins16 26be191
Http JsonOptions updates
brunolins16 5754198
Merge remote-tracking branch 'upstream/main' into brunolins16/aot/jso…
brunolins16 b6fadd9
Bad merge
brunolins16 d31a8e2
fix end line
brunolins16 cc71ed2
Updating RUC/RDC message
brunolins16 f47a076
Add call to AddRouting
brunolins16 d227b30
Fix suppressions
brunolins16 df207a0
Remove empty spaces
brunolins16 9e97941
Moving to Routing
brunolins16 eb64558
Revert "Moving to Routing"
brunolins16 5b175ed
Adding AddDefaultJsonOptions API
brunolins16 45b2282
Fixing unit tests
brunolins16 bb507c7
Trying a different approach
brunolins16 f52c535
Changing MVC
brunolins16 4298afc
Clean up
brunolins16 785d91e
Merge remote-tracking branch 'upstream/main' into brunolins16/aot/jso…
brunolins16 60f9ade
Clean up & Fix/Add unit tests
brunolins16 df95bd3
Merge remote-tracking branch 'upstream/main' into brunolins16/aot/jso…
brunolins16 b9ec639
Merge remote-tracking branch 'upstream/main' into brunolins16/aot/jso…
brunolins16 e186cc4
Include TrimmingAppContextSwitches
brunolins16 de59eb6
Create Microsoft.AspNetCore.Http.Results.WarningSuppressions.xml
brunolins16 2f2869a
Clean up
brunolins16 c45a8f3
Merging changes from #46225
brunolins16 de450ae
Locking JsonOptions :(
brunolins16 b3b7cef
Fixing linker suppressions
brunolins16 5715427
Simplify and using PostConfigureOptions
brunolins16 67faf3f
Clean up
brunolins16 ede0a7e
Fixing unit tests
brunolins16 a7ae048
Fix unit test
brunolins16 422cb93
Trying fix SignalR
brunolins16 8edd3b7
Revert "Trying fix SignalR"
brunolins16 cde347e
Update Startup.cs
brunolins16 a18c01b
Changing to a IOptionsFactory
brunolins16 d45eea5
Move to singleton
brunolins16 298f9e5
Trying another approach
brunolins16 fe7434a
Clean up
brunolins16 580d227
More clean up
brunolins16 6dfe6c1
More clean up
brunolins16 e7e44a5
Merge branch 'brunolins16/aot/json/reflection-json-options' of https:…
brunolins16 afd6762
More clean up
brunolins16 c251205
Fix mvc
brunolins16 19c9465
Merge remote-tracking branch 'upstream/main' into brunolins16/aot/jso…
brunolins16 c01dc5f
More clean up
brunolins16 473e2eb
Merge remote-tracking branch 'upstream/main' into brunolins16/aot/jso…
brunolins16 9ceb581
More clean up
brunolins16 5bfb9e1
Cleaning up JsonHttpResult
brunolins16 aaed7dc
More clean up
brunolins16 79d5117
More clean up
brunolins16 7637bdd
Moving changes to #46716
brunolins16 14a5aac
Fix comment
brunolins16 35556da
Removing public api
brunolins16 08e1545
Merge remote-tracking branch 'upstream/main' into brunolins16/aot/jso…
brunolins16 29fd8cd
PR feedback updates
brunolins16 8c830d1
Removing extra usings
brunolins16 2c5caff
Fix tests
brunolins16 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#nullable enable | ||
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?> | ||
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! | ||
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using System.Text.Json.Serialization.Metadata; | ||
using Microsoft.AspNetCore.Http.Json; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Microsoft.AspNetCore.Routing; | ||
|
||
[RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Ensure Microsoft.AspNetCore.EnsureJsonTrimmability=true.")] | ||
[RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Ensure Microsoft.AspNetCore.EnsureJsonTrimmability=true.")] | ||
internal sealed class ConfigureHttpJsonOptions : IPostConfigureOptions<JsonOptions> | ||
{ | ||
public void PostConfigure(string? name, JsonOptions options) | ||
{ | ||
InitializeForReflection(options); | ||
} | ||
|
||
private static void InitializeForReflection(JsonOptions options) | ||
{ | ||
options.SerializerOptions.TypeInfoResolver = JsonTypeInfoResolver.Combine(options.SerializerOptions.TypeInfoResolver, new DefaultJsonTypeInfoResolver()); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/Http/Routing/src/Microsoft.AspNetCore.Routing.WarningSuppressions.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<linker> | ||
<assembly fullname="Microsoft.AspNetCore.Routing, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60"> | ||
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute"> | ||
<argument>ILLink</argument> | ||
<argument>IL2026</argument> | ||
<property name="Scope">member</property> | ||
<property name="Target">M:Microsoft.Extensions.DependencyInjection.RoutingServiceCollectionExtensions.AddRouting(Microsoft.Extensions.DependencyInjection.IServiceCollection)</property> | ||
</attribute> | ||
</assembly> | ||
</linker> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/src/Properties/ILLink.Substitutions.xml → ...g/src/Properties/ILLink.Substitutions.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreJsonOptionsSetup.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using System.Text.Json.Serialization.Metadata; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection; | ||
|
||
[RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Ensure Microsoft.AspNetCore.EnsureJsonTrimmability=true.")] | ||
[RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Ensure Microsoft.AspNetCore.EnsureJsonTrimmability=true.")] | ||
internal sealed class MvcCoreJsonOptionsSetup : IPostConfigureOptions<JsonOptions> | ||
{ | ||
public void PostConfigure(string? name, JsonOptions options) | ||
{ | ||
InitializeForReflection(options); | ||
} | ||
|
||
private static void InitializeForReflection(JsonOptions options) | ||
{ | ||
options.JsonSerializerOptions.TypeInfoResolver = JsonTypeInfoResolver.Combine(options.JsonSerializerOptions.TypeInfoResolver, new DefaultJsonTypeInfoResolver()); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.