-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Register JsonSerializerOptions in the IoC Container #15328
Conversation
Just |
Why not use Options pattern? It maybe useful as some may way to configure the default setting differently. |
src/OrchardCore/OrchardCore.Abstractions/Json/IJsonSerializer.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.Abstractions/Extensions/JsonSerializerOptionsConfiguration.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore/Modules/Extensions/ServiceCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
@@ -152,6 +155,9 @@ private static void AddDefaultServices(OrchardCoreBuilder builder) | |||
|
|||
services.AddSingleton<IPoweredByMiddlewareOptions, PoweredByMiddlewareOptions>(); | |||
|
|||
services.AddTransient<IConfigureOptions<JsonSerializerOptions>, JsonSerializerOptionsConfiguration>(); |
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 if we also register:
services.AddTransient<JsonSerializerOptions>(sp => sp.GetRequiredService<IOptions<JsonSerializerOptions>>().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.
did you get any feedback on this approach?
@sebastienros I addressed your feedback. I also used |
src/OrchardCore/OrchardCore.Abstractions/Extensions/JsonSerializerOptionsConfiguration.cs
Outdated
Show resolved
Hide resolved
This pull request has merge conflicts. Please resolve those before requesting a review. |
…izerOptionsConfiguration.cs Co-authored-by: Hisham Bin Ateya <hishamco_2007@yahoo.com>
src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/DateTimeFieldSettingsDriver.cs
Outdated
Show resolved
Hide resolved
...OrchardCore.Modules/OrchardCore.ContentTypes/Deployment/ContentDefinitionDeploymentSource.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.
It looks like a lot of changes are about ContentItem and I think this is not required. The test would be simple, put a "$type"
property with something random and you'll see that the resulting content item will still have this property in it's Data
property. That will only be the responsibility of the Part deserialization to use the options.
src/OrchardCore.Modules/OrchardCore.Autoroute/Handlers/AutoroutePartHandler.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.ContentManagement/DefaultContentManager.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.ContentManagement.Abstractions/IContentManager.cs
Outdated
Show resolved
Hide resolved
@sebastienros I made some more changes. There are multiple unrelated changes that you could just ignore. Let me know if you see anything else. |
@MikeAlhayek what's the remaining in this PR, coz I requested changes in the past and I need to approve it, can I did second round review if it's complete |
@hishamco it is complete. I know there are lots of unrelated changes here which is due to the files that were originally touched. I am waiting on @sebastienros to see if we got everything or not. I am not quite sure if the workflow state needs the serializer options here or not. But feel free to review it |
src/OrchardCore.Modules/OrchardCore.Layers/Deployment/AllLayersDeploymentSource.cs
Show resolved
Hide resolved
GTG |
? |
Good To Go |
Do you agree that WorkflowState needs the options? |
Registered a default
JsonSerializerOptions
Lastly used the default
JsonSerializerOptions
when using JObject.FromObject.