Closed thibautvdu closed 5 years ago
Indeed does the Convert.ChangeType call inside the Parse.Utilities.Conversion.ConvertTo
method does not handle invariant formatting of the number although the Json class does encode them with the invariant culture.
Depending on how eager you are to try to solve this issue without waiting for a commit to the repository you might take a look at line 57 and line 68 in the Conversion.cs
file and add the invariant culture to the Convert.ChangeType
calls inside the method to get it looking like
return (T) Convert.ChangeType(value, typeof(T), System.Globalization.CultureInfo.InvariantCulture);
I'll prepare the changes but cannot tell when I have the commit ready to be pushed to the main repository as I don't want to rush it without adding tests to the project and check if it does not break anything else.
@TheFanatr I have a fix for this issue prepared and added a test to the Parse.Test solution.
I'm a bit confused though as you mentioned that in Debug|Any CPU configuration the internals of the Parse assembly should be available to Parse.Test but I still need to add
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Parse.Test")]
somewhere to the Parse assembly code base to get the Parse.Test to compile.
Did I miss anything to get access of the internals inside test methods?
I've prepared a fix for this issue a while ago and finally got the time to put it up as a pull request. @thibautvdu Would you mind to check whether the commit mentioned above does fix this issue for you (I've tested it with german locale which should behave similar to a french one and want to have it validated before I merge it)
Hello everyone,
I'm using Parse in a Xamarin form application. Everything was working fine until I tried it on a smartphone with a French locale. Here is the issue:
Calling the previous code with T = float fails only on my French phone because the floats in my mongo database are using the invariant culture ' 1.0 ' instead of the french ' 1,0 '. Here is the exception:
Is there anyway to tell Parse to stick up with the invariant culture when Parsing ? Also, I don't remind having issue before adding the Newtonsoft json nuget in my project. Did Parse just pick it up because it saw it was available ?
Any help would be appreciated. As a quick and dirty fix, I'm currently catching the exception, retrieving the value as a string and then parsing it manually.
Many thanks,
Thibaut