Merge pull request #496 from nicolas-raoul/unit-test-for-issue2907
[mono.git] / mcs / class / System.XML / Test / System.Xml.Serialization / DeserializeTests.cs
index c7205f6557ddcbf7cde6ea3f71e1b167bfcc7384..362d61fbcf7f260015744fae20312ef274242da6 100644 (file)
@@ -3,8 +3,12 @@
 //
 // Author:
 //     Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
+//     Hagit Yidov <hagity@mainsoft.com>
+//     Andres G. Aragoneses <andres.aragoneses@7digital.com>
 //
 // (C) 2003 Atsushi Enomoto
+// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
+// (C) 2012 7digital Media Ltd (http://www.7digital.com)
 //
 //
 using System;
@@ -20,7 +24,7 @@ namespace MonoTests.System.XmlSerialization
        public class Sample
        {
                public string Text;
-               public string [] ArrayText;
+               public string[] ArrayText;
        }
 
        [TestFixture]
@@ -126,40 +130,40 @@ namespace MonoTests.System.XmlSerialization
                        Field f = Deserialize (typeof (Field), "<field modifiers=\"\" />") as Field;
                        Assert.AreEqual (MapModifiers.Public, f.Modifiers);
                }
-               
+
                [Test]
                public void DeserializePrivateCollection ()
                {
                        MemoryStream ms = new MemoryStream ();
-                       Container c = new Container();
-                       c.Items.Add(1);
-                       
-                       XmlSerializer serializer = new XmlSerializer(typeof(Container));
-                       serializer.Serialize(ms, c);
-                       
+                       Container c = new Container ();
+                       c.Items.Add (1);
+
+                       XmlSerializer serializer = new XmlSerializer (typeof (Container));
+                       serializer.Serialize (ms, c);
+
                        ms.Position = 0;
                        c = (Container) serializer.Deserialize (ms);
                        Assert.AreEqual (1, c.Items[0]);
                }
-               
+
                [Test]
-               [Category("NotDotNet")]
+               [Category ("NotDotNet")]
                [ExpectedException (typeof (InvalidOperationException))]
                public void DeserializeEmptyPrivateCollection ()
                {
                        MemoryStream ms = new MemoryStream ();
-                       Container2 c = new Container2(true);
-                       c.Items.Add(1);
-                       
-                       XmlSerializer serializer = new XmlSerializer(typeof(Container2));
-                       serializer.Serialize(ms, c);
-                       
+                       Container2 c = new Container2 (true);
+                       c.Items.Add (1);
+
+                       XmlSerializer serializer = new XmlSerializer (typeof (Container2));
+                       serializer.Serialize (ms, c);
+
                        ms.Position = 0;
                        c = (Container2) serializer.Deserialize (ms);
                }
-               
+
                [Test]
-               [Category("NotDotNet")]
+               [Category ("NotDotNet")]
                public void DeserializeArrayReferences ()
                {
                        string s = "<Sample xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";
@@ -169,16 +173,16 @@ namespace MonoTests.System.XmlSerialization
                        s += "</ArrayText>";
                        s += "<string id=\"id-606830706\" xsi:type=\"xsd:string\">Adeu</string>";
                        s += "</Sample>";
-                       DeserializeEncoded (typeof(Sample), s);
+                       DeserializeEncoded (typeof (Sample), s);
                }
-               
-               
+
+
                [Test]
                public void TestDeserializeXmlNodeArray ()
                {
-                       object ob = Deserialize (typeof(object), "<anyType at=\"1\"><elem1/><elem2/></anyType>");
+                       object ob = Deserialize (typeof (object), "<anyType at=\"1\"><elem1/><elem2/></anyType>");
                        Assert.IsTrue (ob is XmlNode[], "Is node array");
-                       
+
                        XmlNode[] nods = (XmlNode[]) ob;
                        Assert.AreEqual (3, nods.Length, "lengh");
                        Assert.IsTrue (nods[0] is XmlAttribute, "#1");
@@ -189,59 +193,59 @@ namespace MonoTests.System.XmlSerialization
                        Assert.IsTrue (nods[2] is XmlElement, "#6");
                        Assert.AreEqual ("elem2", ((XmlElement) nods[2]).LocalName, "#7");
                }
-               
+
                [Test]
                public void TestDeserializeXmlElement ()
                {
-                       object ob = Deserialize (typeof(XmlElement), "<elem/>");
+                       object ob = Deserialize (typeof (XmlElement), "<elem/>");
                        Assert.IsTrue (ob is XmlElement, "#1");
                        Assert.AreEqual ("elem", ((XmlElement) ob).LocalName, "#2");
                }
-               
+
                [Test]
                public void TestDeserializeXmlCDataSection ()
                {
-                       CDataContainer c = (CDataContainer) Deserialize (typeof(CDataContainer), "<CDataContainer xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><cdata><![CDATA[data section contents]]></cdata></CDataContainer>");
+                       CDataContainer c = (CDataContainer) Deserialize (typeof (CDataContainer), "<CDataContainer xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><cdata><![CDATA[data section contents]]></cdata></CDataContainer>");
                        Assert.IsNotNull (c.cdata, "#1");
                        Assert.AreEqual ("data section contents", c.cdata.Value, "#2");
                }
-               
+
                [Test]
                public void TestDeserializeXmlNode ()
                {
-                       NodeContainer c = (NodeContainer) Deserialize (typeof(NodeContainer), "<NodeContainer xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><node>text</node></NodeContainer>");
+                       NodeContainer c = (NodeContainer) Deserialize (typeof (NodeContainer), "<NodeContainer xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><node>text</node></NodeContainer>");
                        Assert.IsTrue (c.node is XmlText, "#1");
                        Assert.AreEqual ("text", c.node.Value, "#2");
                }
-               
+
                [Test]
                public void TestDeserializeChoices ()
                {
-                       Choices ch = (Choices) Deserialize (typeof(Choices), "<Choices><ChoiceZero>choice text</ChoiceZero></Choices>");
+                       Choices ch = (Choices) Deserialize (typeof (Choices), "<Choices><ChoiceZero>choice text</ChoiceZero></Choices>");
                        Assert.AreEqual ("choice text", ch.MyChoice, "#A1");
                        Assert.AreEqual (ItemChoiceType.ChoiceZero, ch.ItemType, "#A2");
-                       
-                       ch = (Choices) Deserialize (typeof(Choices), "<Choices><ChoiceOne>choice text</ChoiceOne></Choices>");
+
+                       ch = (Choices) Deserialize (typeof (Choices), "<Choices><ChoiceOne>choice text</ChoiceOne></Choices>");
                        Assert.AreEqual ("choice text", ch.MyChoice, "#B1");
                        Assert.AreEqual (ItemChoiceType.StrangeOne, ch.ItemType, "#B2");
-                       
-                       ch = (Choices) Deserialize (typeof(Choices), "<Choices><ChoiceTwo>choice text</ChoiceTwo></Choices>");
+
+                       ch = (Choices) Deserialize (typeof (Choices), "<Choices><ChoiceTwo>choice text</ChoiceTwo></Choices>");
                        Assert.AreEqual ("choice text", ch.MyChoice, "#C1");
                        Assert.AreEqual (ItemChoiceType.ChoiceTwo, ch.ItemType, "#C2");
                }
-               
+
                [Test]
                public void TestDeserializeNamesWithSpaces ()
                {
-                       TestSpace ts = (TestSpace) Deserialize (typeof(TestSpace), "<Type_x0020_with_x0020_space xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' Attribute_x0020_with_x0020_space='5'><Element_x0020_with_x0020_space>4</Element_x0020_with_x0020_space></Type_x0020_with_x0020_space>");
+                       TestSpace ts = (TestSpace) Deserialize (typeof (TestSpace), "<Type_x0020_with_x0020_space xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' Attribute_x0020_with_x0020_space='5'><Element_x0020_with_x0020_space>4</Element_x0020_with_x0020_space></Type_x0020_with_x0020_space>");
                        Assert.AreEqual (4, ts.elem, "#1");
                        Assert.AreEqual (5, ts.attr, "#2");
                }
-               
+
                [Test]
                public void TestDeserializeDefaults ()
                {
-                       ListDefaults d2 = (ListDefaults) Deserialize (typeof(ListDefaults), "<root/>");
+                       ListDefaults d2 = (ListDefaults) Deserialize (typeof (ListDefaults), "<root/>");
 
                        Assert.IsNotNull (d2.list2, "#A1");
                        Assert.IsNull (d2.list3, "#A2");
@@ -250,7 +254,7 @@ namespace MonoTests.System.XmlSerialization
                        Assert.IsNotNull (d2.ed, "#A5");
                        Assert.IsNotNull (d2.str, "#A6");
 
-                       d2 = (ListDefaults) Deserialize (typeof(ListDefaults), "<root></root>");
+                       d2 = (ListDefaults) Deserialize (typeof (ListDefaults), "<root></root>");
 
                        Assert.IsNotNull (d2.list2, "#B1");
                        Assert.IsNull (d2.list3, "#B2");
@@ -259,11 +263,11 @@ namespace MonoTests.System.XmlSerialization
                        Assert.IsNotNull (d2.ed, "#B5");
                        Assert.IsNotNull (d2.str, "#B6");
                }
-               
+
                [Test]
                public void TestDeserializeChoiceArray ()
                {
-                       CompositeValueType v = (CompositeValueType) Deserialize (typeof(CompositeValueType), "<?xml version=\"1.0\" encoding=\"utf-16\"?><CompositeValueType xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><In>1</In><Es>2</Es></CompositeValueType>");
+                       CompositeValueType v = (CompositeValueType) Deserialize (typeof (CompositeValueType), "<?xml version=\"1.0\" encoding=\"utf-16\"?><CompositeValueType xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><In>1</In><Es>2</Es></CompositeValueType>");
                        Assert.IsNotNull (v.Items, "#1");
                        Assert.IsNotNull (v.ItemsElementName, "#2");
                        Assert.AreEqual (2, v.Items.Length, "#3");
@@ -273,77 +277,315 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (ItemsChoiceType.In, v.ItemsElementName[0], "#7");
                        Assert.AreEqual (ItemsChoiceType.Es, v.ItemsElementName[1], "#8");
                }
-               
+
+               #region GenericsDeseralizationTests
+
+#if NET_2_0
+               [Test]
+               public void TestDeserializeGenSimpleClassString ()
+               {
+                       Deserialize (typeof (GenSimpleClass<string>), "<GenSimpleClassOfString xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />");
+                       Assert.AreEqual (typeof (GenSimpleClass<string>), result.GetType ());
+                       Deserialize (typeof (GenSimpleClass<string>), "<GenSimpleClassOfString xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something>hello</something></GenSimpleClassOfString>");
+                       GenSimpleClass<string> simple = result as GenSimpleClass<string>;
+                       Assert.AreEqual ("hello", simple.something);
+               }
+
+               [Test]
+               public void TestDeserializeGenSimpleClassBool ()
+               {
+                       Deserialize (typeof (GenSimpleClass<bool>), "<GenSimpleClassOfBoolean xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something>false</something></GenSimpleClassOfBoolean>");
+                       Assert.AreEqual (typeof (GenSimpleClass<bool>), result.GetType ());
+                       Deserialize (typeof (GenSimpleClass<bool>), "<GenSimpleClassOfBoolean xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something>true</something></GenSimpleClassOfBoolean>");
+                       GenSimpleClass<bool> simple = result as GenSimpleClass<bool>;
+                       Assert.AreEqual (true, simple.something);
+               }
+
+               [Test]
+               public void TestDeserializeGenSimpleStructInt ()
+               {
+                       Deserialize (typeof (GenSimpleStruct<int>), "<GenSimpleStructOfInt32 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something>0</something></GenSimpleStructOfInt32>");
+                       Assert.AreEqual (typeof (GenSimpleStruct<int>), result.GetType ());
+                       Deserialize (typeof (GenSimpleStruct<int>), "<GenSimpleStructOfInt32 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something>123</something></GenSimpleStructOfInt32>");
+                       GenSimpleStruct<int> simple = new GenSimpleStruct<int> (0);
+                       if (result != null)
+                               simple = (GenSimpleStruct<int>) result;
+                       Assert.AreEqual (123, simple.something);
+               }
+
+               [Test]
+               public void TestDeserializeGenListClassString ()
+               {
+                       Deserialize (typeof (GenListClass<string>), "<GenListClassOfString xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><somelist></somelist></GenListClassOfString>");
+                       Assert.AreEqual (typeof (GenListClass<string>), result.GetType ());
+                       Deserialize (typeof (GenListClass<string>), "<GenListClassOfString xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><somelist><string>Value1</string><string>Value2</string></somelist></GenListClassOfString>");
+                       GenListClass<string> genlist = result as GenListClass<string>;
+                       Assert.AreEqual ("Value1", genlist.somelist[0]);
+                       Assert.AreEqual ("Value2", genlist.somelist[1]);
+               }
+
+               [Test]
+               public void TestDeserializeGenListClassFloat ()
+               {
+                       Deserialize (typeof (GenListClass<float>), "<GenListClassOfSingle xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><somelist></somelist></GenListClassOfSingle>");
+                       Assert.AreEqual (typeof (GenListClass<float>), result.GetType ());
+                       Deserialize (typeof (GenListClass<float>), "<GenListClassOfSingle xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><somelist><float>1</float><float>2.2</float></somelist></GenListClassOfSingle>");
+                       GenListClass<float> genlist = result as GenListClass<float>;
+                       Assert.AreEqual (1, genlist.somelist[0]);
+                       Assert.AreEqual (2.2F, genlist.somelist[1]);
+               }
+
+               [Test]
+               public void TestDeserializeGenListClassList ()
+               {
+                       Deserialize (typeof (GenListClass<GenListClass<int>>), "<GenListClassOfGenListClassOfInt32 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><somelist></somelist></GenListClassOfGenListClassOfInt32>");
+                       Assert.AreEqual (typeof (GenListClass<GenListClass<int>>), result.GetType ());
+                       Deserialize (typeof (GenListClass<GenListClass<int>>), "<GenListClassOfGenListClassOfInt32 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><somelist><GenListClassOfInt32><somelist><int>1</int><int>2</int></somelist></GenListClassOfInt32><GenListClassOfInt32><somelist><int>10</int><int>20</int></somelist></GenListClassOfInt32></somelist></GenListClassOfGenListClassOfInt32>");
+                       GenListClass<GenListClass<int>> genlist = result as GenListClass<GenListClass<int>>;
+                       Assert.AreEqual (1, genlist.somelist[0].somelist[0]);
+                       Assert.AreEqual (2, genlist.somelist[0].somelist[1]);
+                       Assert.AreEqual (10, genlist.somelist[1].somelist[0]);
+                       Assert.AreEqual (20, genlist.somelist[1].somelist[1]);
+               }
+
+               [Test]
+               public void TestDeserializeGenListClassArray ()
+               {
+                       Deserialize (typeof (GenListClass<GenArrayClass<char>>), "<GenListClassOfGenArrayClassOfChar xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><somelist></somelist></GenListClassOfGenArrayClassOfChar>");
+                       Assert.AreEqual (typeof (GenListClass<GenArrayClass<char>>), result.GetType ());
+                       Deserialize (typeof (GenListClass<GenArrayClass<char>>), "<GenListClassOfGenArrayClassOfChar xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><somelist><GenArrayClassOfChar><arr><char>97</char><char>98</char><char>0</char></arr></GenArrayClassOfChar><GenArrayClassOfChar><arr><char>100</char><char>101</char><char>102</char></arr></GenArrayClassOfChar></somelist></GenListClassOfGenArrayClassOfChar>");
+                       GenListClass<GenArrayClass<char>> genlist = result as GenListClass<GenArrayClass<char>>;
+                       Assert.AreEqual ('a', genlist.somelist[0].arr[0]);
+                       Assert.AreEqual ('b', genlist.somelist[0].arr[1]);
+                       Assert.AreEqual ('d', genlist.somelist[1].arr[0]);
+                       Assert.AreEqual ('e', genlist.somelist[1].arr[1]);
+                       Assert.AreEqual ('f', genlist.somelist[1].arr[2]);
+               }
+
+               [Test]
+               public void TestDeserializeGenTwoClassCharDouble ()
+               {
+                       Deserialize (typeof (GenTwoClass<char, double>), "<GenTwoClassOfCharDouble xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something1>0</something1><something2>0</something2></GenTwoClassOfCharDouble>");
+                       Assert.AreEqual (typeof (GenTwoClass<char, double>), result.GetType ());
+                       Deserialize (typeof (GenTwoClass<char, double>), "<GenTwoClassOfCharDouble xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something1>97</something1><something2>2.2</something2></GenTwoClassOfCharDouble>");
+                       GenTwoClass<char, double> gentwo = result as GenTwoClass<char, double>;
+                       Assert.AreEqual ('a', gentwo.something1);
+                       Assert.AreEqual (2.2, gentwo.something2);
+               }
+
+               [Test]
+               public void TestDeserializeGenDerivedClassDecimalShort ()
+               {
+                       Deserialize (typeof (GenDerivedClass<decimal, short>), "<GenDerivedClassOfDecimalInt16 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something2>0</something2><another1>0</another1><another2>0</another2></GenDerivedClassOfDecimalInt16>");
+                       Assert.AreEqual (typeof (GenDerivedClass<decimal, short>), result.GetType ());
+                       Deserialize (typeof (GenDerivedClass<decimal, short>), "<GenDerivedClassOfDecimalInt16 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something1>Value1</something1><something2>1</something2><another1>1.1</another1><another2>-22</another2></GenDerivedClassOfDecimalInt16>");
+                       GenDerivedClass<decimal, short> derived = result as GenDerivedClass<decimal, short>;
+                       Assert.AreEqual ("Value1", derived.something1);
+                       Assert.AreEqual (1, derived.something2);
+                       Assert.AreEqual (1.1M, derived.another1);
+                       Assert.AreEqual (-22, derived.another2);
+               }
+
+               [Test]
+               public void TestDeserializeGenDerivedSecondClassByteUlong ()
+               {
+                       Deserialize (typeof (GenDerived2Class<byte, ulong>), "<GenDerived2ClassOfByteUInt64 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something1>0</something1><something2>0</something2><another1>0</another1><another2>0</another2></GenDerived2ClassOfByteUInt64>");
+                       Assert.AreEqual (typeof (GenDerived2Class<byte, ulong>), result.GetType ());
+                       Deserialize (typeof (GenDerived2Class<byte, ulong>), "<GenDerived2ClassOfByteUInt64 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something1>1</something1><something2>222</something2><another1>111</another1><another2>222222</another2></GenDerived2ClassOfByteUInt64>");
+                       GenDerived2Class<byte, ulong> derived2 = result as GenDerived2Class<byte, ulong>;
+                       Assert.AreEqual (1, derived2.something1);
+                       Assert.AreEqual (222, derived2.something2);
+                       Assert.AreEqual (111, derived2.another1);
+                       Assert.AreEqual (222222, derived2.another2);
+               }
+
+               [Test]
+               public void TestDeserializeGenNestedClass ()
+               {
+                       Deserialize (typeof (GenNestedClass<string, int>.InnerClass<bool>), "<InnerClassOfStringInt32Boolean xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><inner>0</inner><something>false</something></InnerClassOfStringInt32Boolean>");
+                       Assert.AreEqual (typeof (GenNestedClass<string, int>.InnerClass<bool>), result.GetType ());
+                       Deserialize (typeof (GenNestedClass<string, int>.InnerClass<bool>), "<InnerClassOfStringInt32Boolean xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><inner>5</inner><something>true</something></InnerClassOfStringInt32Boolean>");
+                       GenNestedClass<string, int>.InnerClass<bool> nested = result as GenNestedClass<string, int>.InnerClass<bool>;
+                       Assert.AreEqual (5, nested.inner);
+                       Assert.AreEqual (true, nested.something);
+               }
+
+               [Test]
+               public void TestDeserializeGenListClassListNested ()
+               {
+                       Deserialize (typeof (GenListClass<GenListClass<GenNestedClass<int, int>.InnerClass<string>>>),
+                               "<GenListClassOfGenListClassOfInnerClassOfInt32Int32String xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><somelist></somelist></GenListClassOfGenListClassOfInnerClassOfInt32Int32String>");
+                       Assert.AreEqual (typeof (GenListClass<GenListClass<GenNestedClass<int, int>.InnerClass<string>>>), result.GetType ());
+                       Deserialize (typeof (GenListClass<GenListClass<GenNestedClass<int, int>.InnerClass<string>>>),
+                               "<GenListClassOfGenListClassOfInnerClassOfInt32Int32String xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><somelist><GenListClassOfInnerClassOfInt32Int32String><somelist><InnerClassOfInt32Int32String><inner>1</inner><something>ONE</something></InnerClassOfInt32Int32String><InnerClassOfInt32Int32String><inner>2</inner><something>TWO</something></InnerClassOfInt32Int32String></somelist></GenListClassOfInnerClassOfInt32Int32String><GenListClassOfInnerClassOfInt32Int32String><somelist><InnerClassOfInt32Int32String><inner>30</inner><something>THIRTY</something></InnerClassOfInt32Int32String></somelist></GenListClassOfInnerClassOfInt32Int32String></somelist></GenListClassOfGenListClassOfInnerClassOfInt32Int32String>");
+                       GenListClass<GenListClass<GenNestedClass<int, int>.InnerClass<string>>> genlist =
+                               result as GenListClass<GenListClass<GenNestedClass<int, int>.InnerClass<string>>>;
+                       Assert.AreEqual (1, genlist.somelist[0].somelist[0].inner);
+                       Assert.AreEqual ("ONE", genlist.somelist[0].somelist[0].something);
+                       Assert.AreEqual (2, genlist.somelist[0].somelist[1].inner);
+                       Assert.AreEqual ("TWO", genlist.somelist[0].somelist[1].something);
+                       Assert.AreEqual (30, genlist.somelist[1].somelist[0].inner);
+                       Assert.AreEqual ("THIRTY", genlist.somelist[1].somelist[0].something);
+               }
+
+               public enum Myenum { one, two, three, four, five, six };
+               [Test]
+               public void TestDeserializeGenArrayClassEnum ()
+               {
+                       Deserialize (typeof (GenArrayClass<Myenum>), "<GenArrayClassOfMyenum xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><arr><Myenum>one</Myenum><Myenum>one</Myenum><Myenum>one</Myenum></arr></GenArrayClassOfMyenum>");
+                       Assert.AreEqual (typeof (GenArrayClass<Myenum>), result.GetType ());
+                       Deserialize (typeof (GenArrayClass<Myenum>), "<GenArrayClassOfMyenum xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><arr><Myenum>one</Myenum><Myenum>three</Myenum><Myenum>five</Myenum></arr></GenArrayClassOfMyenum>");
+                       GenArrayClass<Myenum> genarr = result as GenArrayClass<Myenum>;
+                       Assert.AreEqual (Myenum.one, genarr.arr[0]);
+                       Assert.AreEqual (Myenum.three, genarr.arr[1]);
+                       Assert.AreEqual (Myenum.five, genarr.arr[2]);
+               }
+
+               [Test]
+               public void TestDeserializeGenArrayClassStruct ()
+               {
+                       Deserialize (typeof (GenArrayClass<GenSimpleStruct<uint>>), "<GenArrayClassOfGenSimpleStructOfUInt32 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><arr><GenSimpleStructOfUInt32>0</GenSimpleStructOfUInt32><GenSimpleStructOfUInt32>0</GenSimpleStructOfUInt32><GenSimpleStructOfUInt32>0</GenSimpleStructOfUInt32></arr></GenArrayClassOfGenSimpleStructOfUInt32>");
+                       Assert.AreEqual (typeof (GenArrayClass<GenSimpleStruct<uint>>), result.GetType ());
+                       Deserialize (typeof (GenArrayClass<GenSimpleStruct<uint>>), "<GenArrayClassOfGenSimpleStructOfUInt32 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><arr><GenSimpleStructOfUInt32><something>111</something></GenSimpleStructOfUInt32><GenSimpleStructOfUInt32><something>222</something></GenSimpleStructOfUInt32><GenSimpleStructOfUInt32><something>333</something></GenSimpleStructOfUInt32></arr></GenArrayClassOfGenSimpleStructOfUInt32>");
+                       GenArrayClass<GenSimpleStruct<uint>> genarr = result as GenArrayClass<GenSimpleStruct<uint>>;
+                       Assert.AreEqual (111, genarr.arr[0].something);
+                       Assert.AreEqual (222, genarr.arr[1].something);
+                       Assert.AreEqual (333, genarr.arr[2].something);
+               }
+
+               [Test]
+               public void TestDeserializeGenArrayClassList ()
+               {
+                       Deserialize (typeof (GenArrayClass<GenListClass<string>>), "<GenArrayClassOfGenListClassOfString xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><arr><GenListClassOfString>0</GenListClassOfString><GenListClassOfString>0</GenListClassOfString><GenListClassOfString>0</GenListClassOfString></arr></GenArrayClassOfGenListClassOfString>");
+                       Assert.AreEqual (typeof (GenArrayClass<GenListClass<string>>), result.GetType ());
+                       Deserialize (typeof (GenArrayClass<GenListClass<string>>), "<GenArrayClassOfGenListClassOfString xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><arr><GenListClassOfString><somelist><string>list1-val1</string><string>list1-val2</string></somelist></GenListClassOfString><GenListClassOfString><somelist><string>list2-val1</string><string>list2-val2</string><string>list2-val3</string><string>list2-val4</string></somelist></GenListClassOfString><GenListClassOfString><somelist><string>list3val</string></somelist></GenListClassOfString></arr></GenArrayClassOfGenListClassOfString>");
+                       GenArrayClass<GenListClass<string>> genarr = result as GenArrayClass<GenListClass<string>>;
+                       Assert.AreEqual ("list1-val1", genarr.arr[0].somelist[0]);
+                       Assert.AreEqual ("list1-val2", genarr.arr[0].somelist[1]);
+                       Assert.AreEqual ("list2-val1", genarr.arr[1].somelist[0]);
+                       Assert.AreEqual ("list2-val2", genarr.arr[1].somelist[1]);
+                       Assert.AreEqual ("list2-val3", genarr.arr[1].somelist[2]);
+                       Assert.AreEqual ("list2-val4", genarr.arr[1].somelist[3]);
+                       Assert.AreEqual ("list3val", genarr.arr[2].somelist[0]);
+                       // The code below checks for DotNet bug (see corresponding test in XmlSerializerTests).
+                       Deserialize (typeof (GenArrayClass<GenListClass<string>>), "<GenArrayClassOfGenListClassOfString xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><arr><GenListClassOfString><somelist><string>list1-val1</string><string>list1-val2</string><string>list3val</string></somelist></GenListClassOfString><GenListClassOfString><somelist><string>list2-val1</string><string>list2-val2</string><string>list2-val3</string><string>list2-val4</string></somelist></GenListClassOfString><GenListClassOfString><somelist></somelist></GenListClassOfString></arr></GenArrayClassOfGenListClassOfString>");
+                       GenArrayClass<GenListClass<string>> genarr2 = result as GenArrayClass<GenListClass<string>>;
+                       Assert.AreEqual ("list1-val1", genarr2.arr[0].somelist[0]);
+                       Assert.AreEqual ("list1-val2", genarr2.arr[0].somelist[1]);
+                       /**/
+                       Assert.AreEqual ("list3val", genarr2.arr[0].somelist[2]);
+                       Assert.AreEqual ("list2-val1", genarr2.arr[1].somelist[0]);
+                       Assert.AreEqual ("list2-val2", genarr2.arr[1].somelist[1]);
+                       Assert.AreEqual ("list2-val3", genarr2.arr[1].somelist[2]);
+                       Assert.AreEqual ("list2-val4", genarr2.arr[1].somelist[3]);
+                       //Assert.AreEqual ("list3val", genarr2.arr[2].somelist[0]);
+               }
+
+               [Test]
+               public void TestDeserializeGenComplexStruct ()
+               {
+                       Deserialize (typeof (GenComplexStruct<int, string>), "<GenComplexStructOfInt32String xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something>0</something><simpleclass><something>0</something></simpleclass><simplestruct><something>0</something></simplestruct><listclass><somelist></somelist></listclass><arrayclass><arr><int>0</int><int>0</int><int>0</int></arr></arrayclass><twoclass><something1>0</something1></twoclass><derivedclass><something2>0</something2><another1>0</another1></derivedclass><derived2><something1>0</something1><another1>0</another1></derived2><nestedouter><outer>0</outer></nestedouter><nestedinner><something>0</something></nestedinner></GenComplexStructOfInt32String>");
+                       Assert.AreEqual (typeof (GenComplexStruct<int, string>), result.GetType ());
+                       Deserialize (typeof (GenComplexStruct<int, string>), "<GenComplexStructOfInt32String xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something>123</something><simpleclass><something>456</something></simpleclass><simplestruct><something>789</something></simplestruct><listclass><somelist><int>100</int><int>200</int></somelist></listclass><arrayclass><arr><int>11</int><int>22</int><int>33</int></arr></arrayclass><twoclass><something1>10</something1><something2>Ten</something2></twoclass><derivedclass><something1>two</something1><something2>2</something2><another1>1</another1><another2>one</another2></derivedclass><derived2><something1>4</something1><something2>four</something2><another1>3</another1><another2>three</another2></derived2><nestedouter><outer>5</outer></nestedouter><nestedinner><inner>six</inner><something>6</something></nestedinner></GenComplexStructOfInt32String>");
+                       GenComplexStruct<int, string> complex = new GenComplexStruct<int, string> (0);
+                       if (result != null)
+                               complex = (GenComplexStruct<int, string>) result;
+                       Assert.AreEqual (123, complex.something);
+                       Assert.AreEqual (456, complex.simpleclass.something);
+                       Assert.AreEqual (789, complex.simplestruct.something);
+                       Assert.AreEqual (100, complex.listclass.somelist[0]);
+                       Assert.AreEqual (200, complex.listclass.somelist[1]);
+                       Assert.AreEqual (11, complex.arrayclass.arr[0]);
+                       Assert.AreEqual (22, complex.arrayclass.arr[1]);
+                       Assert.AreEqual (33, complex.arrayclass.arr[2]);
+                       Assert.AreEqual (10, complex.twoclass.something1);
+                       Assert.AreEqual ("Ten", complex.twoclass.something2);
+                       Assert.AreEqual (1, complex.derivedclass.another1);
+                       Assert.AreEqual ("one", complex.derivedclass.another2);
+                       Assert.AreEqual ("two", complex.derivedclass.something1);
+                       Assert.AreEqual (2, complex.derivedclass.something2);
+                       Assert.AreEqual (3, complex.derived2.another1);
+                       Assert.AreEqual ("three", complex.derived2.another2);
+                       Assert.AreEqual (4, complex.derived2.something1);
+                       Assert.AreEqual ("four", complex.derived2.something2);
+                       Assert.AreEqual (5, complex.nestedouter.outer);
+                       Assert.AreEqual ("six", complex.nestedinner.inner);
+                       Assert.AreEqual (6, complex.nestedinner.something);
+               }
+#endif
+
+               #endregion //GenericsDeseralizationTests
+
                [Test]
                public void TestDeserializeCollection ()
                {
                        string s0 = "";
-                       s0+="   <ArrayOfEntity xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s0+="           <Entity Name='node1'/>";
-                       s0+="           <Entity Name='node2'/>";
-                       s0+="   </ArrayOfEntity>";
-                       
-                       EntityCollection col = (EntityCollection) Deserialize (typeof(EntityCollection), s0);
+                       s0 += " <ArrayOfEntity xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s0 += "         <Entity Name='node1'/>";
+                       s0 += "         <Entity Name='node2'/>";
+                       s0 += " </ArrayOfEntity>";
+
+                       EntityCollection col = (EntityCollection) Deserialize (typeof (EntityCollection), s0);
                        Assert.IsNotNull (col, "#1");
                        Assert.AreEqual (2, col.Count, "#2");
                        Assert.IsNull (col[0].Parent, "#3");
                        Assert.IsNull (col[1].Parent, "#4");
                }
-               
+
                [Test]
                public void TestDeserializeEmptyCollection ()
                {
                        string s1 = "";
-                       s1+="   <ArrayOfEntity xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
-                       
-                       EntityCollection col = (EntityCollection) Deserialize (typeof(EntityCollection), s1);
+                       s1 += " <ArrayOfEntity xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
+
+                       EntityCollection col = (EntityCollection) Deserialize (typeof (EntityCollection), s1);
                        Assert.IsNotNull (col, "#A1");
                        Assert.AreEqual (0, col.Count, "#A2");
-                       
+
                        string s1_1 = "";
-                       s1_1+=" <ArrayOfEntity xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s1_1+=" </ArrayOfEntity>";
-                       
-                       col = (EntityCollection) Deserialize (typeof(EntityCollection), s1_1);
+                       s1_1 += "       <ArrayOfEntity xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s1_1 += "       </ArrayOfEntity>";
+
+                       col = (EntityCollection) Deserialize (typeof (EntityCollection), s1_1);
                        Assert.IsNotNull (col, "#B1");
                        Assert.AreEqual (0, col.Count, "#B2");
                }
-               
+
                [Test]
                public void TestDeserializeNilCollectionIsNotNull ()
                {
                        string s2 = "";
-                       s2+="   <ArrayOfEntity xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true'/>";
-                       
-                       EntityCollection col = (EntityCollection) Deserialize (typeof(EntityCollection), s2);
+                       s2 += " <ArrayOfEntity xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true'/>";
+
+                       EntityCollection col = (EntityCollection) Deserialize (typeof (EntityCollection), s2);
                        Assert.IsNotNull (col, "#1");
                        Assert.AreEqual (0, col.Count, "#2");
                }
-               
+
                [Test]
                public void TestDeserializeObjectCollections ()
                {
                        string s3 = "";
-                       s3+="<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s3+="   <Collection1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s3+="           <Entity Name='node1'/>";
-                       s3+="           <Entity Name='node2'/>";
-                       s3+="   </Collection1>";
-                       s3+="   <Collection2 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s3+="           <Entity Name='node1'/>";
-                       s3+="           <Entity Name='node2'/>";
-                       s3+="   </Collection2>";
-                       s3+="   <Collection3 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s3+="           <Entity Name='node1'/>";
-                       s3+="           <Entity Name='node2'/>";
-                       s3+="   </Collection3>";
-                       s3+="   <Collection4 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s3+="           <Entity Name='node1'/>";
-                       s3+="           <Entity Name='node2'/>";
-                       s3+="   </Collection4>";
-                       s3+="</Container>";
-                       
-                       EntityContainer cont = (EntityContainer) Deserialize (typeof(EntityContainer), s3);
+                       s3 += "<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s3 += " <Collection1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s3 += "         <Entity Name='node1'/>";
+                       s3 += "         <Entity Name='node2'/>";
+                       s3 += " </Collection1>";
+                       s3 += " <Collection2 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s3 += "         <Entity Name='node1'/>";
+                       s3 += "         <Entity Name='node2'/>";
+                       s3 += " </Collection2>";
+                       s3 += " <Collection3 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s3 += "         <Entity Name='node1'/>";
+                       s3 += "         <Entity Name='node2'/>";
+                       s3 += " </Collection3>";
+                       s3 += " <Collection4 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s3 += "         <Entity Name='node1'/>";
+                       s3 += "         <Entity Name='node2'/>";
+                       s3 += " </Collection4>";
+                       s3 += "</Container>";
+
+                       EntityContainer cont = (EntityContainer) Deserialize (typeof (EntityContainer), s3);
                        Assert.IsNotNull (cont, "#A1");
 
                        Assert.IsNotNull (cont.Collection1, "#B1");
@@ -370,15 +612,15 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual ("root", cont.Collection4[0].Parent, "#E4");
                        Assert.AreEqual ("root", cont.Collection4[1].Parent, "#E5");
                }
-               
+
                [Test]
                public void TestDeserializeEmptyObjectCollections ()
                {
                        string s4 = "";
-                       s4+="<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s4+="</Container>";
-                       
-                       EntityContainer cont = (EntityContainer) Deserialize (typeof(EntityContainer), s4);
+                       s4 += "<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s4 += "</Container>";
+
+                       EntityContainer cont = (EntityContainer) Deserialize (typeof (EntityContainer), s4);
                        Assert.IsNotNull (cont, "#A1");
 
                        Assert.IsNotNull (cont.Collection1, "#B1");
@@ -402,14 +644,14 @@ namespace MonoTests.System.XmlSerialization
                public void TestDeserializeObjectNilCollectionsAreNotNull ()
                {
                        string s5 = "";
-                       s5+="<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s5+="   <Collection1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
-                       s5+="   <Collection2 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
-                       s5+="   <Collection3 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
-                       s5+="   <Collection4 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
-                       s5+="</Container>";
-                       
-                       EntityContainer cont = (EntityContainer) Deserialize (typeof(EntityContainer), s5);
+                       s5 += "<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s5 += " <Collection1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
+                       s5 += " <Collection2 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
+                       s5 += " <Collection3 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
+                       s5 += " <Collection4 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
+                       s5 += "</Container>";
+
+                       EntityContainer cont = (EntityContainer) Deserialize (typeof (EntityContainer), s5);
                        Assert.IsNotNull (cont, "#A1");
 
                        Assert.IsNotNull (cont.Collection1, "#B1");
@@ -428,19 +670,19 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (0, cont.Collection4.Count, "#E2");
                        Assert.AreEqual ("root", cont.Collection4.Container, "#E3");
                }
-               
+
                [Test]
                public void TestDeserializeObjectEmptyCollections ()
                {
                        string s6 = "";
-                       s6+="<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s6+="   <Collection1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
-                       s6+="   <Collection2 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
-                       s6+="   <Collection3 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
-                       s6+="   <Collection4 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
-                       s6+="</Container>";
-                       
-                       EntityContainer cont = (EntityContainer) Deserialize (typeof(EntityContainer), s6);
+                       s6 += "<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s6 += " <Collection1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
+                       s6 += " <Collection2 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
+                       s6 += " <Collection3 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
+                       s6 += " <Collection4 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
+                       s6 += "</Container>";
+
+                       EntityContainer cont = (EntityContainer) Deserialize (typeof (EntityContainer), s6);
                        Assert.IsNotNull (cont, "#A1");
 
                        Assert.IsNotNull (cont.Collection1, "#B1");
@@ -459,19 +701,19 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (0, cont.Collection4.Count, "#E2");
                        Assert.AreEqual ("root", cont.Collection4.Container, "#E3");
                }
-               
+
                [Test]
                public void TestDeserializeObjectEmptyArrays ()
                {
                        string s6 = "";
-                       s6+="<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s6+="   <Collection1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
-                       s6+="   <Collection2 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
-                       s6+="   <Collection3 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
-                       s6+="   <Collection4 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
-                       s6+="</Container>";
-                       
-                       ArrayEntityContainer cont = (ArrayEntityContainer) Deserialize (typeof(ArrayEntityContainer), s6);
+                       s6 += "<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s6 += " <Collection1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
+                       s6 += " <Collection2 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
+                       s6 += " <Collection3 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
+                       s6 += " <Collection4 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
+                       s6 += "</Container>";
+
+                       ArrayEntityContainer cont = (ArrayEntityContainer) Deserialize (typeof (ArrayEntityContainer), s6);
                        Assert.IsNotNull (cont, "#A1");
 
                        Assert.IsNotNull (cont.Collection1, "#B1");
@@ -486,15 +728,15 @@ namespace MonoTests.System.XmlSerialization
                        Assert.IsNotNull (cont.Collection4, "#E1");
                        Assert.AreEqual (0, cont.Collection4.Length, "#E2");
                }
-               
+
                [Test]
                public void TestDeserializeEmptyObjectArrays ()
                {
                        string s4 = "";
-                       s4+="<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s4+="</Container>";
-                       
-                       ArrayEntityContainer cont = (ArrayEntityContainer) Deserialize (typeof(ArrayEntityContainer), s4);
+                       s4 += "<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s4 += "</Container>";
+
+                       ArrayEntityContainer cont = (ArrayEntityContainer) Deserialize (typeof (ArrayEntityContainer), s4);
                        Assert.IsNotNull (cont, "#A1");
 
                        Assert.IsNull (cont.Collection1, "#B1");
@@ -506,19 +748,19 @@ namespace MonoTests.System.XmlSerialization
                        Assert.IsNotNull (cont.Collection4, "#D1");
                        Assert.AreEqual (0, cont.Collection4.Length, "#D2");
                }
-               
+
                [Test]
                public void TestDeserializeObjectNilArrays ()
                {
                        string s5 = "";
-                       s5+="<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s5+="   <Collection1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
-                       s5+="   <Collection2 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
-                       s5+="   <Collection3 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
-                       s5+="   <Collection4 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
-                       s5+="</Container>";
-                       
-                       ArrayEntityContainer cont = (ArrayEntityContainer) Deserialize (typeof(ArrayEntityContainer), s5);
+                       s5 += "<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s5 += " <Collection1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
+                       s5 += " <Collection2 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
+                       s5 += " <Collection3 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
+                       s5 += " <Collection4 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true' />";
+                       s5 += "</Container>";
+
+                       ArrayEntityContainer cont = (ArrayEntityContainer) Deserialize (typeof (ArrayEntityContainer), s5);
                        Assert.IsNotNull (cont, "#A1");
 
                        Assert.IsNull (cont.Collection1, "#B1");
@@ -528,48 +770,48 @@ namespace MonoTests.System.XmlSerialization
                        Assert.IsNotNull (cont.Collection4, "#C1");
                        Assert.AreEqual (0, cont.Collection4.Length, "#C2");
                }
-               
+
                [Test]
                public void TestDeserializeEmptyArray ()
                {
                        string s1 = "";
-                       s1+="<ArrayOfEntity xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
-                       
-                       Entity[] col = (Entity[]) Deserialize (typeof(Entity[]), s1);
+                       s1 += "<ArrayOfEntity xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />";
+
+                       Entity[] col = (Entity[]) Deserialize (typeof (Entity[]), s1);
                        Assert.IsNotNull (col, "#A1");
                        Assert.AreEqual (0, col.Length, "#A2");
-                       
+
                        string s1_1 = "";
-                       s1_1+=" <ArrayOfEntity xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s1_1+=" </ArrayOfEntity>";
-                       
-                       col = (Entity[]) Deserialize (typeof(Entity[]), s1_1);
+                       s1_1 += "       <ArrayOfEntity xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s1_1 += "       </ArrayOfEntity>";
+
+                       col = (Entity[]) Deserialize (typeof (Entity[]), s1_1);
                        Assert.IsNotNull (col, "#B1");
                        Assert.AreEqual (0, col.Length, "#B2");
                }
-               
+
                [Test]
                public void TestDeserializeNilArray ()
                {
                        string s2 = "";
                        s2 += "<ArrayOfEntity xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true'/>";
-                       
-                       Entity[] col = (Entity[]) Deserialize (typeof(Entity[]), s2);
+
+                       Entity[] col = (Entity[]) Deserialize (typeof (Entity[]), s2);
                        Assert.IsNull (col, "#1");
                }
-               
+
                [Test]
                public void TestDeserializeObjectWithReadonlyCollection ()
                {
                        string s3 = "";
-                       s3+="<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s3+="   <Collection1>";
-                       s3+="           <Entity Name='node1'/>";
-                       s3+="           <Entity Name='node2'/>";
-                       s3+="   </Collection1>";
-                       s3+="</Container>";
-                       
-                       ObjectWithReadonlyCollection cont = (ObjectWithReadonlyCollection) Deserialize (typeof(ObjectWithReadonlyCollection), s3);
+                       s3 += "<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s3 += " <Collection1>";
+                       s3 += "         <Entity Name='node1'/>";
+                       s3 += "         <Entity Name='node2'/>";
+                       s3 += " </Collection1>";
+                       s3 += "</Container>";
+
+                       ObjectWithReadonlyCollection cont = (ObjectWithReadonlyCollection) Deserialize (typeof (ObjectWithReadonlyCollection), s3);
                        Assert.IsNotNull (cont, "#1");
                        Assert.IsNotNull (cont.Collection1, "#2");
                        Assert.AreEqual (2, cont.Collection1.Count, "#3");
@@ -577,34 +819,34 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual ("root", cont.Collection1[0].Parent, "#5");
                        Assert.AreEqual ("root", cont.Collection1[1].Parent, "#6");
                }
-               
+
                [Test]
-               [ExpectedException (typeof(InvalidOperationException))]
+               [ExpectedException (typeof (InvalidOperationException))]
                public void TestDeserializeObjectWithReadonlyNulCollection ()
                {
                        string s3 = "";
-                       s3+="<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s3+="   <Collection1>";
-                       s3+="           <Entity Name='node1'/>";
-                       s3+="           <Entity Name='node2'/>";
-                       s3+="   </Collection1>";
-                       s3+="</Container>";
-                       
-                       Deserialize (typeof(ObjectWithReadonlyNulCollection), s3);
+                       s3 += "<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s3 += " <Collection1>";
+                       s3 += "         <Entity Name='node1'/>";
+                       s3 += "         <Entity Name='node2'/>";
+                       s3 += " </Collection1>";
+                       s3 += "</Container>";
+
+                       Deserialize (typeof (ObjectWithReadonlyNulCollection), s3);
                }
-               
+
                [Test]
                public void TestDeserializeObjectWithReadonlyArray ()
                {
                        string s3 = "";
-                       s3+="<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
-                       s3+="   <Collection1>";
-                       s3+="           <Entity Name='node1'/>";
-                       s3+="           <Entity Name='node2'/>";
-                       s3+="   </Collection1>";
-                       s3+="</Container>";
-                       
-                       ObjectWithReadonlyArray cont = (ObjectWithReadonlyArray) Deserialize (typeof(ObjectWithReadonlyArray), s3);
+                       s3 += "<Container xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       s3 += " <Collection1>";
+                       s3 += "         <Entity Name='node1'/>";
+                       s3 += "         <Entity Name='node2'/>";
+                       s3 += " </Collection1>";
+                       s3 += "</Container>";
+
+                       ObjectWithReadonlyArray cont = (ObjectWithReadonlyArray) Deserialize (typeof (ObjectWithReadonlyArray), s3);
                        Assert.IsNotNull (cont, "#1");
                        Assert.IsNotNull (cont.Collection1, "#2");
                        Assert.AreEqual (0, cont.Collection1.Length, "#3");
@@ -639,7 +881,8 @@ namespace MonoTests.System.XmlSerialization
                        try {
                                Deserialize (typeof (EnumDefaultValueNF), "<EnumDefaultValueNF />");
                                Assert.Fail ("#B1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
                                Assert.IsNotNull (ex.InnerException, "#B3");
                                Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#B4");
@@ -651,7 +894,8 @@ namespace MonoTests.System.XmlSerialization
                        try {
                                Deserialize (typeof (EnumDefaultValueNF), "<EnumDefaultValueNF>e1 e3</EnumDefaultValueNF>");
                                Assert.Fail ("#C1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#C2");
                                Assert.IsNotNull (ex.InnerException, "#C3");
                                Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#C4");
@@ -663,7 +907,8 @@ namespace MonoTests.System.XmlSerialization
                        try {
                                Deserialize (typeof (EnumDefaultValueNF), "<EnumDefaultValueNF> e3</EnumDefaultValueNF>");
                                Assert.Fail ("#D1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
                                Assert.IsNotNull (ex.InnerException, "#D3");
                                Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#D4");
@@ -675,7 +920,8 @@ namespace MonoTests.System.XmlSerialization
                        try {
                                Deserialize (typeof (EnumDefaultValueNF), "<EnumDefaultValueNF> </EnumDefaultValueNF>");
                                Assert.Fail ("#E1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
                                Assert.IsNotNull (ex.InnerException, "#E3");
                                Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#E4");
@@ -687,7 +933,8 @@ namespace MonoTests.System.XmlSerialization
                        try {
                                Deserialize (typeof (EnumDefaultValueNF), "<EnumDefaultValueNF>1</EnumDefaultValueNF>");
                                Assert.Fail ("#F1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#F2");
                                Assert.IsNotNull (ex.InnerException, "#F3");
                                Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#F4");
@@ -698,7 +945,6 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotWorking")] // DefaultValue should not be used when deserializing
                public void TestDeserialize_Field ()
                {
                        Field f = null;
@@ -757,7 +1003,8 @@ namespace MonoTests.System.XmlSerialization
                                        "<field xmlns:xsd='{0}' xmlns:xsi='{1}' flag2='444' />",
                                        XmlSchemaNamespace, XmlSchemaInstanceNamespace));
                                Assert.Fail ("#D1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                // There was an error generating the XML document
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
                                Assert.IsNotNull (ex.Message, "#D3");
@@ -777,7 +1024,8 @@ namespace MonoTests.System.XmlSerialization
                                        "<field xmlns:xsd='{0}' xmlns:xsi='{1}' flag2='Garbage' />",
                                        XmlSchemaNamespace, XmlSchemaInstanceNamespace));
                                Assert.Fail ("#E1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                // There was an error generating the XML document
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
                                Assert.IsNotNull (ex.Message, "#E3");
@@ -797,7 +1045,8 @@ namespace MonoTests.System.XmlSerialization
                                        "<field xmlns:xsd='{0}' xmlns:xsi='{1}' flag2='{2}' />",
                                        XmlSchemaNamespace, XmlSchemaInstanceNamespace, ((int) FlagEnum.e2).ToString (CultureInfo.InvariantCulture)));
                                Assert.Fail ("#F1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                // There was an error generating the XML document
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#F2");
                                Assert.IsNotNull (ex.Message, "#F3");
@@ -813,7 +1062,7 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotDotNet")] // MS.NET does not allow SoapAttribute backed by enum ??
+               [Category ("NotDotNet")] // MS.NET results in compilation error (probably it generates bogus source.)
                public void TestDeserialize_Field_Encoded ()
                {
                        Field_Encoded f = null;
@@ -824,7 +1073,7 @@ namespace MonoTests.System.XmlSerialization
                                XmlSchemaNamespace, XmlSchemaInstanceNamespace, ANamespace));
                        Assert.AreEqual ((FlagEnum_Encoded) 0, f.Flags1, "#A1");
                        Assert.AreEqual ((FlagEnum_Encoded) 0, f.Flags2, "#A2");
-                       Assert.AreEqual (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e2, f.Flags3, "#A3");
+                       Assert.AreEqual ((FlagEnum_Encoded) 0, f.Flags3, "#A3");
                        Assert.AreEqual ((FlagEnum_Encoded) 0, f.Flags4, "#A4");
                        Assert.AreEqual (MapModifiers.Public, f.Modifiers, "#A5");
                        Assert.AreEqual (MapModifiers.Public, f.Modifiers2, "#A6");
@@ -838,14 +1087,14 @@ namespace MonoTests.System.XmlSerialization
                                string.Format (CultureInfo.InvariantCulture, "<?xml version='1.0' encoding='utf-16'?>" +
                                "<q1:field xmlns:xsd='{0}' xmlns:xsi='{1}' id='id1' flag3='two' flag4='' modifiers='Protected' modifiers2='PuBlIc' xmlns:q1='{2}' />",
                                XmlSchemaNamespace, XmlSchemaInstanceNamespace, ANamespace));
-                       Assert.AreEqual (FlagEnum_Encoded.e1, f.Flags1, "#B1");
-                       Assert.AreEqual (FlagEnum_Encoded.e1, f.Flags2, "#B2");
+                       Assert.AreEqual ((FlagEnum_Encoded) 0, f.Flags1, "#B1");
+                       Assert.AreEqual ((FlagEnum_Encoded) 0, f.Flags2, "#B2");
                        Assert.AreEqual (FlagEnum_Encoded.e2, f.Flags3, "#B3");
                        Assert.AreEqual ((FlagEnum_Encoded) 0, f.Flags4, "#B4");
                        Assert.AreEqual (MapModifiers.Protected, f.Modifiers, "#B5");
                        Assert.AreEqual (MapModifiers.Public, f.Modifiers2, "#B6");
                        Assert.AreEqual (MapModifiers.Public, f.Modifiers3, "#B7");
-                       Assert.AreEqual (MapModifiers.Protected, f.Modifiers4, "#B8");
+                       Assert.AreEqual (MapModifiers.Public, f.Modifiers4, "#B8");
                        Assert.AreEqual (MapModifiers.Public, f.Modifiers5, "#B9");
                        Assert.IsNull (f.Names, "#B10");
                        Assert.IsNull (f.Street, "#B11");
@@ -856,7 +1105,7 @@ namespace MonoTests.System.XmlSerialization
                                XmlSchemaNamespace, XmlSchemaInstanceNamespace, ANamespace));
                        Assert.AreEqual (FlagEnum_Encoded.e2, f.Flags1, "#C1");
                        Assert.AreEqual (FlagEnum_Encoded.e2, f.Flags2, "#C2");
-                       Assert.AreEqual (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e2, f.Flags3, "#C3");
+                       Assert.AreEqual ((FlagEnum_Encoded) 0, f.Flags3, "#C3");
                        Assert.AreEqual ((FlagEnum_Encoded) 0, f.Flags4, "#C4");
                        Assert.AreEqual (MapModifiers.Public, f.Modifiers, "#C5");
                        Assert.AreEqual (MapModifiers.Protected, f.Modifiers2, "#C6");
@@ -872,7 +1121,8 @@ namespace MonoTests.System.XmlSerialization
                                        "<q1:field xmlns:xsd='{0}' xmlns:xsi='{1}' id='id1' flag2='444' flag3='555' flag4='' modifiers='666' modifiers2='777' modifiers4='888' modifiers5='999' xmlns:q1='{2}' />",
                                        XmlSchemaNamespace, XmlSchemaInstanceNamespace, ANamespace));
                                Assert.Fail ("#D1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                // There was an error generating the XML document
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
                                Assert.IsNotNull (ex.Message, "#D3");
@@ -910,7 +1160,7 @@ namespace MonoTests.System.XmlSerialization
                        e = (FlagEnum) Deserialize (typeof (FlagEnum), "<FlagEnum>two four two</FlagEnum>");
                        Assert.AreEqual (FlagEnum.e2 | FlagEnum.e4, e, "#A6");
 
-                       e = (FlagEnum) Deserialize (typeof (FlagEnum), "<FlagEnum>two four two\tone\u2002four\u200btwo one</FlagEnum>");
+                       e = (FlagEnum) Deserialize (typeof (FlagEnum), "<FlagEnum>two four two\tone\u2002four\rtwo one</FlagEnum>");
                        Assert.AreEqual (FlagEnum.e1 | FlagEnum.e2 | FlagEnum.e4, e, "#A7");
 
                        e = (FlagEnum) Deserialize (typeof (FlagEnum), "<FlagEnum></FlagEnum>");
@@ -922,7 +1172,8 @@ namespace MonoTests.System.XmlSerialization
                        try {
                                Deserialize (typeof (FlagEnum), "<FlagEnum>1</FlagEnum>");
                                Assert.Fail ("#B1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
                                Assert.IsNotNull (ex.InnerException, "#B3");
                                Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#B4");
@@ -934,7 +1185,8 @@ namespace MonoTests.System.XmlSerialization
                        try {
                                Deserialize (typeof (FlagEnum), "<FlagEnum>one,two</FlagEnum>");
                                Assert.Fail ("#C1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#C2");
                                Assert.IsNotNull (ex.InnerException, "#C3");
                                Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#C4");
@@ -946,7 +1198,8 @@ namespace MonoTests.System.XmlSerialization
                        try {
                                Deserialize (typeof (FlagEnum), "<FlagEnum>one something</FlagEnum>");
                                Assert.Fail ("#D1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
                                Assert.IsNotNull (ex.InnerException, "#D3");
                                Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#D4");
@@ -980,7 +1233,7 @@ namespace MonoTests.System.XmlSerialization
 
                        Assert.AreEqual (new DateTime (2002, 5, 2), group.Today, "#A1");
                        Assert.AreEqual (".NET", group.GroupName, "#A2");
-                       Assert.AreEqual (new byte [] { 0x64, 0x32 }, group.GroupNumber, "#A3");
+                       Assert.AreEqual (new byte[] { 0x64, 0x32 }, group.GroupNumber, "#A3");
                        Assert.AreEqual (GroupType.A, group.Grouptype, "#A4");
                        Assert.AreEqual ("10000", group.PostitiveInt, "#A5");
                        Assert.IsFalse (group.IgnoreThis, "#A6");
@@ -1010,7 +1263,7 @@ namespace MonoTests.System.XmlSerialization
 
                        Assert.AreEqual (new DateTime (2002, 5, 2), group.Today, "#B1");
                        Assert.IsNull (group.GroupName, "#B2");
-                       Assert.AreEqual (new byte [] { 0x64, 0x32 }, group.GroupNumber, "#B3");
+                       Assert.AreEqual (new byte[] { 0x64, 0x32 }, group.GroupNumber, "#B3");
                        Assert.AreEqual (GroupType.B, group.Grouptype, "#B4");
                        Assert.AreEqual ("10000", group.PostitiveInt, "#B5");
                        Assert.IsFalse (group.IgnoreThis, "#B6");
@@ -1053,7 +1306,8 @@ namespace MonoTests.System.XmlSerialization
                        try {
                                group = (Group) DeserializeEncoded (typeof (Group), xtr);
                                Assert.Fail ("#D1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                // There is an error in XML document (1, 174)
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
                                Assert.IsNotNull (ex.Message, "#D3");
@@ -1081,7 +1335,8 @@ namespace MonoTests.System.XmlSerialization
                        try {
                                group = (Group) DeserializeEncoded (typeof (Group), xtr);
                                Assert.Fail ("#E1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                // There is an error in XML document (1, 178)
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#E2");
                                Assert.IsNotNull (ex.Message, "#E3");
@@ -1110,7 +1365,8 @@ namespace MonoTests.System.XmlSerialization
                        try {
                                group = (Group) DeserializeEncoded (typeof (Group), xtr);
                                Assert.Fail ("#F1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                // There is an error in XML document (1, 172)
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#F2");
                                Assert.IsNotNull (ex.Message, "#F3");
@@ -1138,7 +1394,8 @@ namespace MonoTests.System.XmlSerialization
                        try {
                                Deserialize (typeof (ZeroFlagEnum), "<ZeroFlagEnum>four</ZeroFlagEnum>");
                                Assert.Fail ("#B1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
                                Assert.IsNotNull (ex.InnerException, "#B3");
                                Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#B4");
@@ -1150,7 +1407,8 @@ namespace MonoTests.System.XmlSerialization
                        try {
                                Deserialize (typeof (ZeroFlagEnum), "<ZeroFlagEnum> o&lt;n&gt;e  four </ZeroFlagEnum>");
                                Assert.Fail ("#C1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#C2");
                                Assert.IsNotNull (ex.InnerException, "#C3");
                                Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#C4");
@@ -1162,7 +1420,8 @@ namespace MonoTests.System.XmlSerialization
                        try {
                                Deserialize (typeof (ZeroFlagEnum), "<ZeroFlagEnum>four o&lt;n&gt;e</ZeroFlagEnum>");
                                Assert.Fail ("#D1");
-                       } catch (InvalidOperationException ex) {
+                       }
+                       catch (InvalidOperationException ex) {
                                Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
                                Assert.IsNotNull (ex.InnerException, "#D3");
                                Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#D4");
@@ -1175,7 +1434,7 @@ namespace MonoTests.System.XmlSerialization
                [Test]
                public void TestDeserialize_PrimitiveTypesContainer ()
                {
-                       Deserialize (typeof (PrimitiveTypesContainer), string.Format (CultureInfo.InvariantCulture, 
+                       Deserialize (typeof (PrimitiveTypesContainer), string.Format (CultureInfo.InvariantCulture,
                                "<?xml version='1.0' encoding='utf-16'?>" +
                                "<PrimitiveTypesContainer xmlns:xsd='{0}' xmlns:xsi='{1}' xmlns='{2}'>" +
                                "<Number xsi:type='xsd:int'>2004</Number>" +
@@ -1213,5 +1472,197 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (new byte[] { 243, 15 }, deserialized.Password, "#B5");
                        Assert.AreEqual ('/', deserialized.PathSeparatorCharacter, "#B6");
                }
+
+               [Test] // bug #378696
+               public void DoNotFillDefaultValue ()
+               {
+                       XmlSerializer xs = new XmlSerializer (typeof (DefaultDateTimeContainer));
+                       DefaultDateTimeContainer o = (DefaultDateTimeContainer) xs.Deserialize (new StringReader ("<DefaultDateTimeContainer xmlns='urn:foo' />"));
+                       // do not fill DefaultValue / do not bork at generating code.
+                       Assert.AreEqual (DateTime.MinValue, o.FancyDateTime, "#1");
+                       Assert.AreEqual (0, o.Numeric, "#2");
+               }
+               
+               [Test] // bug bxc 4367
+               public void SpecifiedXmlIgnoreTest ()
+               {
+                       XmlReflectionMember [] out_members = new XmlReflectionMember [2];
+                       XmlReflectionMember m;
+                       
+                       m = new XmlReflectionMember ();
+                       m.IsReturnValue = false;
+                       m.MemberName = "HasPermissionsForUserResult";
+                       m.MemberType = typeof (bool);
+                       m.SoapAttributes = new SoapAttributes ();
+                       m.XmlAttributes = new XmlAttributes ();
+                       out_members [0] = m;
+                       
+                       m = new XmlReflectionMember ();
+                       m.IsReturnValue = false;
+                       m.MemberName = "HasPermissionsForUserResultSpecified";
+                       m.MemberType = typeof (bool);
+                       m.SoapAttributes = new SoapAttributes ();
+                       m.XmlAttributes = new XmlAttributes ();
+                       m.XmlAttributes.XmlIgnore = true;
+                       out_members [1] = m;
+                       
+                       XmlReflectionImporter xmlImporter = new XmlReflectionImporter ();
+                       XmlMembersMapping OutputMembersMapping = xmlImporter.ImportMembersMapping ("HasPermissionsForUserResponse", "http://tempuri.org", out_members, true);
+                       XmlSerializer xmlSerializer = XmlSerializer.FromMappings (new XmlMapping [] { OutputMembersMapping }) [0];
+                       
+                       Assert.AreEqual (2, OutputMembersMapping.Count, "#count");
+                       
+                       string msg = @"
+                       <HasPermissionsForUserResponse xmlns=""http://tempuri.org/"">
+                               <HasPermissionsForUserResult>true</HasPermissionsForUserResult>
+                       </HasPermissionsForUserResponse>
+                       ";
+                       
+                       object res = xmlSerializer.Deserialize (new StringReader (msg));
+                       Assert.AreEqual (typeof (object[]), res.GetType (), "type");
+                       Assert.AreEqual (2, ((object[]) res).Length, "length");
+               }
+               
+               [Test]
+               public void InvalidNullableTypeTest ()
+               {
+                       XmlReflectionMember [] out_members = new XmlReflectionMember [1];
+                       XmlReflectionMember m;
+                       
+                       m = new XmlReflectionMember ();
+                       m.IsReturnValue = false;
+                       m.MemberName = "HasPermissionsForUserResultSpecified";
+                       m.MemberType = typeof (bool);
+                       m.SoapAttributes = new SoapAttributes ();
+                       m.XmlAttributes = new XmlAttributes ();
+                       m.XmlAttributes.XmlIgnore = true;
+                       m.XmlAttributes.XmlElements.Add (new XmlElementAttribute () { IsNullable = true });
+                       out_members [0] = m;
+                       
+                       XmlReflectionImporter xmlImporter = new XmlReflectionImporter ();
+                       
+                       try {
+                               xmlImporter.ImportMembersMapping ("HasPermissionsForUserResponse", "http://tempuri.org", out_members, true);
+                               Assert.Fail ("Expected InvalidOperationException");
+                       } catch (InvalidOperationException) {
+                       }
+               }
+
+               [Test]
+               public void NotExactDateParse ()
+               {
+                       XmlSerializer xs = new XmlSerializer (typeof (NotExactDateParseClass));
+                       NotExactDateParseClass o = (NotExactDateParseClass) xs.Deserialize (new StringReader ("<NotExactDateParseClass xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><SomeDate xsi:type=\"xsd:date\">2012-02-05-09:00</SomeDate></NotExactDateParseClass>"));
+                       Assert.AreEqual (new DateTime (2012,2,5), o.SomeDate);
+               }
+
+
+               public class Foo
+               {
+                       public DateTime? Baz { get; set; }
+               }
+
+               [Test]
+               public void CanDeserializeXsiNil()
+               {
+                       var reader = new StringReader(
+@"<Foo xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">
+       <Baz xsi:nil=""true"" />
+</Foo>");
+
+                       using (var xmlReader = new XmlTextReader(reader))
+                       {
+                               var serializer = new XmlSerializer(typeof(Foo));
+                               var foo = (Foo)serializer.Deserialize(xmlReader);
+                               Assert.IsNull(foo.Baz);
+                       }
+               }
+
+               public class Bar
+               {
+                       [XmlElement("baz")]
+                       public DateTime? Baz { get; set; }
+               }
+
+               [Test]
+               public void CanDeserializeXsiNilToAPropertyWithXmlElementAttrib()
+               {
+                       var reader = new StringReader(
+@"<Bar xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">
+       <baz xsi:nil=""true"" />
+</Bar>");
+
+                       using (var xmlReader = new XmlTextReader(reader))
+                       {
+                               var serializer = new XmlSerializer(typeof(Bar));
+                               var bar = (Bar)serializer.Deserialize(xmlReader);
+                               Assert.IsNull(bar.Baz);
+                       }
+               }
+
+               public class FooBar
+               {
+                       [XmlElement("baz", IsNullable = true)]
+                       public DateTime? Baz { get; set; }
+               }
+
+               [Test]
+               public void CanDeserializeXsiNilToAPropertyWithXmlElementAttribAndIsNullableTrue()
+               {
+                       var reader = new StringReader(
+@"<FooBar xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">
+       <baz xsi:nil=""true"" />
+</FooBar>");
+
+                       using (var xmlReader = new XmlTextReader(reader))
+                       {
+                               var serializer = new XmlSerializer(typeof(FooBar));
+                               var foobar = (FooBar)serializer.Deserialize(xmlReader);
+                               Assert.IsNull(foobar.Baz);
+                       }
+               }
+
+               [Test] // bug #8468
+               public void TestUseSubclassDefaultNamespace ()
+               {
+                       XmlSerializer xs = new XmlSerializer (typeof (Bug8468Subclass));
+                       string msg = "<Test xmlns=\"http://test-namespace\"><Base>BaseValue</Base><Mid>MidValue</Mid></Test>";
+                       var res1 = (Bug8468Subclass)xs.Deserialize (new StringReader (msg));
+                       Assert.IsNotNull (res1);
+                       Assert.AreEqual ("BaseValue", res1.Base);
+                       Assert.AreEqual ("MidValue", res1.Mid);
+
+                       xs = new XmlSerializer (typeof (Bug8468SubclassNoNamespace), "http://test-namespace");
+                       var res2 = (Bug8468SubclassNoNamespace)xs.Deserialize (new StringReader (msg));
+                       Assert.IsNotNull (res2);
+                       Assert.AreEqual ("BaseValue", res2.Base);
+                       Assert.AreEqual ("MidValue", res2.Mid);
+
+                       xs = new XmlSerializer (typeof (Bug8468SubclassV2));
+                       var res3 = (Bug8468SubclassV2)xs.Deserialize (new StringReader (msg));
+                       Assert.IsNotNull (res3);
+                       Assert.IsNull (res3.Base);
+                       Assert.AreEqual ("MidValue", res3.Mid);
+
+                       xs = new XmlSerializer (typeof (Bug8468SubclassNoNamespaceV2), "http://test-namespace");
+                       var res4 = (Bug8468SubclassNoNamespaceV2)xs.Deserialize (new StringReader (msg));
+                       Assert.IsNotNull (res4);
+                       Assert.IsNull (res4.Base);
+                       Assert.AreEqual ("MidValue", res4.Mid);
+
+                       msg = "<Test xmlns=\"http://test-namespace\"><Base xmlns=\"\">BaseValue</Base><Mid>MidValue</Mid></Test>";
+
+                       xs = new XmlSerializer (typeof (Bug8468SubclassV2));
+                       var res5 = (Bug8468SubclassV2)xs.Deserialize (new StringReader (msg));
+                       Assert.IsNotNull (res5);
+                       Assert.AreEqual ("BaseValue", res5.Base);
+                       Assert.AreEqual ("MidValue", res5.Mid);
+
+                       xs = new XmlSerializer (typeof (Bug8468SubclassNoNamespaceV2), "http://test-namespace");
+                       var res6 = (Bug8468SubclassNoNamespaceV2)xs.Deserialize (new StringReader (msg));
+                       Assert.IsNotNull (res6);
+                       Assert.AreEqual ("BaseValue", res6.Base);
+                       Assert.AreEqual ("MidValue", res6.Mid); 
+               }
        }
 }