Author: atsushi
Date: 2008-02-10 09:55:50 -0500 (Sun, 10 Feb 2008)
New Revision: 95377

Modified:
   trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/ChangeLog
   trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/XElement.cs
   trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/XNodeWriter.cs
   trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/ChangeLog
   trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/ExtensionsTest.cs
   trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XNodeWriterTest.cs
Log:
2008-02-10  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * XElement.cs : .ctor(XName,object) was trying to set args as its
          content, not as its own fields.
        * XNodeWriter.cs : check null ns and replace it with "".
          Now that IsEmpty is true, set IsEmpty as false explicitly
          when WriteFullEndElement() is called.

        * ExtensionsTest.cs : disabled Remove() which does not compile now.
        * XNodeWriterTest.cs : added test for Write[Full]EndElement() and
          XElement.IsEmpty.



Modified: trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/ChangeLog
===================================================================
--- trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/ChangeLog   2008-02-10 
13:43:08 UTC (rev 95376)
+++ trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/ChangeLog   2008-02-10 
14:55:50 UTC (rev 95377)
@@ -1,3 +1,11 @@
+2008-02-10  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * XElement.cs : .ctor(XName,object) was trying to set args as its
+         content, not as its own fields.
+       * XNodeWriter.cs : check null ns and replace it with "".
+         Now that IsEmpty is true, set IsEmpty as false explicitly
+         when WriteFullEndElement() is called.
+
 2008-02-09  Miguel de Icaza  <[EMAIL PROTECTED]>
 
        * XNamespace.cs: implement.

Modified: trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/XElement.cs
===================================================================
--- trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/XElement.cs 2008-02-10 
13:43:08 UTC (rev 95376)
+++ trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/XElement.cs 2008-02-10 
14:55:50 UTC (rev 95377)
@@ -47,11 +47,12 @@
 
                XName name;
                XAttribute attr_first, attr_last;
-               bool explicit_is_empty;
+               bool explicit_is_empty = true;
 
                public XElement (XName name, object value)
                {
-                       SetElementValue (name, value);
+                       this.name = name;
+                       Add (value);
                }
 
                public XElement (XElement source)
@@ -398,6 +399,7 @@
                                r.Read ();
                                e.ReadContentFrom (r);
                                r.ReadEndElement ();
+                               e.explicit_is_empty = false;
                        } else {
                                e.explicit_is_empty = true;
                                r.Read ();

Modified: trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/XNodeWriter.cs
===================================================================
--- trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/XNodeWriter.cs      
2008-02-10 13:43:08 UTC (rev 95376)
+++ trunk/mcs/class/System.Xml.Linq/System.Xml.Linq/XNodeWriter.cs      
2008-02-10 14:55:50 UTC (rev 95377)
@@ -223,7 +223,7 @@
                {
                        CheckState ();
 
-                       XNamespace xns = XNamespace.Get (ns);
+                       XNamespace xns = XNamespace.Get (ns ?? String.Empty);
                        XElement el = new XElement (xns.GetName (name));
                        if (current == null) {
                                root.Add (el);
@@ -233,7 +233,7 @@
                                state = XmlNodeType.Element;
                        }
 
-                       FillXmlns (el, prefix, xns);
+                       FillXmlns (el, prefix ?? String.Empty, xns);
 
                        current = el;
                }
@@ -257,8 +257,8 @@
                                throw new InvalidOperationException ("Current 
state is not acceptable for endElement.");
 
                        XElement el = current as XElement;
-                       if (!forceFull && el != null && el.FirstNode == null)
-                               el.IsEmpty = true;
+                       if (forceFull)
+                               el.IsEmpty = false;
 
                        current = current.Parent;
                }

Modified: trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/ChangeLog
===================================================================
--- trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/ChangeLog      
2008-02-10 13:43:08 UTC (rev 95376)
+++ trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/ChangeLog      
2008-02-10 14:55:50 UTC (rev 95377)
@@ -1,3 +1,9 @@
+2008-02-10  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * ExtensionsTest.cs : disabled Remove() which does not compile now.
+       * XNodeWriterTest.cs : added test for Write[Full]EndElement() and
+         XElement.IsEmpty.
+
 2008-01-30  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * XNodeReaderTest.cs : test for bug #356522, the third case.

Modified: trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/ExtensionsTest.cs
===================================================================
--- trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/ExtensionsTest.cs      
2008-02-10 13:43:08 UTC (rev 95376)
+++ trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/ExtensionsTest.cs      
2008-02-10 14:55:50 UTC (rev 95377)
@@ -37,12 +37,14 @@
        [TestFixture]
        public class ExtensionsTest
        {
+/* It does not compile probably due to bug #359733.
                [Test]
                public void Remove ()
                {
                        XDocument doc = XDocument.Parse 
("<root><foo/><bar/><baz/></root>");
-                       doc.Root.Nodes ().Remove ();
+                       doc.Root.Nodes ().Remove<XNode> ();
                        Assert.IsNull (doc.Root.FirstNode, "#1");
                }
+*/
        }
 }

Modified: 
trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XNodeWriterTest.cs
===================================================================
--- trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XNodeWriterTest.cs     
2008-02-10 13:43:08 UTC (rev 95376)
+++ trunk/mcs/class/System.Xml.Linq/Test/System.Xml.Linq/XNodeWriterTest.cs     
2008-02-10 14:55:50 UTC (rev 95377)
@@ -39,6 +39,22 @@
        public class XNodeWriterTest
        {
                [Test]
+               public void WriteEmptyElements ()
+               {
+                       var doc = new XDocument ();
+                       XmlWriter w = doc.CreateWriter ();
+                       w.WriteStartElement ("root");
+                       w.WriteStartElement ("foo");
+                       w.WriteEndElement ();
+                       w.WriteStartElement ("bar");
+                       w.WriteFullEndElement ();
+                       w.WriteEndElement ();
+                       w.Close ();
+                       Assert.IsTrue (((XElement) doc.Root.FirstNode).IsEmpty, 
"#1");
+                       Assert.IsFalse (((XElement) doc.Root.LastNode).IsEmpty, 
"#2");
+               }
+
+               [Test]
                public void CreateWriter1 ()
                {
                        string xml = "<root><foo/><bar></bar><baz a='v' 
xmlns='urn:foo' xmlns:x='urn:x'><x:ext xmlns=''>test</x:ext><!-- comment -->  
<?some-pi some-data?></baz></root>";

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to