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

Configure both Microsoft.AspNetCore.Http.Json.JsonOptions & Microsoft.AspNetCore.Mvc.JsonOptions using DocumentJsonSerializerOptions defaults #16836

Closed
wants to merge 1 commit into from

Conversation

hishamco
Copy link
Member

@hishamco hishamco commented Oct 4, 2024

This pull request includes changes to the JsonOptionsConfigurations class to support both HttpJsonOptions and MvcJsonOptions configurations.

Fixes #16831

/cc @wAsnk

….AspNetCore.Mvc.JsonOptions using DocumentJsonSerializerOptions defaults
@hishamco hishamco changed the title Configure both Microsoft.AspNetCore.Http.Json.JsonOptions & Microsoft… Configure both Microsoft.AspNetCore.Http.Json.JsonOptions & Microsoft.AspNetCore.Mvc.JsonOptions using DocumentJsonSerializerOptions defaults Oct 4, 2024
@hishamco hishamco requested a review from Piedone October 4, 2024 17:45
=> options.SerializerOptions.Merge(_jsonSerializerOptions);

public void Configure(MvcJsonOptions options)
=> options.JsonSerializerOptions.Merge(_jsonSerializerOptions);
Copy link
Member

Choose a reason for hiding this comment

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

When does this get called for you? Because it doesn't for me.

Also, this would be better in two classes.

Copy link
Member Author

Choose a reason for hiding this comment

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

When does this get called for you? Because it doesn't for me.

Read the issue description

Also, this would be better in two classes.

The problem with two classes is the naming

Copy link
Member Author

Choose a reason for hiding this comment

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

We could use partial class for clarity

Copy link
Member

Choose a reason for hiding this comment

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

I understand the issue description. My question is, when testing this, when do you see line 23 be called?

You can have two IConfigureOptions implementations, there's surely no difficulty in that.

@MikeAlhayek
Copy link
Member

I think we should not do this in OC because this will change the default of ASP.NET framework by OC which could impact people in a way they don't expect. I actually think we should remove JsonOptionsConfigurations so we are not changing default asp.net behavior by OC incase people actually want the .net framework default.

I would do this instead #16831 (comment)

Copy link
Contributor

github-actions bot commented Oct 9, 2024

This pull request has merge conflicts. Please resolve those before requesting a review.

@Piedone
Copy link
Member

Piedone commented Oct 9, 2024

Fixed in #16837.

@Piedone Piedone closed this Oct 9, 2024
@hishamco hishamco deleted the hishamco/json branch October 9, 2024 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Microsoft.AspNetCore.Mvc.JsonOptions uses default instead of OC JOptions settings
3 participants