fix correctness bugs across core, JsonPath, Xml and FSharp

Merged
SI
5mo ago
+878-51

fix correctness bugs across core, JsonPath, Xml and FSharp

Add regression tests (src/ArgonTests/BugFixes/, NullTokenTests.fs) and fix:

core writer/reader

  • JsonConvert.ToString(TimeSpan) escaped the whole stack buffer, embedding NULs
  • JsonWriter.WriteValue(StringBuilder) wrote each chunk as a separate JSON string
  • JsonTextWriter.WriteValue(char) ignored QuoteValue/QuoteChar
  • JsonTextReader.Close() double-returned charBuffer to ArrayPool on a second call
  • JsonReader.SetUndefinedToken set Null instead of Undefined

serializer

  • JsonConverter.ReadJson returned null on container tokens without consuming them
  • OrderByKey packed the comparer into the sort key, making ordering culture-sensitive
  • JsonSerializerProxy did not forward ResolveContract or Converters to converters
  • CreateProperties used unstable List.Sort, scrambling order for >16 props with Order
  • removed duplicate EncodingConverter registration

utilities

  • GetDefaultValue(char) returned boxed int 0 so DefaultValueHandling.Ignore missed chars
  • BoxedPrimitives.Get(decimal) dropped the sign of negative zero
  • ISO parser accepted out-of-range zone offsets, throwing from the DateTimeOffset ctor

linq

  • CompareBigInteger inverted comparisons against negative fractions
  • GetHashCode/GetDeepHashCode were inconsistent with Equals across numeric types
  • TryAddInternal advanced the index when a child insert was skipped
  • implemented JObject IDictionary.Values (was NotImplementedException)

jsonpath

  • FieldMultipleFilter threw ErrorWhenNoMatch even when the property existed
  • numeric filter literals were not terminated by && or ||
  • $[-1] crashed instead of returning null

fsharp

  • FSharpList/FSharpMap converters crashed on a JSON null

xml

  • single-element nested arrays lost json:Array for prefixed/encoded names
  • multiple sibling comments serialized to "#comment": [], dropping the text
  • CreateXmlDocumentType discarded the DTD internal subset
  • #cdata-section/#text with a null value crashed for XDocument