runtime: [Linux] [CoreClr] Inconsistent results during value formatting
I have several tests, passed ok under windows and under linux with mono runtime, but same tests failed with the linux coreclr runtime:
test
CultureInfo culture = new CultureInfo("en-US");
Assert.AreEqual("0.00", 0.0.ToString("n", culture));
result
Expected: 0.00
Actual: 0.000
test
CultureInfo culture = new CultureInfo("en-US");
Assert.AreEqual("0.00", 0.0.ToString("f", culture));
result
Expected: 0.00
Actual: 0.000
test
CultureInfo culture = new CultureInfo("en-US");
Assert.AreEqual("0.00 %", 0.0.ToString("p", culture));
result
Expected: 0.00 %
Actual: 0.000%
test
CultureInfo culture = new CultureInfo("en-US");
Assert.AreEqual("0.0 %", 0.0.ToString("p1", culture));
result
Expected: 0.0 %
Actual: 0.0%
test
double negativeNumber = -38456.123456789123456789;
CultureInfo culture = new CultureInfo("en-US");
Assert.AreEqual("($38,456.1)", negativeNumber.ToString("c1", culture));
result
Expected: ($38,456.1)
Actual: -$38,456.1
test
CultureInfo culture = new CultureInfo("de-DE");
DateTime date = new DateTime(2015, 3, 9, 15, 43, 28); // 9 Mar 2015
Assert.AreEqual("09.03.2015", date.ToString(culture.DateTimeFormat.ShortDatePattern, culture));
result
Expected: 09.03.2015
Actual: 9.3.2015
test
CultureInfo culture = new CultureInfo("ru-RU");
DateTime date = new DateTime(2015, 3, 9, 15, 43, 28); // 9 Mar 2015
Assert.AreEqual("9 марта 2015 г.", date.ToString(culture.DateTimeFormat.LongDatePattern, culture));
result
Expected: 9 марта 2015 г.
Actual: Понедельник, 9 марта 2015 г.
Environment
uname -a
Linux debianDNX 3.16.0-4-amd64 dotnet/coreclr#1 SMP Debian 3.16.7-ckt11-1+deb8u3 (2015-08-04) x86_64 GNU/Linux
dnvm list
Active Version Runtime Arch OperatingSystem Alias
------ ------- ------- ---- --------------- -----
1.0.0-beta6 mono linux/darwin
* 1.0.0-rc1-15838 coreclr x64 linux default
1.0.0-beta8-15618 mono linux/darwin
1.0.0-beta8-15530 mono linux/darwin
1.0.0-rc1-15838 mono linux/darwin
1.0.0-beta8-15618 coreclr x64 linux
1.0.0-beta7 mono linux/darwin
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 21 (17 by maintainers)
@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.
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.