YamlDotNet icon indicating copy to clipboard operation
YamlDotNet copied to clipboard

fix: floating-point number serialization issue for non-normal values

Open filzrev opened this issue 1 year ago • 0 comments

This PR intended to fix #991.

What's changed in this PR

  • Replace formatter.FormatNumber(object value); call to ToString("G", CultureInfo.InvariantCulture).
    • It's required to serialize special symbols (Nan/PositiveInfinite/NegativeInfinite) to JSON compatible string representation.
    • Additionally explicitly specify format (G) to align YAML serialized value
  • Remove NumericRegex checks. Instead add IsNaN/IsInfinity checks
  • Add unit test code (SerializationOfNumericsAsJsonRountTrip)

filzrev avatar Oct 16 '24 05:10 filzrev