2010-05-17 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 17 May 2010 12:58:18 +0000 (12:58 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Mon, 17 May 2010 12:58:18 +0000 (12:58 -0000)
* XamlWriterStateManager.cs : on object writer, reject more write
  namespace order. (I should really unuse it for object writer.)
* XamlObjectWriter.cs : result is set at end object. Do not reject
  non-collection in this writer. I'm totally no idea why it should
  not do so though.

* XamlObjectWriterTest.cs : fix and enable some tests.

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

mcs/class/System.Xaml/System.Xaml/ChangeLog
mcs/class/System.Xaml/System.Xaml/XamlObjectWriter.cs
mcs/class/System.Xaml/System.Xaml/XamlWriterStateManager.cs
mcs/class/System.Xaml/Test/System.Xaml/ChangeLog
mcs/class/System.Xaml/Test/System.Xaml/XamlObjectWriterTest.cs

index e68b84daf6a932629d36652ac59e146243aa74f2..ef12e8ffb087b35a6abc807e56a3d963301ff2f4 100644 (file)
@@ -1,3 +1,11 @@
+2010-05-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XamlWriterStateManager.cs : on object writer, reject more write
+         namespace order. (I should really unuse it for object writer.)
+       * XamlObjectWriter.cs : result is set at end object. Do not reject
+         non-collection in this writer. I'm totally no idea why it should
+         not do so though.
+
 2010-04-26  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XamlMember.cs : hack GetHashCode().
index 19b98ffa2340d392800012f6ba425e651f41639a..c4abc3d322b311fb988a20e023fbe969b1247fb2 100644 (file)
@@ -188,6 +188,8 @@ namespace System.Xaml
                        var obj = objects.Pop ();
                        if (members.Count > 0)
                                contents.Add (obj);
+                       if (objects.Count == 0)
+                               result = obj;
                }
 
                public override void WriteGetObject ()
@@ -195,8 +197,9 @@ namespace System.Xaml
                        manager.GetObject ();
 
                        var xm = members.Peek ();
-                       if (!xm.Type.IsCollection)
-                               throw new XamlObjectWriterException (String.Format ("WriteGetObject method can be invoked only when current member '{0}' is of collection type", xm.Name));
+                       // see GetObjectOnNonNullString() test
+                       //if (!xm.Type.IsCollection)
+                       //      throw new XamlObjectWriterException (String.Format ("WriteGetObject method can be invoked only when current member '{0}' is of collection type", xm.Name));
 
                        var obj = xm.Invoker.GetValue (objects.Peek ());
                        if (obj == null)
@@ -287,8 +290,6 @@ namespace System.Xaml
                {
                        objects.Push (obj);
                        object_instantiated = true;
-                       if (objects.Count == 1)
-                               result = objects.Peek ();
                        arguments.Clear ();
                        factory_method = null;
                }
index b5d00051fe72d7f29e484c49fab8cb1a9af78bbd..295a20a780c9199ab9814df0860bcea3742e808b 100644 (file)
@@ -168,7 +168,7 @@ namespace System.Xaml
 
                public void Namespace ()
                {
-                       if (!allow_ns_at_value && state == XamlWriteState.ValueWritten)
+                       if (!allow_ns_at_value && (state == XamlWriteState.ValueWritten || state == XamlWriteState.ObjectStarted))
                                throw CreateError (String.Format ("Namespace declarations cannot be written at {0} state", state));
                        ns_pushed = true;
                }
index 28744c53fe3d16d0a2dc54bbdd7ae26ba91683ce..b1b823eb705a39d3dc4365b1029db0191baaca9e 100644 (file)
@@ -1,3 +1,7 @@
+2010-05-17  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XamlObjectWriterTest.cs : fix and enable some tests.
+
 2010-04-26  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XamlObjectReaderTest.cs : more test use cases.
index f709ac6011efff0768dca5f41bcb41ddf8e99979..7c51499652b799dba4c57dc4d0746326283b602a 100644 (file)
@@ -512,7 +512,6 @@ namespace MonoTests.System.Xaml
 
                [Test]
                [ExpectedException (typeof (XamlObjectWriterException))] // This is also very different, requires exactly opposite namespace output manner to XamlXmlWriter (namespace first, object follows).
-               [Category ("NotWorking")]
                public void StartMemberAfterNamespace ()
                {
                        var xw = new XamlObjectWriter (sctx, null);
@@ -592,14 +591,15 @@ namespace MonoTests.System.Xaml
                }
 
                [Test]
-               // String is not treated as a collection on XamlXmlWriter, while this XamlObjectReader does.
-               [Category ("NotWorking")]
+               // String is not treated as a collection on XamlXmlWriter, while this XamlObjectWriter does.
                public void GetObjectOnNonNullString ()
                {
                        var xw = new XamlObjectWriter (sctx, null);
                        xw.WriteStartObject (xt3);
+                       Assert.IsNull (xw.Result, "#1");
                        xw.WriteStartMember (xt3.GetMember ("TestProp3"));
                        xw.WriteGetObject ();
+                       Assert.IsNull (xw.Result, "#2");
                }
 
                [Test]
@@ -611,8 +611,6 @@ namespace MonoTests.System.Xaml
                        xw.WriteStartMember (new XamlMember (typeof (Foo).GetProperty ("Bar"), sctx));
                        xw.WriteGetObject ();
                        xw.Close ();
-                       // FIXME: enable it once we got generic type output fixed.
-                       //Assert.AreEqual (xml, sw.ToString ().Replace ('"', '\''), "#1");
                }
 
                [Test]