Topic: OnlineMapsXML invariant culture fix

Hi !

This is not a bug request, rather a small evolution request to update OnlineMapsXML.cs in order to use invariantCulture while parsing some types (i.e Doubles, by example) that causes exception if not done.

The modification concern Lines 628-630 in \Infinity Code\Online Maps\Scripts\XML\OnlineMapsXML.cs
Would it be possible to change :

[...]
        try
        {
            MethodInfo method = OnlineMapsReflectionHelper.GetMethod(underlyingType, "Parse", new[] {typeof (string)});
            if (method != null) obj = (T)method.Invoke(null, new[] { value });
        }
[...]

TO

[...]
        try
        {
            MethodInfo method = OnlineMapsReflectionHelper.GetMethod(underlyingType, "Parse", new Type[] { typeof(string), typeof(CultureInfo) });
            CultureInfo c = CultureInfo.InvariantCulture;
            if (method != null) obj = (T)method.Invoke(null, new object[] { value, c });
        }
[...]

..This would prevent us to patch OnlineMapsXML code every time we update the pluggin wink

Thanks !

Re: OnlineMapsXML invariant culture fix

Hello.

Thanks for your modification.
The next version of Online Maps will contain this.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: OnlineMapsXML invariant culture fix

Nice ! Thanks !

Re: OnlineMapsXML invariant culture fix

Hello,

Thanks for this fix, it saved me some time, but it's not the only one in the plugin now.
In Unity 2018.3, the default conversion is now Culture.CurrentCulture !!!
I'm French and all floating or double values are parsed with an expected "," by default ... sad sad
I need to patch your plugin to use InvariantCulture each time a Double is parsed.
Could you take care of that changement from Unity 2018.3 in your next versions please ?
Thanks

Re: OnlineMapsXML invariant culture fix

Hello.

I did not know about it.
Please send a link to the source of this information.

If this is true, it will be a big pain for all developers of assets.

The best way to work around this, at least for now:

Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

6 (edited by RaphBen 2018-10-24 09:21:11)

Re: OnlineMapsXML invariant culture fix

Ok it's just when changing from Unity 2017 to 2018, language changed from .Net 3.5.x to .Net 4.x
and automatically, System.Globalization.CultureInfo.CurrentCulture change from "en-US" to "fr-FR" for us ...
But yes a solution is to force System.Globalization.CultureInfo.CurrentCulture to Invariant.
Thanks