+2008-02-10 Atsushi Enomoto <atsushi@ximian.com>
+
+ * 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 <miguel@novell.com>
* XNamespace.cs: implement.
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)
r.Read ();
e.ReadContentFrom (r);
r.ReadEndElement ();
+ e.explicit_is_empty = false;
} else {
e.explicit_is_empty = true;
r.Read ();
{
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);
state = XmlNodeType.Element;
}
- FillXmlns (el, prefix, xns);
+ FillXmlns (el, prefix ?? String.Empty, xns);
current = el;
}
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;
}
+2008-02-10 Atsushi Enomoto <atsushi@ximian.com>
+
+ * 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 <atsushi@ximian.com>
* XNodeReaderTest.cs : test for bug #356522, the third case.
[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");
}
+*/
}
}
[TestFixture]
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 ()
{