2006-04-05 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 5 Apr 2006 13:36:56 +0000 (13:36 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Wed, 5 Apr 2006 13:36:56 +0000 (13:36 -0000)
* XmlWriter.cs : Create(StringBuilder,XmlWriterSettings) was missing
  settings argument to pass another .ctor().
* XmlWriterSettings.cs : set_NewLineChars() should reject null.

* XmlWriterSettingsTest.cs : added tests on set_Encoding(),
  set_NewLineChars() and OmitXmlDeclaration.

svn path=/trunk/mcs/; revision=59061

mcs/class/System.XML/System.Xml/ChangeLog
mcs/class/System.XML/System.Xml/XmlWriter.cs
mcs/class/System.XML/System.Xml/XmlWriterSettings.cs
mcs/class/System.XML/Test/System.Xml/ChangeLog
mcs/class/System.XML/Test/System.Xml/XmlWriterSettingsTests.cs

index be6155f898970fd91866470c171fa68d3aeb5bc5..2a29b9050aa7ea63498f742278819a9b216b2859 100644 (file)
@@ -1,3 +1,9 @@
+2006-04-05  Atsushi Enomoto <atsushi@ximian.com>
+
+       * XmlWriter.cs : Create(StringBuilder,XmlWriterSettings) was missing
+         settings argument to pass another .ctor().
+       * XmlWriterSettings.cs : set_NewLineChars() should reject null.
+
 2006-04-03     Boris Kirzner <borisk@mainsoft.com>
        * XmlException.cs: fix .net soap serialization compatibility.
 
index 55092049d2b975c9294d210d28496c90995adc25..6e95833c5d2f89020cdc95aa098c15930edbd77e 100644 (file)
@@ -116,35 +116,28 @@ namespace System.Xml
                        return Create (builder, null);
                }
 
-               [MonoTODO ("NewLineHandling/OutputMethod")]
                public static XmlWriter Create (Stream stream, XmlWriterSettings settings)
                {
-                       // FIXME: this might result in encoding null reference
                        Encoding enc = settings != null ? settings.Encoding : Encoding.UTF8;
                        return Create (new StreamWriter (stream, enc), settings);
                }
 
-               [MonoTODO ("NewLineHandling/OutputMethod")]
                public static XmlWriter Create (string file, XmlWriterSettings settings)
                {
-                       // FIXME: this might result in encoding null reference
                        Encoding enc = settings != null ? settings.Encoding : Encoding.UTF8;
                        return Create (new StreamWriter (file, false, enc), settings);
                }
 
-               [MonoTODO ("NewLineHandling/OutputMethod")]
                public static XmlWriter Create (StringBuilder builder, XmlWriterSettings settings)
                {
-                       return Create (new StringWriter (builder), null);
+                       return Create (new StringWriter (builder), settings);
                }
 
-               [MonoTODO ("NewLineHandling/OutputMethod")]
                public static XmlWriter Create (TextWriter writer, XmlWriterSettings settings)
                {
                        return CreateTextWriter (writer, settings);
                }
 
-               [MonoTODO ("NewLineHandling/OutputMethod")]
                public static XmlWriter Create (XmlWriter writer, XmlWriterSettings settings)
                {
                        if (settings == null)
index 7fd5522e7d35cfd10cb8819c4fad9925c0c81b98..704c15d7874e5de9ff76788ea145bff2fa0e0037 100644 (file)
@@ -130,7 +130,11 @@ namespace System.Xml
                // It affects only on XmlTextWriter
                public string NewLineChars {
                        get { return newLineChars; }
-                       set { newLineChars = value; }
+                       set {
+                               if (value == null)
+                                       throw new ArgumentNullException ("value");
+                               newLineChars = value;
+                       }
                }
 
                // It affects only on XmlTextWriter
index cf4ad96efd00870981b0dfceb17eb05ec0d84660..c9f74366748fcabe4e2fed86b46f5382d04aef81 100644 (file)
@@ -1,3 +1,8 @@
+2006-04-05  Atsushi Enomoto <atsushi@ximian.com>
+
+       * XmlWriterSettingsTest.cs : added tests on set_Encoding(),
+         set_NewLineChars() and OmitXmlDeclaration.
+
 2006-03-08  Atsushi Enomoto <atsushi@ximian.com>
 
        * XmlReaderCommonTests.cs : Added tests for ReadContentAsString() and
index 4cf9733c37454614e386a23f3cdeb6797c894ca9..276d5b6215ad9edaa694777c681dfb80394837b9 100644 (file)
@@ -137,6 +137,37 @@ namespace MonoTests.System.Xml
                        w.Close ();
                        AssertEquals (output, sw.ToString ());
                }
+
+               [Test]
+               public void SetEncodingNull ()
+               {
+                       // null is allowed.
+                       new XmlWriterSettings ().Encoding = null;
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void NewLineCharsNull ()
+               {
+                       new XmlWriterSettings ().NewLineChars = null;
+               }
+
+               [Test]
+               public void CreateOmitXmlDeclaration ()
+               {
+                       StringBuilder sb = new StringBuilder ();
+                       // Even if XmlWriter is allowed to write fragment,
+                       // DataContractSerializer never allows it to write
+                       // content in contentOnly mode.
+                       XmlWriterSettings settings = new XmlWriterSettings ();
+                       settings.OmitXmlDeclaration = true;
+                       //settings.ConformanceLevel = ConformanceLevel.Fragment;
+                       XmlWriter w = XmlWriter.Create (sb, settings);
+                       w.WriteStartElement ("root");
+                       w.WriteEndElement ();
+                       w.Flush ();
+                       AssertEquals ("<root />", sb.ToString ());
+               }
        }
 }
 #endif