Problems with localization and dynamic parsing of values


I've just discovered strong evidence that there may be problems with parsing WPFix expressions on different locales than they were written under. That is, whereas regular xaml is compiled to baml and removes all locale-dependent information in the process, when we dynamically parse for example the literal "1.0" on a system that represents decimals with a comma, we get an exception that "1.0" cannot be interpreted as a double (at first this exception really had me stumped!).
It seems to me an ideal solution would be some static means of initializing the WPFix engine with a locale that should apply to all conversions that occur from dynamic parsing of WPFix expressions, defaulting to US English, however I am not familiar enough with the WPFix architecture (or the dynamic parsing mechanism) to know how possible/easy this would be so am conveying this as an issue. I will look into this myself when I have some free time and post anything I discover.


chaiguy1337 wrote Nov 26, 2008 at 1:56 AM

Just to be clear, the problems arise whether or not the application using WPFix utilizes localization or not. I simply meant localization of the host operating system.

chaiguy1337 wrote Nov 27, 2008 at 3:48 AM

Ok, here's what I did: I replaced every call in Dynamic.cs to TryParse() with the culture-invariant form like so:

double.TryParse( text, NumberStyles.Number, cultureFormatProvider, out d )

where cultureFormatProvider is:

internal static IFormatProvider cultureFormatProvider = CultureInfo.InvariantCulture;

I will post back to let you know if it works.

chaiguy1337 wrote Nov 28, 2008 at 12:48 AM

So far it looks like it worked!!

wrote Feb 12, 2013 at 10:12 PM