Bug 3634 - XElement with decimal date get formatted has wrong ToString representation
Summary: XElement with decimal date get formatted has wrong ToString representation
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.XML ()
Version: 2.10.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-02-24 10:46 UTC by DesDesDes
Modified: 2012-03-08 04:27 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Unit test showing the problem (326 bytes, application/octet-stream)
2012-02-24 10:46 UTC, DesDesDes
Test which shows the bug with XElement in dutch culture (915 bytes, text/plain)
2012-02-27 14:32 UTC, DesDesDes

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description DesDesDes 2012-02-24 10:46:41 UTC
Created attachment 1417 [details]
Unit test showing the problem

On a box which has a default decimal separator which is a comma the ToString() function on XElement returns a a value containing a comma. This is wrong according to the XML spec and also a different behavior as MS.NET has.

Using a dutch mac with OS 10.7.3 and mono 2.10.9.
Comment 1 Miguel de Icaza [MSFT] 2012-02-24 15:40:50 UTC
I set my computer to have the thousand separator be "." and the decimal separator to be "," and Console.WriteLine ("{0}", 54545.0); will be printed as:


But the XElement is still rendered as 

Comment 2 DesDesDes 2012-02-27 14:31:13 UTC
Changing the decimal separator does not resolve the issue on my computer so will probably will not help on reproducing the issue on your computer. 

I've looked into this issue a bit further and it looks like it is related to the System.Threading.Thread.CurrentThread.CurrentCulture. If I set it to CultureInfo.InvariantCulture the issue seems to be resolved. By default this is set to the "nl-NL" culture. This culture setting does not seem to be affected by the thousand separator and decimal separator set on the computer.

You can probably reproduce the behavior by setting the System.Threading.Thread.CurrentThread.CurrentCulture to CultureInfo.GetCultureInfoByIetfLanguageTag("nl-NL"). I've attached the a new test which demonstrates the behavior.
Comment 3 DesDesDes 2012-02-27 14:32:41 UTC
Created attachment 1425 [details]
Test which shows the bug with XElement in dutch culture
Comment 4 Atsushi Eno 2012-03-08 04:27:18 UTC
Fixed in git master d1761d0. Thanks for the report.