implement ValueSerializer.
authorAtsushi Eno <atsushieno@gmail.com>
Wed, 14 Apr 2010 05:54:03 +0000 (05:54 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Wed, 14 Apr 2010 05:54:03 +0000 (05:54 -0000)
svn path=/trunk/mcs/; revision=155353

14 files changed:
mcs/class/System.Xaml/ChangeLog
mcs/class/System.Xaml/System.Windows.Markup/ChangeLog
mcs/class/System.Xaml/System.Windows.Markup/ValueSerializer.cs
mcs/class/System.Xaml/System.Xaml/ChangeLog
mcs/class/System.Xaml/System.Xaml/XamlDirective.cs
mcs/class/System.Xaml/System.Xaml/XamlLanguage.cs
mcs/class/System.Xaml/System.Xaml/XamlMember.cs
mcs/class/System.Xaml/System.Xaml/XamlType.cs
mcs/class/System.Xaml/System.Xaml_test.dll.sources
mcs/class/System.Xaml/Test/System.Windows.Markup/ChangeLog
mcs/class/System.Xaml/Test/System.Windows.Markup/ValueSerializerTest.cs [new file with mode: 0644]
mcs/class/System.Xaml/Test/System.Xaml/ChangeLog
mcs/class/System.Xaml/Test/System.Xaml/XamlLanguageTest.cs
mcs/class/System.Xaml/Test/System.Xaml/XamlTypeTest.cs

index 7a73145579ab1719e659f601e3ddb2858be3fc49..e9518c52f3985b1a44cc57c615a20f87b1036056 100644 (file)
@@ -1,3 +1,7 @@
+2010-04-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * System.Xaml_test.dll.sources : add ValueSerializerTest.cs.
+
 2010-04-13  Atsushi Enomoto  <atsushi@ximian.com>
 
        * System.Xaml_test.dll.sources : add XamlObjectWriterTest.cs.
index 9c5723deb1a9c432c180d405ee36280f8d14e87e..9da4395b4fbd987cfc2c6daff71a9f8a8306ca71 100644 (file)
@@ -1,3 +1,7 @@
+2010-04-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ValueSerializer.cs : implement most of them.
+
 2010-04-12  Atsushi Enomoto  <atsushi@ximian.com>
 
        * TypeExtension.cs, StaticExtension.cs : add [TypeConverter].
index 79693ab61494da7f3e225f3c19de6393b90fb759..c3bd3dc860b88334ede86f5e2225fcb72e9d0e23 100644 (file)
@@ -33,36 +33,55 @@ namespace System.Windows.Markup
        {
                public static ValueSerializer GetSerializerFor (PropertyDescriptor descriptor)
                {
-                       throw new NotImplementedException ();
+                       return GetSerializerFor (descriptor, null);
                }
+
                public static ValueSerializer GetSerializerFor (Type type)
                {
-                       throw new NotImplementedException ();
+                       return GetSerializerFor (type, null);
                }
+
                public static ValueSerializer GetSerializerFor (PropertyDescriptor descriptor, IValueSerializerContext context)
                {
                        throw new NotImplementedException ();
                }
+
+               [MonoTODO ("IValueSerializerContext parameter is not supported")]
                public static ValueSerializer GetSerializerFor (Type type, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       if (type == null)
+                               throw new ArgumentNullException ("type");
+
+                       // FIXME: it is likely a hack.
+                       if (Type.GetTypeCode (type) != TypeCode.Object)
+                               return new TypeConverterValueSerializer (type);
+                       if (type == typeof (TimeSpan))
+                               return new TypeConverterValueSerializer (typeof (TimeSpan));
+                       if (type == typeof (Uri))
+                               return new TypeConverterValueSerializer (typeof (Uri));
+                       return null;
                }
 
+               // instance members
+
                public virtual bool CanConvertFromString (string value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       return false;
                }
+
                public virtual bool CanConvertToString (object value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       return false;
                }
+
                public virtual object ConvertFromString (string value, IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       throw new NotSupportedException (String.Format ("Conversion from string '{0}' is not supported", value));
                }
+
                public virtual string ConvertToString (object value,     IValueSerializerContext context)
                {
-                       throw new NotImplementedException ();
+                       throw new NotSupportedException (String.Format ("Conversion from '{0}' to string is not supported", value != null ? value.GetType ().Name : "(null)"));
                }
 
                protected Exception GetConvertFromException (object value)
@@ -80,4 +99,79 @@ namespace System.Windows.Markup
                        throw new NotImplementedException ();
                }
        }
+
+       internal class StringValueSerializer : ValueSerializer
+       {
+               public override bool CanConvertFromString (string value, IValueSerializerContext context)
+               {
+                       return true;
+               }
+
+               public override bool CanConvertToString (object value, IValueSerializerContext context)
+               {
+                       return true;
+               }
+
+               public override object ConvertFromString (string value, IValueSerializerContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public override string ConvertToString (object value,     IValueSerializerContext context)
+               {
+                       return (string) value;
+               }
+
+               public override IEnumerable<Type> TypeReferences (object value, IValueSerializerContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+
+       #region Internal implementations.
+
+       internal class TypeConverterValueSerializer<T> : TypeConverterValueSerializer
+       {
+               public TypeConverterValueSerializer ()
+                       : base (typeof (T))
+               {
+               }
+       }
+
+       internal class TypeConverterValueSerializer : ValueSerializer
+       {
+               public TypeConverterValueSerializer (Type type)
+               {
+                       c = TypeDescriptor.GetConverter (type);
+               }
+
+               TypeConverter c;
+
+               public override bool CanConvertFromString (string value, IValueSerializerContext context)
+               {
+                       return c.CanConvertFrom (typeof (string));
+               }
+
+               public override bool CanConvertToString (object value, IValueSerializerContext context)
+               {
+                       return c.CanConvertTo (typeof (string));
+               }
+
+               public override object ConvertFromString (string value, IValueSerializerContext context)
+               {
+                       return c.ConvertFromInvariantString (value);
+               }
+
+               public override string ConvertToString (object value,     IValueSerializerContext context)
+               {
+                       return value == null ? String.Empty : c.ConvertToInvariantString (value);
+               }
+
+               public override IEnumerable<Type> TypeReferences (object value, IValueSerializerContext context)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+       
+       #endregion
 }
index 7d75ca8b435739e4050224d56d6381ddd5d6eecb..607f14b5eaa02f1066cb682b7d713a76cbdca0f9 100644 (file)
@@ -1,3 +1,10 @@
+2010-04-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XamlMember.cs
+         XamlDirective.cs
+         XamlType.cs
+         XamlLanguage.cs : implement (Lookup)ValueSerializer.
+
 2010-04-13  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XamlXmlWriter.cs :
index ffec3f52550a745e53eb3f3a0c730a95c0520ff5..65e4dcc8b6f7f1317f5580c64f923f8c0158699d 100644 (file)
@@ -88,17 +88,17 @@ namespace System.Xaml
 
                protected override sealed ICustomAttributeProvider LookupCustomAttributeProvider ()
                {
-                       throw new NotImplementedException ();
+                       return null; // as documented.
                }
 
                protected override sealed XamlValueConverter<XamlDeferringLoader> LookupDeferringLoader ()
                {
-                       return null;
+                       return null; // as documented.
                }
 
                protected override sealed IList<XamlMember> LookupDependsOn ()
                {
-                       return base.LookupDependsOn ();
+                       return null; // as documented.
                }
 
                protected override sealed XamlMemberInvoker LookupInvoker ()
@@ -175,7 +175,7 @@ namespace System.Xaml
 
                public override string ToString ()
                {
-                       throw new NotImplementedException ();
+                       return String.IsNullOrEmpty (PreferredXamlNamespace) ? Name : String.Concat ("{", PreferredXamlNamespace, "}", Name);
                }
        }
 }
index 6b315e5fbdad8e5800f71c95c72b479f267c88b7..93940389db2b1365466590ce49a573372726d3bd 100644 (file)
@@ -39,13 +39,15 @@ namespace System.Xaml
                public const string Xml1998Namespace = "http://www.w3.org/XML/1998/namespace";
                internal const string Xmlns2000Namespace = "http://www.w3.org/2000/xmlns/";
 
-               static readonly XamlSchemaContext sctx = new XamlSchemaContext (null, null);
+               static readonly XamlSchemaContext sctx = new XamlSchemaContext (new Assembly [] {typeof (XamlType).Assembly});
 
                static XamlType XT<T> ()
                {
                        return sctx.GetXamlType (typeof (T));
                }
 
+               internal static readonly bool InitializingDirectives;
+
                static XamlLanguage ()
                {
                        // types
@@ -76,6 +78,10 @@ namespace System.Xaml
 
                        // directives
 
+                       // Looks like predefined XamlDirectives have no ValueSerializer. 
+                       // To handle this situation, differentiate them from non-primitive XamlMembers.
+                       InitializingDirectives = true;
+
                        var nss = new string [] {XamlLanguage.Xaml2006Namespace};
                        var nssXml = new string [] {XamlLanguage.Xml1998Namespace};
 
@@ -105,6 +111,8 @@ namespace System.Xaml
                        UnknownContent = new XamlDirective (nss, "_UnknownContent", XT<object> (), null, AllowedMemberLocations.MemberElement) { InternalIsUnknown = true };
 
                        AllDirectives = new ReadOnlyCollection<XamlDirective> (new XamlDirective [] {Arguments, AsyncRecords, Base, Class, ClassAttributes, ClassModifier, Code, ConnectionId, FactoryMethod, FieldModifier, Initialization, Items, Key, Lang, Members, Name, PositionalParameters, Space, Subclass, SynchronousMode, Shared, TypeArguments, Uid, UnknownContent});
+
+                       InitializingDirectives = false;
                }
 
                static readonly string [] xaml_nss = new string [] {Xaml2006Namespace};
index 0f2b2ed0adbd5abba2a6da4875b5f7b7af9b8a70..03466f061cd29d6d572b5fc6db01adce61ee1f46 100644 (file)
@@ -147,6 +147,7 @@ namespace System.Xaml
                XamlSchemaContext context;
                XamlMemberInvoker invoker;
                bool is_attachable, is_event, is_directive;
+               bool is_predefined_directive = XamlLanguage.InitializingDirectives;
                string directive_ns;
 
                internal MethodInfo UnderlyingGetter {
@@ -188,9 +189,13 @@ namespace System.Xaml
                public XamlValueConverter<XamlDeferringLoader> DeferringLoader {
                        get { return LookupDeferringLoader (); }
                }
+               
+               static readonly XamlMember [] empty_members = new XamlMember [0];
+               
                public IList<XamlMember> DependsOn {
-                       get { return LookupDependsOn (); }
+                       get { return LookupDependsOn () ?? empty_members; }
                }
+
                public XamlMemberInvoker Invoker {
                        get { return LookupInvoker (); }
                }
@@ -284,8 +289,9 @@ namespace System.Xaml
 
                protected virtual ICustomAttributeProvider LookupCustomAttributeProvider ()
                {
-                       throw new NotImplementedException ();
+                       return UnderlyingMember;
                }
+
                protected virtual XamlValueConverter<XamlDeferringLoader> LookupDeferringLoader ()
                {
                        // FIXME: probably fill from attribute.
@@ -404,8 +410,12 @@ namespace System.Xaml
 
                protected virtual XamlValueConverter<ValueSerializer> LookupValueSerializer ()
                {
-                       // FIXME: probably fill from attribute
-                       return null;
+                       if (is_predefined_directive) // FIXME: this is likely a hack.
+                               return null;
+                       if (Type == null)
+                               return null;
+
+                       return XamlType.LookupValueSerializer (Type, LookupCustomAttributeProvider ()) ?? Type.ValueSerializer;
                }
 
                void VerifyGetter (MethodInfo method)
index 17de363f5b199884a2e83a430ac17d333725b889..6f490eaacfe49e01cf54fdbb5e4f0fc442052011 100644 (file)
@@ -625,9 +625,35 @@ namespace System.Xaml
                        return a != null && a.Usable;
                }
 
+               static XamlValueConverter<ValueSerializer> string_value_serializer;
+
                protected virtual XamlValueConverter<ValueSerializer> LookupValueSerializer ()
                {
-                       throw new NotImplementedException ();
+                       return LookupValueSerializer (this, CustomAttributeProvider);
+               }
+
+               internal static XamlValueConverter<ValueSerializer> LookupValueSerializer (XamlType targetType, ICustomAttributeProvider provider)
+               {
+                       if (provider == null)
+                               return null;
+
+                       var a = provider.GetCustomAttribute<ValueSerializerAttribute> (true);
+                       if (a != null)
+                               return new XamlValueConverter<ValueSerializer> (a.ValueSerializerType ?? Type.GetType (a.ValueSerializerTypeName), targetType);
+
+                       if (targetType.BaseType != null) {
+                               var ret = targetType.BaseType.LookupValueSerializer ();
+                               if (ret != null)
+                                       return ret;
+                       }
+
+                       if (targetType.UnderlyingType == typeof (string)) {
+                               if (string_value_serializer == null)
+                                       string_value_serializer = new XamlValueConverter<ValueSerializer> (typeof (StringValueSerializer), targetType);
+                               return string_value_serializer;
+                       }
+
+                       return null;
                }
        }
 }
index 98ca352a7f8bcc304ec90dea9d43c5fb783fd013..876e071fcd91a91a99692df0b9fae38b726d4f14 100644 (file)
@@ -1,6 +1,7 @@
 System.Windows.Markup/ArrayExtensionTest.cs
 System.Windows.Markup/StaticExtensionTest.cs
 System.Windows.Markup/TypeExtensionTest.cs
+System.Windows.Markup/ValueSerializerTest.cs
 System.Xaml.Schema/XamlMemberInvokerTest.cs
 System.Xaml.Schema/XamlTypeInvokerTest.cs
 System.Xaml.Schema/XamlTypeTypeConverterTest.cs
index 546a20d202982e88b6513fc8c6d9fffdbd35f37b..cdf88e87928f944734f4ae7558944e9bcc5d2a3a 100644 (file)
@@ -1,3 +1,7 @@
+2010-04-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * ValueSerializerTest.cs : new test.
+
 2010-04-09  Atsushi Enomoto  <atsushi@ximian.com>
 
        * ArrayExtensionTest.cs
diff --git a/mcs/class/System.Xaml/Test/System.Windows.Markup/ValueSerializerTest.cs b/mcs/class/System.Xaml/Test/System.Windows.Markup/ValueSerializerTest.cs
new file mode 100644 (file)
index 0000000..a88cbd9
--- /dev/null
@@ -0,0 +1,136 @@
+//
+// Copyright (C) 2010 Novell Inc. http://novell.com
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Windows.Markup;
+using System.Xaml;
+using System.Xaml.Schema;
+using NUnit.Framework;
+
+using Category = NUnit.Framework.CategoryAttribute;
+
+namespace MonoTests.System.Windows.Markup
+{
+       [TestFixture]
+       public class ValueSerializerTest
+       {
+               static ValueSerializerTest ()
+               {
+                       std_types = new List<XamlType> (XamlLanguage.AllTypes);
+                       std_types.Sort ((t1, t2) => String.CompareOrdinal (t1.Name, t2.Name));
+               }
+
+               static readonly List<XamlType> std_types;
+               object [] test_values = {null, true, "test", 3, 'x', 5.5, -1.414m, (byte) 255, new Uri ("urn:foo"), new NullExtension (), new object (), new PropertyDefinition (), new Reference ("Foo"), new StaticExtension (), TimeSpan.FromMinutes (5), new TypeExtension ("TypeExt"), new XData () { Text = "test xdata"} }; // can we instantiate MemberDefinition?
+               string [] test_strings = {String.Empty, "True", "test", "3", "x", "5.5", "-1.414", "255", "urn:foo", "System.Windows.Markup.NullExtension", "System.Object", "System.Windows.Markup.PropertyDefinition", "System.Windows.Markup.Reference", "System.Windows.Markup.StaticExtension", "00:05:00", "System.Windows.Markup.TypeExtension", "System.Windows.Markup.XData"};
+
+               [Test]
+               public void SerializerInAllTypes ()
+               {
+                       var sctx = new XamlSchemaContext (new Assembly [] { typeof (XamlType).Assembly });
+                       foreach (var t in std_types) {
+                               if (t != XamlLanguage.String) {
+                                       Assert.IsNull (t.ValueSerializer, "IsNull? " + t.Name);
+                                       continue;
+                               }
+                               var v = t.ValueSerializer.ConverterInstance;
+                               foreach (var val in test_values)
+                                       Assert.IsTrue (v.CanConvertToString (val, null), t.Name + "_" + (val != null ? val.GetType () : null));
+                       }
+               }
+
+               static readonly Type [] no_ser_types = {typeof (object), typeof (ArrayExtension), typeof (MemberDefinition), typeof (NullExtension), typeof (PropertyDefinition), typeof (Reference), typeof (StaticExtension), typeof (TypeExtension), typeof (XData)};
+
+               [Test]
+               public void GetSerializerForAllTypes ()
+               {
+                       // Serializers from GetSerializerFor() returns very 
+                       // different results from predefined ValueSerializer.
+                       foreach (var t in std_types) {
+                               var v = ValueSerializer.GetSerializerFor (t.UnderlyingType, null);
+                               if (no_ser_types.Any (ti => ti == t.UnderlyingType)) {
+                                       Assert.IsNull (v, "NoSerializer_" + t.Name);
+                                       continue;
+                               }
+
+                               // String ValueSerializer is the only exceptional one that mostly fails ConvertToString().
+                               // For remaining types, ConvertToString() should succeed.
+                               // What is funny or annoying here is, that always return true for CanConvertToString() while everything fails at ConvertToString() on .NET.
+                               if (t.UnderlyingType == typeof (string))
+                                       continue;
+
+                               int i = 0;
+                               foreach (var val in test_values) {
+                                       Assert.IsTrue (v.CanConvertToString (val, null), t.Name + "_" + (val != null ? val.GetType () : null));
+                                       Assert.AreEqual (test_strings [i++], v.ConvertToString (val, null), "value-" + t.Name + "_" + val);
+                               }
+
+                               // The funny thing also applies to CanConvertToString() and ConvertToString().
+
+                               i = 0;
+                               foreach (var str in test_strings) {
+                                       Assert.IsTrue (v.CanConvertFromString (str, null), t.Name + "_" + str);
+                                       // FIXME: add tests for this large matrix someday.
+                                       //Assert.AreEqual (test_values [i++], v.ConvertFromString (str, null), "value-" + t.Name + "_" + str);
+                               }
+                       }
+               }
+
+               [Test]
+               public void DefaultImplementation ()
+               {
+                       var v = new MyValueSerializer ();
+
+                       int i = 0;
+                       foreach (var val in test_values) {
+                               Assert.IsFalse (v.CanConvertToString (val, null), "CanConvertTo." + val);
+                               try {
+                                       v.ConvertToString (val, null);
+                                       Assert.Fail ("ConvertTo." + val);
+                               } catch (NotSupportedException) {
+                               }
+                       }
+
+                       // The funny thing also applies to CanConvertToString() and ConvertToString().
+
+                       i = 0;
+                       foreach (var str in test_strings) {
+                               Assert.IsFalse (v.CanConvertFromString (str, null), "CanConvertFrom." + str);
+                               try {
+                                       v.ConvertFromString (str, null);
+                                       Assert.Fail ("ConvertFrom." + str);
+                               } catch (NotSupportedException) {
+                               }
+                       }
+               }
+
+               class MyValueSerializer : ValueSerializer
+               {
+               }
+       }
+}
index d01dc9ae159f5e1c5c7365bfa42a110bf2aab6b9..dc1abf5a9b0085fecbd14b88ce8aaa6c546961cc 100644 (file)
@@ -1,3 +1,7 @@
+2010-04-14  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * XamlTypeTest.cs, XamlLanguageTest.cs : enable ValueSerializer tests.
+
 2010-04-13  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XamlXmlWriterTest.cs : enable WriteNode() tests.
index e853a11a28d20c5b362f003b78b6f6a42049f104..2f4dda50fc2401cba57e98ab055db6777f8f0bc0 100644 (file)
@@ -572,6 +572,8 @@ namespace MonoTests.System.Xaml
                {
                        var t = XamlLanguage.String;
                        TestXamlTypePrimitive (t, "String", typeof (string), true, true);
+                       Assert.IsNotNull (XamlLanguage.AllTypes.First (tt => tt.Name == "String").ValueSerializer, "#x");
+                       Assert.IsNotNull (XamlLanguage.String.ValueSerializer, "#y");
 
                        /* Those properties are pointless regarding practical use. Those "members" does not participate in serialization.
                        var l = t.GetAllAttachableMembers ().ToArray ();
@@ -758,7 +760,11 @@ namespace MonoTests.System.Xaml
                        Assert.IsFalse (t.IsAmbient, "#22");
                        //Assert.IsNull (t.AllowedContentTypes, "#23");
                        //Assert.IsNull (t.ContentWrappers, "#24");
-                       //Assert.IsNull (t.ValueSerializer, "#26");
+                       // string is a special case.
+                       if (t == XamlLanguage.String)
+                               Assert.IsNotNull (t.ValueSerializer, "#26");
+                       else
+                               Assert.IsNull (t.ValueSerializer, "#26");
                        //Assert.IsNull (t.DeferringLoader, "#28");
                }
 
@@ -787,11 +793,6 @@ namespace MonoTests.System.Xaml
                }
 
                void TestMemberCommon (XamlMember m, string name, Type type, Type declType, bool hasSetter)
-               {
-                       TestMemberCommon (m, name, type, declType, hasSetter, type == typeof (string));
-               }
-
-               void TestMemberCommon (XamlMember m, string name, Type type, Type declType, bool hasSetter, bool hasSerializer)
                {
                        Assert.IsNotNull (m, "#1");
                        Assert.IsNotNull (m.DeclaringType, "#2");
@@ -812,9 +813,14 @@ namespace MonoTests.System.Xaml
                        Assert.AreEqual (new XamlType (declType, m.TargetType.SchemaContext), m.TargetType, "#10");
                        Assert.IsNotNull (m.Type, "#11");
                        Assert.AreEqual (type, m.Type.UnderlyingType, "#11-2");
-                       // FIXME: test TypeConverter and ValueSerializer
-//                     Assert.IsNull (m.TypeConverter, "#12");
-//                     Assert.AreEqual (hasSerializer, m.ValueSerializer != null, "#13");
+                       // Property.Type is a special case here.
+                       if (name == "Type" && m.DeclaringType != XamlLanguage.Property)
+                               Assert.AreEqual (m.Type.TypeConverter, m.TypeConverter, "#12");
+                       // String type is a special case here.
+                       if (type == typeof (string))
+                               Assert.AreEqual (m.Type.ValueSerializer, m.ValueSerializer, "#13a");
+                       else
+                               Assert.IsNull (m.ValueSerializer, "#13b");
                        Assert.IsNull (m.DeferringLoader, "#14");
                        Assert.IsNotNull (m.UnderlyingMember, "#15");
                        Assert.AreEqual (!hasSetter, m.IsReadOnly, "#16");
index 268ce4977915dda87a3d47d56a6234eda5be299e..b390811aa1051b3f682bd694fd966f2de4a12e29 100644 (file)
@@ -35,7 +35,7 @@ using Category = NUnit.Framework.CategoryAttribute;
 
 namespace MonoTests.System.Xaml
 {
-       // FIXME: enable AllowedContentTypes, ContentWrappers, DeferringLoader and ValueSerializer tests.
+       // FIXME: enable AllowedContentTypes, ContentWrappers and DeferringLoader tests.
        [TestFixture]
        public class XamlTypeTest
        {
@@ -173,7 +173,7 @@ namespace MonoTests.System.Xaml
                }
 
                [Test]
-               [Ignore ("It results in NRE on .NET 4.0 RC")]
+               [Ignore ("It results in NRE on .NET 4.0 RTM")]
                public void EmptyTypeArguments ()
                {
                        var t1 = new MyXamlType ("System.Int32", null, sctx);
@@ -308,7 +308,7 @@ namespace MonoTests.System.Xaml
                        //Assert.IsNull (t.ContentWrappers, "#24");
                        Assert.IsNotNull (t.TypeConverter, "#25");
                        Assert.IsTrue (t.TypeConverter.ConverterInstance is Int32Converter, "#25-2");
-                       //Assert.IsNull (t.ValueSerializer, "#26");
+                       Assert.IsNull (t.ValueSerializer, "#26");
                        Assert.IsNull (t.ContentProperty, "#27");
                        //Assert.IsNull (t.DeferringLoader, "#28");
                        Assert.IsNull (t.MarkupExtensionReturnType, "#29");
@@ -345,7 +345,7 @@ namespace MonoTests.System.Xaml
                        //Assert.IsNull (t.AllowedContentTypes, "#23");
                        //Assert.IsNull (t.ContentWrappers, "#24");
                        Assert.IsNull (t.TypeConverter, "#25");
-                       //Assert.IsNull (t.ValueSerializer, "#26");
+                       Assert.IsNull (t.ValueSerializer, "#26");
                        Assert.IsNull (t.ContentProperty, "#27");
                        //Assert.IsNull (t.DeferringLoader, "#28");
                        Assert.IsNull (t.MarkupExtensionReturnType, "#29");
@@ -382,7 +382,7 @@ namespace MonoTests.System.Xaml
                        //Assert.IsNull (t.AllowedContentTypes, "#23");
                        //Assert.IsNull (t.ContentWrappers, "#24");
                        Assert.IsNull (t.TypeConverter, "#25");
-                       //Assert.IsNull (t.ValueSerializer, "#26");
+                       Assert.IsNull (t.ValueSerializer, "#26");
                        Assert.IsNull (t.ContentProperty, "#27");
                        //Assert.IsNull (t.DeferringLoader, "#28");
                        Assert.IsNull (t.MarkupExtensionReturnType, "#29");
@@ -432,7 +432,7 @@ namespace MonoTests.System.Xaml
                        // Assert.IsNull (t.AllowedContentTypes, "#23");
                        // Assert.IsNull (t.ContentWrappers, "#24");
                        Assert.IsNull (t.TypeConverter, "#25");
-                       // Assert.IsNull (t.ValueSerializer, "#26");
+                       Assert.IsNull (t.ValueSerializer, "#26");
                        Assert.IsNotNull (t.ContentProperty, "#27");
                        Assert.AreEqual ("Name", t.ContentProperty.Name, "#27-2");
                        // Assert.IsNull (t.DeferringLoader, "#28");