Skip to content

Commit

Permalink
Fixes aaubry#792 parsing bug for floats with non english culture
Browse files Browse the repository at this point in the history
Adds `CultureInfo.InvariantCulture` in parsing method in
`ScalarNodeDeserializer.AttemptUnknownTypeDeserialization`.
This caused tests to fail in non english culture (Tested with "es-AR")
  • Loading branch information
jhm-ciberman committed Mar 30, 2023
1 parent f460b5c commit e6ba3f3
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,13 @@ private static object CastInteger(ulong number, TypeCode typeCode)
}
else if (Regex.IsMatch(v, @"[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?")) //regular number
{
if (TryAndSwallow(() => byte.Parse(v), out result)) { }
else if (TryAndSwallow(() => short.Parse(v), out result)) { }
else if (TryAndSwallow(() => int.Parse(v), out result)) { }
else if (TryAndSwallow(() => long.Parse(v), out result)) { }
else if (TryAndSwallow(() => ulong.Parse(v), out result)) { }
else if (TryAndSwallow(() => float.Parse(v), out result)) { }
else if (TryAndSwallow(() => double.Parse(v), out result)) { }
if (TryAndSwallow(() => byte.Parse(v, CultureInfo.InvariantCulture), out result)) { }
else if (TryAndSwallow(() => short.Parse(v, CultureInfo.InvariantCulture), out result)) { }
else if (TryAndSwallow(() => int.Parse(v, CultureInfo.InvariantCulture), out result)) { }
else if (TryAndSwallow(() => long.Parse(v, CultureInfo.InvariantCulture), out result)) { }
else if (TryAndSwallow(() => ulong.Parse(v, CultureInfo.InvariantCulture), out result)) { }
else if (TryAndSwallow(() => float.Parse(v, CultureInfo.InvariantCulture), out result)) { }
else if (TryAndSwallow(() => double.Parse(v, CultureInfo.InvariantCulture), out result)) { }
else
{
//we couldn't parse it, default to string, It's probably too big
Expand Down

0 comments on commit e6ba3f3

Please sign in to comment.