Closed ziemiowid closed 6 years ago
I suppose that code which triggers this error is in Legivel.Mapper/Customization.fs
line 28, where one can find call to Double.Parse(String)
.
ScalarToNativeMapping.Create (YamlExtended.FloatGlobalTag, typeof<float>, fun (s:string) -> YamlExtended.FloatGlobalTag.ToCanonical s |> Option.get |> Double.Parse |> box)
According to .NET documentation string passed to Double.Parse(String)
is interpreted using the formatting information in a NumberFormatInfo object that is initialized for the current thread culture.
so in, for example pl_PL
environment it expects coma as decimal separator and hence exception.
To avoid exception more complicated form of Double.Parse(String, NumberStyles)
should be used.
Unfortunately I couldn't catch this error in my debugging environment (Monodevelop), so it's only speculations.
Hi,
Thanks for noticing. I've fixed this issue in 0.0.7, which I published to Nuget just now. Float parsing was indeed broken - in my language we use comma as decimal seperator.
Anyway, there is now a unit test for this. Please let me know if it works on your machine.
Regards, Frank
I think there's no reason to keep this issue opened now.
Description
Unhandled exception is thrown when deserializing float value in culture context not using a dot as decimal separator.
Repro steps
Under Linux:
Set language environment to Polish, and run fsi.exe
LANG=pl_PL.utf8 mono fsi.exe
Run script:
Expected behavior
String "3.14" should be parsed as float value:
Actual behavior
Exception is thown:
Known workarounds
This exception can be avoided by setting proper language environment before running program, for example in Linux:
Related information
4.4.92-18.36-default x86_64
Mono JIT compiler version 4.6.2 (Stable 4.6.2.7/08fd525 Fri Nov 18 12:32:36 UTC 2016)