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:
authorMarek Safar <marek.safar@gmail.com>2014-08-29 14:16:24 +0400
committerMarek Safar <marek.safar@gmail.com>2014-08-29 14:16:24 +0400
commit38c3874627b632c0fbd3809891bd43df7e3cac68 (patch)
tree9cab04d6bcc2405e7a474b88184d35f57bc54ffc /mcs/class/System.Xml.Linq
parentb2d61a33a63e06a128d482c29e861452b26759bf (diff)
parentacb0cc0d7d55fd862eb593a6cb00832db1f404df (diff)
Merge pull request #1242 from esdrubal/xelement
Fixes XContainer attempt to create a XNode from a null value.
Diffstat (limited to 'mcs/class/System.Xml.Linq')
-rw-r--r--mcs/class/System.Xml.Linq/System.Xml.Linq/XContainer.cs3
-rw-r--r--mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XElementTest.cs8
2 files changed, 11 insertions, 0 deletions
diff --git a/mcs/class/System.Xml.Linq/System.Xml.Linq/XContainer.cs b/mcs/class/System.Xml.Linq/System.Xml.Linq/XContainer.cs
index af5fd976403..25e967583cb 100644
--- a/mcs/class/System.Xml.Linq/System.Xml.Linq/XContainer.cs
+++ b/mcs/class/System.Xml.Linq/System.Xml.Linq/XContainer.cs
@@ -72,6 +72,9 @@ namespace System.Xml.Linq
foreach (object o in XUtil.ExpandArray (content))
{
+ if (o == null)
+ continue;
+
if (!OnAddingObject (o, false, last, false))
{
var node = XUtil.ToNode (o);
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 fd5cd82bf94..70616aa0da0 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
@@ -2097,5 +2097,13 @@ namespace MonoTests.System.Xml.Linq
Assert.AreEqual (xe.Content.ToString (), "<Data />", "#3");
}
#endif
+
+ [Test] // Bug #20151
+ public void XElementFromArrayWithNullValuesAsObject ()
+ {
+ string[] content = {null, "content1", null, "content2"};
+ var el = new XElement ("test", (object)content);
+ Assert.AreEqual ("<test>content1content2</test>", el.ToString ());
+ }
}
}