2010-04-18 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Sun, 18 Apr 2010 12:16:29 +0000 (12:16 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Sun, 18 Apr 2010 12:16:29 +0000 (12:16 -0000)
* XamlObjectReader.cs : check constructible type. Remove extra ns node.

* XamlObjectReaderTest.cs : enable working tests and remove invalid
  comment.

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

mcs/class/System.Xaml/System.Xaml/ChangeLog
mcs/class/System.Xaml/System.Xaml/XamlObjectReader.cs
mcs/class/System.Xaml/Test/System.Xaml/ChangeLog
mcs/class/System.Xaml/Test/System.Xaml/XamlObjectReaderTest.cs

index 2c0bfed4d125838e0e01e89270bfaeba61d6937e..8a948e74bdf7178d7e71bf37ddab921401edd435 100644 (file)
@@ -1,3 +1,7 @@
+2010-04-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XamlObjectReader.cs : check constructible type. Remove extra ns node.
+
 2010-04-18  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XamlType.cs : ignore ReferenceConverter which is used for IList<T>.
index 9afefccba0b29a0a248406261e6211d485efb5bc..99bc1b4623f4d3605e6e2fe367726ee9373f9647 100644 (file)
@@ -117,6 +117,8 @@ namespace System.Xaml
                                if (!type.IsPublic)
                                        throw new XamlObjectReaderException (String.Format ("instance type '{0}' must be public and non-nested.", type));
                                root_type = SchemaContext.GetXamlType (instance.GetType ());
+                               if (root_type.ConstructionRequiresArguments && root_type.TypeConverter == null)
+                                       throw new XamlObjectReaderException (String.Format ("instance type '{0}' has no default constructor.", type));
                        }
                        else
                                root_type = XamlLanguage.Null;
@@ -182,7 +184,8 @@ namespace System.Xaml
                                var rootNS = root_type.PreferredXamlNamespace;
                                if (rootNS != XamlLanguage.Xaml2006Namespace)
                                        tmp_ns_decls.Add (new NamespaceDeclaration (rootNS, String.Empty));
-                               tmp_ns_decls.Add (new NamespaceDeclaration (XamlLanguage.Xaml2006Namespace, "x"));
+                               else
+                                       tmp_ns_decls.Add (new NamespaceDeclaration (XamlLanguage.Xaml2006Namespace, "x"));
                                namespaces = new NSList (XamlNodeType.StartObject, tmp_ns_decls.ToArray ()).GetEnumerator ();
                                tmp_ns_decls.Clear ();
 
index 939a8f4a368993736a252b371320b3cbd7b1b50f..ef7028433f8ed49dfc8498a7a09670d9eeb1ec4c 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XamlObjectReaderTest.cs : enable working tests and remove invalid
+         comment.
+
 2010-04-18  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XamlObjectReaderTest.cs : add simple read tests for some types.
index e64badfa90554e44c455385d27f66092cafc32b4..31b5220b94cc8ffeeb2f76e6cbeabcc12884aad5 100644 (file)
@@ -137,12 +137,10 @@ namespace MonoTests.System.Xaml
 
                [Test]
                [ExpectedException (typeof (XamlObjectReaderException))]
-               [Category ("NotWorking")]
                public void ReadNonConstructible ()
                {
-                       var r = new XamlObjectReader (XamlLanguage.String);
                        // XamlType has no default constructor.
-                       r.Read ();
+                       var r = new XamlObjectReader (XamlLanguage.String);
                }
 
                [Test]
@@ -383,9 +381,6 @@ namespace MonoTests.System.Xaml
                }
 
                [Test]
-               // WTF, It does not give XAML namespace, but XamlSerives.Save()
-               // serializes DateTime instance in the XAML namespace.
-               [Category ("NotWorking")]
                public void Read_DateTime ()
                {
                        var obj = new DateTime (2010, 4, 15);