See dotnet/corefx#37549 (comment) for context.
If you nest complex documents, JsonSerializer uses JsonDocument which throws:
System.Text.Json.Serialization.Tests.ObjectTests.ReadClassIgnoresLeadingOrTrailingTrivia(leadingTrivia: "/* Multi\nLine\nComment */ ", trailingTrivia: "\t// trailing comment\n ") [FAIL]
System.ArgumentException : Comments cannot be stored in a JsonDocument, only the Skip and Disallow comment handling modes are supported.
Parameter name: reader
JsonSerializerOptions should either support JsonCommentHandling.Allow in all cases (by transforming it to JsonCommentHandling.Skip before passing it to the JsonDocument), or just like JsonDocument, throw if the options is set to Allow. This comes up whenever a user has a System.Object property (which is where JsonDocument gets used).
I don't really see much benefit of Allow outside of JsonReader.
cc @steveharter, @bartonjs, @JamesNK, @rynowak, @JeremyKuhne, @watfordgnf
See dotnet/corefx#37549 (comment) for context.
JsonSerializerOptions should either support
JsonCommentHandling.Allowin all cases (by transforming it toJsonCommentHandling.Skipbefore passing it to theJsonDocument), or just likeJsonDocument, throw if the options is set toAllow. This comes up whenever a user has aSystem.Objectproperty (which is whereJsonDocumentgets used).I don't really see much benefit of
Allowoutside ofJsonReader.cc @steveharter, @bartonjs, @JamesNK, @rynowak, @JeremyKuhne, @watfordgnf