Bug 29935 - XAttribute.ToString() outputs wrong result if attribute contains namespace
Summary: XAttribute.ToString() outputs wrong result if attribute contains namespace
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.XML ()
Version: 4.0.0
Hardware: PC All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-05-11 08:51 UTC by eb1
Modified: 2015-05-27 07:30 UTC (History)
4 users (show)

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

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 eb1 2015-05-11 08:51:08 UTC
The following code snippet produces a wrong result:

	const string xml ="<?xml version='1.0' encoding='utf-8'?><lift xmlns:test='http://test.example.com'></lift>";
	var fileName = Path.GetTempFileName();
	File.WriteAllText(fileName, xml);
	var doc = XDocument.Load(fileName);
	Console.WriteLine(doc.Root.Attributes().Select(s => s.ToString()).First());

The expected output is

but Mono instead outputs

This happens with all Mono versions including 4.0.1.
Comment 1 eb1 2015-05-11 09:34:56 UTC
Fix for the 4.0 branch in PR #1787
Comment 2 Alexander Köplinger 2015-05-11 09:37:41 UTC
fyi, I just verified this produces the expected output with Mono from master.
Comment 3 Marek Safar 2015-05-18 03:38:56 UTC
Closing as it's already fixed in master
Comment 4 Abhishek 2015-05-27 07:30:04 UTC
I have checked this issue with the latest master Mono: MonoFramework-MDK- Now this issue is working fine .Here is the screeencast for the same:

Hence closing this issue.