Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2015-03-17 13:56:10 +0300
committerAtsushi Eno <atsushieno@gmail.com>2015-03-17 13:56:10 +0300
commit59267a16c4ab48441f3869e2c80cefd01dd6074c (patch)
treed29269b1913fe468fee8bf968cfbbdf68a8ad252 /mcs/class/System.Xml.Linq
parentee9fd4828959cee349bd11e28cb0dddb84c79bcc (diff)
[xlinq] add test from bug #14856.
Diffstat (limited to 'mcs/class/System.Xml.Linq')
-rw-r--r--mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XElementTest.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XElementTest.cs b/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XElementTest.cs
index 69c3f23f164..b4fd35cac19 100644
--- a/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XElementTest.cs
+++ b/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XElementTest.cs
@@ -29,6 +29,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
+using System.Text;
using System.Threading;
using System.Xml;
using System.Xml.Linq;
@@ -2107,5 +2108,37 @@ namespace MonoTests.System.Xml.Linq
var el = new XElement ("test", (object)content);
Assert.AreEqual ("<test>content1content2</test>", el.ToString ());
}
+
+ [Test] // bug #14856
+ public void PossibleDuplicateNamespaces ()
+ {
+ string testXML =
+ "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
+ "<TestElement xmlns=\"http://www.test.com/TestNamespace\" />";
+
+ using (var stream = new MemoryStream (Encoding.UTF8.GetBytes (testXML)))
+ {
+ var root = XElement.Load (stream);
+ using (var savedStream = new MemoryStream ())
+ {
+ var options = SaveOptions.None;
+
+ // Comment out this line to make it not crash.
+ options |= SaveOptions.OmitDuplicateNamespaces;
+
+ root.Save (savedStream, options);
+ savedStream.Flush ();
+ savedStream.Position = 0;
+
+ var settings = new XmlReaderSettings { IgnoreComments = true, IgnoreWhitespace = true };
+ using (var xmlReader = XmlReader.Create (savedStream, settings))
+ {
+ while (xmlReader.Read ())
+ {
+ }
+ }
+ }
+ }
+ }
}
}