-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
Hello,
I am a user of the Convey project and noticed that they use this project for its JSON serialization. I may have found an issue in your Clone code for cloning serialization options.
public static JsonSerializerOptions Clone(this JsonSerializerOptions options)
{
if (options == null) throw new ArgumentNullException(nameof(options));
Contract.EndContractBlock();
var clone = new JsonSerializerOptions
{
AllowTrailingCommas = options.AllowTrailingCommas,
DefaultBufferSize = options.DefaultBufferSize,
DictionaryKeyPolicy = options.DictionaryKeyPolicy,
Encoder = options.Encoder,
IgnoreNullValues = options.IgnoreNullValues,
IgnoreReadOnlyFields = options.IgnoreReadOnlyFields,
IgnoreReadOnlyProperties = options.IgnoreReadOnlyProperties,
IncludeFields = options.IncludeFields,
MaxDepth = options.MaxDepth,
NumberHandling = options.NumberHandling,
PropertyNameCaseInsensitive = options.PropertyNameCaseInsensitive,
PropertyNamingPolicy = options.PropertyNamingPolicy,
ReadCommentHandling = options.ReadCommentHandling,
WriteIndented = options.WriteIndented
};
foreach (var converter in options.Converters)
clone.Converters.Add(converter);
return clone;
}
It looks like you are not cloning the reference handler option. Unless I am missing something. Could this option along with any other potential missing options be added in the clone?
What happens currently when I pass in my JsonSerializerOptions object with a reference handler option set to the JsonSerializerFactory constructor, then call the GetSerializer method. I get back a serializer with the handler option no longer set.
If you need any further details I can try to provide more. Thanks.
Metadata
Metadata
Assignees
Labels
No labels