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

Populate existing collections by default when deserializing JSON #16628

Closed
wants to merge 3 commits into from

Conversation

sebastienros
Copy link
Member

@sebastienros sebastienros commented Aug 28, 2024

@sebastienros
Copy link
Member Author

I found that the sessions didn't have this property. Isolated it to these defaults. I want to see if the tests still pass as we might have not set it on purpose, I remember we had issues that STJ was not able to assign new collections and we went with init setters for this reason. But I believe that if it find existing collections it will just be fine.

@MikeAlhayek
Copy link
Member

Strange that we did not add it. I think it should be added too. I suggest that you add a test case to approve that this fixed the problem we had.

@gvkries
Copy link
Contributor

gvkries commented Aug 28, 2024

This is way better than adding another JsonConverter.
Should it also be set in JsonSerializerOptionsExtensions.Merge()?

public static JsonSerializerOptions Merge(this JsonSerializerOptions destination, JsonSerializerOptions source)

Copy link
Contributor

@sarahelsaig sarahelsaig left a comment

Choose a reason for hiding this comment

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

I agree with @gvkries , PreferredObjectCreationHandling should be added to JsonSerializerOptionsExtensions.Merge() and that should be used here instead of manually overwriting each property.
That way you will never have to manually update this configuration from JOptions.Base if a new setting is added there or something.

sebastienros and others added 2 commits August 28, 2024 08:55
…onSerializerOptionsConfiguration.cs

Co-authored-by: Sára El-Saig <sara.el-saig@lombiq.com>
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.

Breaking shape name resolution regarding menu shape
4 participants