-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Move JSON.NET specific features to a separate assembly #5146
Conversation
...crosoft.AspNetCore.Mvc.NewtonsoftJson/DependencyInjection/MvcJsonMvcCoreBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
...c/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/Microsoft.AspNetCore.Mvc.NewtonsoftJson.csproj
Outdated
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/NewtonsoftJsonControllerExtensions.cs
Outdated
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/SessionStateTempDataProvider.cs
Outdated
Show resolved
Hide resolved
src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/ApiBehaviorTest.cs
Show resolved
Hide resolved
...c/Microsoft.AspNetCore.Mvc.NewtonsoftJson/DependencyInjection/MvcJsonMvcBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
...c/Microsoft.AspNetCore.Mvc.NewtonsoftJson/DependencyInjection/MvcJsonMvcBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
...crosoft.AspNetCore.Mvc.NewtonsoftJson/DependencyInjection/MvcJsonMvcCoreBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/JsonHelperExtensions.cs
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/JsonHelperExtensions.cs
Outdated
Show resolved
Hide resolved
...c/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/Microsoft.AspNetCore.Mvc.NewtonsoftJson.csproj
Outdated
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/ProblemDetailsConverter.cs
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Infrastructure/DefaultTempDataSerializer.cs
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Rendering/DefaultJsonHelper.cs
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/ProblemDetailsConverter.cs
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/AnnotatedProblemDetails.cs
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/AnnotatedProblemDetails.cs
Show resolved
Hide resolved
f70f98b
to
d86770c
Compare
b2a6d63
to
4e30791
Compare
🆙 📅 |
@@ -125,7 +125,7 @@ public void ConfigureServices(IServiceCollection services) | |||
services | |||
.AddMvcCore() | |||
.AddAuthorization() | |||
.AddJsonFormatters(json => json.ContractResolver = new CamelCasePropertyNamesContractResolver()) | |||
.AddNewtonsoftJsonFeatures(options => options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on the name? It's a bit more than serializers. There's one casualty here - this method will add services used by views. In the past, you could use MvcCoreBuilder based extensions to avoid adding any view related features to DI. Do we need to maintain a AddNewtonsoftJsonFormatters
in addition to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just AddNewtonsoftJson
?
I think it's OK that we're adding the viewfeatures-defined services. They don't do anything unless they are used.
One thing we could do is move the interface types into Mvc.Abstractions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would reduce the number of assemblies that get loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TempDataSerializer
doesn't quite feel like something that belongs in abstractions. Perhaps it's ok to leave this as-is unless we get some strong feedback
....AspNetCore.Mvc.NewtonsoftJson/DependencyInjection/NewtonsoftJsonMvcCoreBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Rendering/DefaultJsonHelper.cs
Show resolved
Hide resolved
src/Mvc/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ServicesModelBinderIntegrationTest.cs
Show resolved
Hide resolved
13b657c
to
d5bcaf8
Compare
🆙 📅 |
/// <summary> | ||
/// A RFC 7807 compliant <see cref="JsonConverter"/> for <see cref="ValidationProblemDetails"/>. | ||
/// </summary> | ||
public sealed class ValidationProblemDetailsConverter : JsonConverter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the converters need to be public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The equivalent types for the xml serializers are public - https://github.com/aspnet/AspNetCore/blob/master/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Xml/ProblemDetailsWrapper.cs so it made sense to do so here
/// <inheritdoc /> | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
return objectType == typeof(ValidationProblemDetails); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you care about serializing sub-classes of ValidationProblemDetails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, we don't want a catch-all converter, one of the reasons I did not use JsonConverter<T>
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove extra line
src/Mvc/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/ValidationProblemDetailsConverter.cs
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Infrastructure/TempDataSerializer.cs
Show resolved
Hide resolved
64b38e8
to
1db2821
Compare
🆙 📅 |
5325f6c
to
63ca2b9
Compare
ab7a6a1
to
bb61da5
Compare
bb61da5
to
a63c0ab
Compare
So, does this mean we can pull Json.NET out of the shared fx now? |
No description provided.