-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Cleanup MvcJsonHelper #6529
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
Cleanup MvcJsonHelper #6529
Conversation
pranavkm
commented
Jan 9, 2019
- Remove dependency on JsonOutputFormatter
- Cache JsonSerializer for the default case
pranavkm
left a comment
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.
Cleaning up JsonHelper \ output formatter while we're making breaking changes to the type \ assembly
src/Mvc/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/NewtonsoftJsonHelper.cs
Outdated
Show resolved
Hide resolved
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.
NewtonsoftJsonOutputFormatter applies two other settings to the writer it creates - CloseOutput = false, AutoCompleteOnClose = false, neither of which seemed important here?
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.
Correct
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.
Inlined this. This API isn't used by anything now and I'm not sure it has much value
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 should application code that used to call this method do to respond to this breaking change? we are in the middle of upgrading the newtonsoft lversion.
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.
@richardwan you could call jsonSerializer.Serialize(jsonWriter, value) in your application code. If you need to discuss this further, please file an issue.
* Remove dependency on JsonOutputFormatter * Cache JsonSerializer for the default case
c0cf8d9 to
af6eddd
Compare
pranavkm
left a comment
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.
🆙 📅
JamesNK
left a comment
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.
![]()
dougbu
left a comment
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.
Minor comments but otherwise
after confirming thread-safety with @JamesNK
src/Mvc/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/NewtonsoftJsonHelper.cs
Outdated
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/NewtonsoftJsonHelper.cs
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/NewtonsoftJsonHelper.cs
Show resolved
Hide resolved
src/Mvc/src/Microsoft.AspNetCore.Mvc.NewtonsoftJson/NewtonsoftJsonHelper.cs
Outdated
Show resolved
Hide resolved
src/Mvc/test/Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test/NewtonsoftJsonOutputFormatterTest.cs
Show resolved
Hide resolved
|
This is a super good cleanup. This is something I always wanted to change but was afraid of the breaking potential. What's the reason for the difference in output, is it that we're HTML-encoding inside JSON.NET rather than letting the Razor infrastructure do it? |
@pranavkm and I discussed this test output. It previously indicated a bug -- un-escaped HTML would have flowed through to responses because Razor doesn't do anything more with |