Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
If I load an XML file into an XElement object from a String(Reader) and the convert it back to a string, before every newline (\n) a carriage-return (\r) is inserted.
If you run the test program I have attached under Mono 3.2.8 (32-bit Linux) you will get the output
(first line is the ascii encoding of the original XML string, the other two are the output of XElement.ToString(), loaded with different options).
This shows the \r inserted in front of every newline.
This is a regression. In mono 2.10.2 (also 32-bit linux) the output is
as should be expected.
Created attachment 6354 [details]
Test program demonstrating the issue
I'd like to add, that, evne though that may sounds like a minor issue, if you use mono to create and verify XMLDSIG signatures it is a very critical bug.
I just found the reason for the problem. It is not in the parsing but in the String output of XElemen (as inherited by XNode). In this commit https://github.com/mono/mono/commit/7b3f562eabac201f1bd73d34e026ba358d54d6f9 the default value of NewLineHandling in XmlWriterSettings (used by XNode.ToString()) was changed from None to Replace.
According to MSDN, the new behaviour is the correct one, and it was a bug before: