Explorar o código

2010-01-12 Atsushi Enomoto <[email protected]>

	* XmlWriter.cs : handle a corner case for empty string handling 
	  difference between XmlTextWriter and XmlWriter.Create().

	* XmlWriterTests.cs : added a corner case test for empty string handling
	  difference between XmlTextWriter and XmlWriter.Create().


svn path=/trunk/mcs/; revision=149368
Atsushi Eno %!s(int64=16) %!d(string=hai) anos
pai
achega
e703e2593c

+ 5 - 0
mcs/class/System.XML/System.Xml/ChangeLog

@@ -1,3 +1,8 @@
+2010-01-12  Atsushi Enomoto  <[email protected]>
+
+	* XmlWriter.cs : handle a corner case for empty string handling 
+	  difference between XmlTextWriter and XmlWriter.Create().
+
 2009-11-27  Atsushi Enomoto  <[email protected]>
 
 	* NamespaceHandling.cs, XmlWriterSettings.cs, XmlTextWriter2.cs:

+ 1 - 1
mcs/class/System.XML/System.Xml/XmlTextWriter2.cs

@@ -1102,7 +1102,7 @@ namespace Mono.Xml
 
 		public override void WriteString (string text)
 		{
-			if (text == null || text.Length == 0)
+			if (text == null || (text.Length == 0 && !v2))
 				return; // do nothing, including state transition.
 			ShiftStateContent ("Text", true);
 

+ 5 - 0
mcs/class/System.XML/Test/System.Xml/ChangeLog

@@ -1,3 +1,8 @@
+2010-01-12  Atsushi Enomoto  <[email protected]>
+
+	* XmlWriterTests.cs : added a corner case test for empty string handling
+	  difference between XmlTextWriter and XmlWriter.Create().
+
 2009-11-17  Atsushi Enomoto  <[email protected]>
 
 	* XmlConvertTests.cs : add test for DateTimeOffset roundtrip.

+ 15 - 0
mcs/class/System.XML/Test/System.Xml/XmlWriterTests.cs

@@ -559,6 +559,21 @@ namespace MonoTests.System.Xml
 			w.Close ();
 			AssertType.AreEqual ("<hoge />", sw.ToString ());
 		}
+
+		[Test]
+		public void WriteStringDifferentBehavior ()
+		{
+			// Messy implementation difference.
+			// from XmlTextWriter -> <foo />
+			// from XmlWriter.XCreate() -> <foo></foo>
+			var sw = new StringWriter ();
+			var xw = XmlWriter.Create (sw);
+			xw.WriteStartElement ("foo");
+			xw.WriteString ("");
+			xw.WriteEndElement ();
+			xw.Close ();
+			AssertType.AreEqual ("<?xml version='1.0' encoding='utf-16'?><foo></foo>".Replace ('\'', '"'), sw.ToString ());
+		}
 #endif
 
 	}