Closed johannesvp closed 4 years ago
This looks like an issue. I will look into it.
Note:
Deserialize
"NaN" = "Incorrect format: 'NaN', for tag: tag:yaml.org,2002:float"
This is expected behavior. Both nan
and inf
need to preceed with a dot (see regexp part).
Fixed in 0.4.5
Tested with ".nan", ".inf", "+.inf" and "-.inf". All working fine.
Thank you very much for the fix. I really appreciate that you fixed it this fast.
Description
I cannot deserialize an infinite floating point number in yaml to a float. Ditto for 'not a number'.
Expected behavior
Deserialize<float> "1.23" = 1.23
Deserialize<float> "NaN" = nan
Deserialize<float> "nan" = nan
Deserialize<float> ".nan" = nan
Actual behavior
Deserialize<float> "1.23" = 1.23
Deserialize<float> "NaN" = "Incorrect format: 'NaN', for tag: tag:yaml.org,2002:float"
Deserialize<float> "nan" = "Incorrect format: 'nan', for tag: tag:yaml.org,2002:float"
Deserialize<float> ".nan" = System.FormatException: Input string was not in a correct format.
Known workarounds
No workarounds. No value is accepted for nan/infinite in yaml.
Related information
src/Legivel.Mapper/Customization.fs:
let value = YamlExtended.FloatGlobalTag.ToCanonical s |> Option.get
Double.Parse(value, CultureInfo.InvariantCulture) |> box)
It looks like the ToCanonical always returns
Some ".nan"
for "not a number". This is not the correct input forDouble.Parse
. Similar problem for infinite.