XmlSerializer: Add support to serialize nullable types when the XmlElement has explic...
authorMiguel de Icaza <miguel@gnome.org>
Wed, 4 Jan 2012 00:38:01 +0000 (19:38 -0500)
committerMiguel de Icaza <miguel@gnome.org>
Wed, 4 Jan 2012 00:38:13 +0000 (19:38 -0500)
commit62d74308649b088ab6ed2877859f470e41db3f9c
treeb6c55aafe6e7d128f761f257457547816a351d6c
parentd7f671d0ee3ff161416f13c1f3777dc911aad3f9
XmlSerializer: Add support to serialize nullable types when the XmlElement has explicity set the DataType

The existing code had a special code path for handling nullables that
ignored the DataType component.

This patch splits the nullable test away, allows the specified XmlDataType
to be probed and then performs the standard type lookup mechanism.

This allows this:

        [XmlElement ("MyNullableTime", DataType="time", IsNullable=true)]
        DateTime? myTime;

To be serialized as a "time" instead of a "datetime".

Fixes bug #329
mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs
mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializationWriterTests.cs
mcs/class/System.XML/Test/System.Xml.Serialization/XmlSerializerTestClasses.cs