You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You will find out that num1 == 0 (!!!!!). This is caused by a bug in GetStringValue method in JsonFileConfigStore which is using ToString() to convert back the read value into a string. This ToString() takes Culture into account, and so it converts 2.5 to "2,5" (notice the comma) in Cultures with that decimal separator (Spain, as in my case). Afterwards, the ValueHandlerParseValue method fails in the TryParse part because of that, and returns the default value (0 in this case).
This is easily fixed in JsonFileConfigStore changing:
I experience the same problem. My culture locale is "de-DE" and fractioned values will fail to parse properly. @aloneguid would you please apply the PR and publish a new version?
If you use a JSON store, you will face this problem with a config file like this:
If you execute this trivial code:
You will find out that
num1 == 0
(!!!!!). This is caused by a bug inGetStringValue
method inJsonFileConfigStore
which is usingToString()
to convert back the read value into a string. ThisToString()
takes Culture into account, and so it converts 2.5 to"2,5"
(notice the comma) in Cultures with that decimal separator (Spain, as in my case). Afterwards, theValueHandler
ParseValue
method fails in theTryParse
part because of that, and returns the default value (0 in this case).This is easily fixed in
JsonFileConfigStore
changing:to:
Can you please integrate this into the library? It is a safe change IMHO. And this is a really nasty bug...
As a temporary workaround, if you put:
Then the parser works well... and the value is converted to float
The text was updated successfully, but these errors were encountered: