Skip to content
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

Merged
merged 1 commit into from
Jan 8, 2019

Conversation

pranavkm
Copy link
Contributor

No description provided.

@pranavkm pranavkm requested a review from rynowak December 17, 2018 02:32
@pranavkm pranavkm changed the title Move JSON.NET specific features to a separate assembly [WIP] Move JSON.NET specific features to a separate assembly Dec 17, 2018
@pranavkm pranavkm changed the title [WIP] Move JSON.NET specific features to a separate assembly Move JSON.NET specific features to a separate assembly Dec 24, 2018
@pranavkm pranavkm force-pushed the prkrishn/json branch 2 times, most recently from b2a6d63 to 4e30791 Compare December 31, 2018 19:06
@pranavkm
Copy link
Contributor Author

🆙 📅

@@ -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())
Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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

@pranavkm pranavkm force-pushed the prkrishn/json branch 2 times, most recently from 13b657c to d5bcaf8 Compare January 3, 2019 20:43
@pranavkm
Copy link
Contributor Author

pranavkm commented Jan 3, 2019

🆙 📅

/// <summary>
/// A RFC 7807 compliant <see cref="JsonConverter"/> for <see cref="ValidationProblemDetails"/>.
/// </summary>
public sealed class ValidationProblemDetailsConverter : JsonConverter
Copy link
Member

@JamesNK JamesNK Jan 3, 2019

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// <inheritdoc />
public override bool CanConvert(Type objectType)
{
return objectType == typeof(ValidationProblemDetails);
Copy link
Member

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?

Copy link
Contributor Author

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>

}
}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove extra line

@pranavkm pranavkm force-pushed the prkrishn/json branch 2 times, most recently from 64b38e8 to 1db2821 Compare January 4, 2019 18:55
@pranavkm
Copy link
Contributor Author

pranavkm commented Jan 4, 2019

🆙 📅

@pranavkm pranavkm force-pushed the prkrishn/json branch 2 times, most recently from ab7a6a1 to bb61da5 Compare January 8, 2019 19:11
@pranavkm pranavkm merged commit cdc66c5 into master Jan 8, 2019
@pranavkm pranavkm deleted the prkrishn/json branch January 8, 2019 20:49
@natemcmaster
Copy link
Contributor

So, does this mean we can pull Json.NET out of the shared fx now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants