-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Remove extra constructors in JsonInputFormatter
and JsonPatchInputFormatter
#4339
Comments
Is there any reasonably common scenario for new'ing up these types? (Aside from tests, which is mostly our own internal concern.) |
I'm not really sure. There was in WebAPI - but that was often a workaround for other things being obtuse.... Only case I can think of is if you have two different sets of JSON settings. |
There's still an action item to take here if we don't want to make them constructable, we should clean up the other ctors. |
If there's nothing "common" then I'll put in Backlog. If there's something more urgent for v1, what is it that we should do? |
Suggest that if there's no common scenario, we were wrong to add the extra constructors. They are a bit complicated and do odd things like |
Well, given what I've understood here, this would be backlog. So if you could distill this down to exactly what new proposed action we should take sooner, let's take a look at that. |
JsonInputFormatter
and JsonPatchInputFormatter
JsonInputFormatter
and JsonPatchInputFormatter
Sure. I've updated the title and description. (In retrospect, should have posed this issue as a question on which way to go.) |
Choose any two. |
@rynowak are you onboard with that? |
Yes |
Ok, we'll do in RTM. |
As long as issue #4270 is not fixed, the workaround requires to be able to derive from JsonInputFormatter and have access to the base constructor. |
- #4339 - `JsonInputFormatter`, `JsonOutputFormatter`, `JsonPatchInputFormatter` - `JsonOutputFormatter` cleanup also impacts `JsonHelper` also - create unique `JsonSerializerSettings` when changing settings - fix one `JsonOutputFormatterTests` test; was actually testing `JsonInputFormatter` - remove now-duplicate tests
- #4339 - `JsonInputFormatter`, `JsonOutputFormatter`, `JsonPatchInputFormatter` - `JsonOutputFormatter` cleanup also impacts `JsonHelper` also - create unique `JsonSerializerSettings` when changing settings - fix one `JsonOutputFormatterTests` test; was actually testing `JsonInputFormatter` - remove now-duplicate tests
New overall description: Remove extra options to manipulate `JsonSerializerSettings` - #4339: remove non-recommended JSON formatter constructors - affects `JsonInputFormatter`, `JsonOutputFormatter`, `JsonPatchInputFormatter` - `JsonOutputFormatter` cleanup also impacts `JsonHelper` - make `SerializerSettingsProvider` class public and use it - #4409: make `SerializerSetings` properties get-only and `protected` - affects `JsonInputFormatter`, `JsonOutputFormatter` Recommended patterns: - change `JsonSerializerSettings` values in `MvcJsonOptions` for almost all customizations - find `JsonOutputFormatter` in `MvcOptions.OutputFormatters` when limiting per-result formatters - start with `SerializerSettingsProvider.CreateSerializerSettings()` when customizing a per-result formatter
- #4339: remove non-recommended JSON formatter constructors - affects `JsonInputFormatter`, `JsonOutputFormatter`, `JsonPatchInputFormatter` - `JsonOutputFormatter` cleanup also impacts `JsonHelper` - rename and make `SerializerSettingsProvider` class public; use it as appropriate - #4409: make `SerializerSetings` properties get-only and `protected` - affects `JsonInputFormatter`, `JsonOutputFormatter` Recommended patterns: - change `JsonSerializerSettings` values in `MvcJsonOptions` for almost all customizations - find `JsonOutputFormatter` in `MvcOptions.OutputFormatters` when limiting per-result formatters - start with `JsonSerializerSettingsProvider.CreateSerializerSettings()` when customizing a per-result formatter
Sorry for the necropost but I'm working on upgrading to 1.0 at the moment. We were overriding input/output formatters like so, mostly to globally configure converters.
I did not see any announcements on this. Is there a different way I should be overriding serializer settings in 1.0? If not, what values should I use the logger, charPool and objectPoolProvider parameters? |
You can modify the "shared" JSON.NET settings by doing:
|
Thanks for the quick response - I just found that AddJsonOptions when looking at the next json-related issue we're having and was hoping it would do the trick. Good to know it will! |
Hi, it looks like you are posting on a closed issue/PR/commit! We're very likely to lose track of your bug/feedback/question unless you:
Thanks! |
The
JsonInputFormatter
andJsonPatchInputFormatter
classes previously had a parameterless constructor for ease of use. This was lost when a requiredILogger
parameter was added. We have also since decided there's no important user scenario involving construction of these types. ButJsonInputFormatter
still has 3 constructor overloads whileJsonPatchInputFormatter
has 2. The extra overloads are used only in test code and are somewhat complicated i.e. don't just passnull
to the longest overload.Should remove all but the longest constructor overload in each class. Change the related tests to use the one remaining constructor for each class.
The text was updated successfully, but these errors were encountered: