-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[Linux] [CoreClr] Inconsistent results during value formatting #4565
Comments
cc: @tarekgh, @steveharter |
For Linux and MacOX this is expected as we are returning raw locale data from the underlying framework which is ICU (International Components for Unicode) which is then then used by coreclr to format numbers, dates, etc. That raw data is different than Windows (and mono). ICU obtains its values from CLDR (Common Locale Data Repository). There are also differences in that data between releases of ICU\CLDR, just like there's differences between Windows 8.1 and 10 in some of their locale information. Windows has fixed data for common locales but does 'import' some of the less common locale data from CLDR. Note that ICU\CLDR has two settings for currency - regular and 'accounting' where accounting typically uses parenthesis instead of the negative sign for negative values. However, Windows only one setting for currency. The behavior of coreclr currently uses the 'regular' setting so no parenthesis by default, unlike some locales like en-US which use parenthesis by default. |
We also use ICU/CLDR to get the short and long date patterns for a culture. For LongDatePattern, we use the "full" and "long" date format, with the "full" format being the default. For "ru-RU", you can see the full format is For ShortDatePattern, we use the "short" and "medium" formats from CLDR, but we also use the "yMd" skeleton, with the "yMd" skeleton being the default. For "de-DE", you can see the "yMd" skeleton is In short, until Windows and CLDR are in 100% agreement, there will always be differences between the culture data on Windows and Linux. Which means if you are dependent on this data (like your tests are), then you will have to switch depending on what platform you are running on. In our tests, we use This issue is pretty much a dupe of https://github.com/dotnet/corefx/issues/3698. |
@eerhardt FWIW as a native German speaker, having Maybe it'd be better to default to the |
I think we are seeing similar issue with Serbian cultures too dotnet/coreclr#3616. I am wondering why ICU is not picking the CLDR data? |
The But I agree that using the Maybe the right thing to do here is to use |
@eerhardt you're right, I misread the To be honest, using the |
Logged dotnet/coreclr#1736 for this specific issue. |
Could you consider my tests from compatibility/consistence point of view? When we (users) develop a software using aspvnext, we expected to get most similar results (better the same results) running against different OS and different runtimes. Both, NET framework and runtime are abstraction layers intended to leverage differences in underlying OS, libraries, hardware etc. That's why it would be great, if tests similar to mine pass ok against different runtimes and OS, without writing any spaghetti code. |
See @ellismg's comment on https://github.com/dotnet/corefx/issues/3698. Windows' locale data deviates from ICU/CLDR's in some cases. There are some cases where Windows uses the CLDR data and they match. But there are cases where it doesn't - for example if the Windows team felt it was "wrong", or if there are geopolitical issues, or if there would be compatibility concerns with earlier versions of Windows, etc. The only way to ensure the same culture data on other platforms would be to take Windows' culture data and ship it with .NET, which we decided not to do for obvious reasons such as maintainability, updatability, package size, etc. |
And what about the other way around; match CoreCLR on Windows with CoreCLR on other platforms, rather than with the full CLR on Windows? Not saying it's a good option or even feasible, just curious if it was considered. Is ICU/CLDR available for use on Windows? |
ICU is available for use on Windows for both 32 and 64 bit. I'm not sure if @ellismg considered using ICU on Windows for CoreCLR, but I don't think the approach would be correct. It would create a new dependency on Windows, and some would consider the dependency needless, since culture data already exists on Windows. |
Right, we need to have the culture data consistent with the OS to avoid undesirable behaviors. also as mentioned we don't have to add more dependency when running on Windows. in general I expect moving forward the data on Windows and data on ICU will converge and the differences will be very little. |
That sounds good to me. I was just sort of playing "Devil's advocate", because the most obvious way to align behavior would just be to use the same library, and we hadn't mentioned that. It would also probably have bad implications for debugging Universal apps, or other Windows-only things, which would be using the Windows culture data. |
Not a lot to add, but you might want to look at http://blogs.msdn.com/b/shawnste/archive/2015/08/28/locale-culture-data-churn.aspx |
For folks like @mviorno that need consistent data across platforms, it seems like the correct long term direction is for someone to spend time investing in the following:
I don't think there are technical reasons preventing the following from happening. I suspect a solution looks like setting up a way to our build with FEATURE_COREFX_GLOBALIZATION as true and then work to decouple the "Unix" portions of the code with the "ICU" parts of the code (today FEATURE_COREFX_GLOBALIZATION means use the version of globalization which has less ties to the runtime (it's a fork of the code we use in .NET Native) and then PLATFORM_UNIX means go to ICU). Having said that, I don't think that we (Microsoft) are willing to invest in this area. As Shawn, Tarek and Eric said, our general philosophy is to use the underlying OS when possible. We also don't want to get in the game of statically linking against our dependencies. However, if there were patches or PR that would make the code more amenable to this, we would definitely consider them, amusing they don't impact existing scenarios. Like the FreeBSD port, I expect this would need to be a largely community supported thing, we would try not to break things, but we wouldn't spend a ton of resources in the area. If there's someone who is passionate about it, I'm more than happy to provide guidance and code reviews. My e-mail should be easy enough to find (it's in every commit and should be public on GitHub) if someone wants to get in touch. For now, I'm going to close this issue. |
@ellismg
Is there any workaround for that issue? |
Have you tried using the InvariantCulture to store the numbers into the database? (Side question: why are you serializing numbers into strings to store them in a DB?) If you use the InvariantCulture, it will be the same across all machines. Then when parsing the numbers back - use the InvariantCulture as well. Only use the CurrentCulture for displaying to the user. |
@effyteva The applications cannot assume the globalization data not changing even on the same OS. even now Windows is changing its data to use CLDR. if you want to use consistent data across the OS and OS versions then use invariant culture. We have invariant culture for this purpose. |
Thanks guys, updating all our Parse methods to InvariantCulture solved this. |
- Pull Request Runtime\#1734 - This change corrects a cut-and paste typo with a previous commit. - Includes test case Runtime_1104.cs
I have several tests, passed ok under windows and under linux with mono runtime, but same tests failed with the linux coreclr runtime:
test
result
test
result
test
result
test
result
test
result
test
result
test
result
Environment
The text was updated successfully, but these errors were encountered: