-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeHelper#ParseNumber TryParse does not use InvariantCulture #320
Comments
Good point. |
Having it configurable would be a nice addition, the default should still be |
@mvalero Can you please test version |
@StefH Sorry for the delayed response. Looks good, I just tested the version from MyGet and it solves the problem I described. Thx a lot. |
@mvalero Thank you very much for verifying. |
When parsing a dynamic expression that contains a real literal like
12.02
or1.0
, the resulting LambdaExpression works differently depending on the machine's configured locale.i.e:
Following literal expression should be parsed to a decimal:
But in my machine (with a german locale) the resulting expression gets the value

321
instead of3.21
->Trying the same in a machine with a US locale it works as expected.
When looking into the TypeHelper#ParseNumber method:
https://github.com/StefH/System.Linq.Dynamic.Core/blob/master/src/System.Linq.Dynamic.Core/Parser/TypeHelper.cs#L498
you can see that
decimal.TryParse(text, out e)
gets called without using theInvariantCulture
which leads to different results depending on the locale of the machine where the code is being executed.When calling
ParseLambda
with3.21m
the expression get's parsed correctly.I'm not sure if that's the expected behavior, but in my opinion both cases should work independently of the locale as the literal in an expression normaly would use
.
as a decimal separator: https://github.com/kahanu/System.Linq.Dynamic/wiki/Dynamic-Expressions#literalsThe text was updated successfully, but these errors were encountered: