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

The IJsonTypeInfoResolver returned a JsonTypeInfo instance whose JsonSerializerOptions setting does not match the provided argument #248

Closed
Jericho opened this issue Nov 13, 2022 · 3 comments
Assignees
Labels
Bug This change resolves a defect
Milestone

Comments

@Jericho
Copy link
Owner

Jericho commented Nov 13, 2022

As I have learned here, cloning Json serialization options is problematic when library targets .net6 and is being used in a .net7 application.

The culprit is this line in ZoomNetJsonConverter:

var clonedOptions = new JsonSerializerOptions(options);
clonedOptions.Converters.Add((JsonConverter)Activator.CreateInstance(propertyConverterAttribute.ConverterType));

it can be replaced with:

var customOptions = new JsonSerializerOptions()
{
	Converters = { (JsonConverter)Activator.CreateInstance(propertyConverterAttribute.ConverterType) }
};
@Jericho Jericho added the Bug This change resolves a defect label Nov 13, 2022
@Jericho Jericho added this to the 0.53.0 milestone Nov 13, 2022
@Jericho Jericho self-assigned this Nov 13, 2022
@tmoreland-r7
Copy link

not sure how related it is but seeing this when using JsonSerializerOptions.TypeInfoResolver with a combined generated SerializerContext + new instance of DefaultJsonTypeInfoResolver()

@tmoreland-r7
Copy link

nevermind, I had forgotten to push an updated dependency (updated to support net7.0) so it was still using the older net6.0 build which I'm assuming is the cause, leaving this here in case anyone else finds this via bing/google/whatever

@Jericho
Copy link
Owner Author

Jericho commented Nov 22, 2022

🎉 This issue has been resolved in version 0.53.0 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This change resolves a defect
Projects
None yet
Development

No branches or pull requests

2 participants