Merge pull request #3968 from BrzVlad/fix-monitor-exception
[mono.git] / mcs / class / System.XML / Test / System.Xml.Serialization / XmlSerializerTests.cs
index ef6ba78867fa3b99cb16bbe347f37608795cc92a..61835e709a09541daa56c89b501efc256c0ba3c1 100644 (file)
@@ -35,9 +35,7 @@ using System.Data;
 using System.Xml.Schema;
 using System.Xml.Serialization;
 using System.Reflection;
-#if NET_2_0
 using System.Collections.Generic;
-#endif
 
 using NUnit.Framework;
 
@@ -163,14 +161,12 @@ namespace MonoTests.System.XmlSerialization
                }
 
                // test constructors
-#if USE_VERSION_1_1    // It doesn't pass on MS.NET 1.1.
                [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
                public void TestConstructor()
                {
                        XmlSerializer ser = new XmlSerializer (null, "");
                }
-#else
-#endif
 
                // test basic types ////////////////////////////////////////////////////////
                [Test]
@@ -280,7 +276,7 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotWorking")]
+               [Category ("MobileNotWorking")]
                public void TestSerializeEnumeration_FromValue_Encoded ()
                {
                        SerializeEncoded ((int) SimpleEnumeration.SECOND, typeof (SimpleEnumeration));
@@ -378,7 +374,7 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotWorking")]
+               [Category ("MobileNotWorking")]
                public void TestSerializeEnumDefaultValue_Encoded ()
                {
                        SerializeEncoded (new EnumDefaultValue ());
@@ -559,7 +555,6 @@ namespace MonoTests.System.XmlSerialization
                [Test]
                public void TestSerializeEnumDefaultValue_InvalidValue2 ()
                {
-#if NET_2_0
                        try {
                                Serialize (5, typeof (EnumDefaultValue));
                                Assert.Fail ("#1");
@@ -571,16 +566,11 @@ namespace MonoTests.System.XmlSerialization
                                Assert.IsTrue (ex.InnerException.Message.IndexOf ("'5'") != -1, "#6");
                                Assert.IsTrue (ex.InnerException.Message.IndexOf (typeof (EnumDefaultValue).FullName) != -1, "#7");
                        }
-#else
-                       Serialize (5, typeof (EnumDefaultValue));
-                       Assert.AreEqual (Infoset ("<EnumDefaultValue>5</EnumDefaultValue>"), WriterText);
-#endif
                }
 
                [Test]
                public void TestSerializeEnumDefaultValueNF_InvalidValue1 ()
                {
-#if NET_2_0
                        try {
                                Serialize (new EnumDefaultValueNF ());
                                Assert.Fail ("#1");
@@ -592,16 +582,11 @@ namespace MonoTests.System.XmlSerialization
                                Assert.IsTrue (ex.InnerException.Message.IndexOf ("'0'") != -1, "#6");
                                Assert.IsTrue (ex.InnerException.Message.IndexOf (typeof (EnumDefaultValueNF).FullName) != -1, "#7");
                        }
-#else
-                       Serialize (new EnumDefaultValueNF ());
-                       Assert.AreEqual (Infoset ("<EnumDefaultValueNF>0</EnumDefaultValueNF>"), WriterText);
-#endif
                }
 
                [Test]
                public void TestSerializeEnumDefaultValueNF_InvalidValue2 ()
                {
-#if NET_2_0
                        try {
                                Serialize (15, typeof (EnumDefaultValueNF));
                                Assert.Fail ("#1");
@@ -613,10 +598,6 @@ namespace MonoTests.System.XmlSerialization
                                Assert.IsTrue (ex.InnerException.Message.IndexOf ("'15'") != -1, "#6");
                                Assert.IsTrue (ex.InnerException.Message.IndexOf (typeof (EnumDefaultValueNF).FullName) != -1, "#7");
                        }
-#else
-                       Serialize (15, typeof (EnumDefaultValueNF));
-                       Assert.AreEqual (Infoset ("<EnumDefaultValueNF>15</EnumDefaultValueNF>"), WriterText);
-#endif
                }
 
                [Test]
@@ -726,7 +707,6 @@ namespace MonoTests.System.XmlSerialization
                        f.Modifiers3 = (MapModifiers) 0;
                        f.Modifiers4 = (MapModifiers) 888;
                        f.Modifiers5 = (MapModifiers) 999;
-#if NET_2_0
                        try {
                                Serialize (f, typeof (Field));
                                Assert.Fail ("#E1");
@@ -744,33 +724,19 @@ namespace MonoTests.System.XmlSerialization
                                Assert.IsTrue (ex.InnerException.Message.IndexOf (typeof (FlagEnum).FullName) != -1, "#E8");
                                Assert.IsNull (ex.InnerException.InnerException, "#E9");
                        }
-#else
-                       Serialize (f, typeof (Field));
-                       Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
-                               "<field xmlns:xsd='{0}' xmlns:xsi='{1}' flag1='one two' flag2='444'" +
-                               " flag3='555' flag4='one two four' modifiers='666' modifiers2='777'" +
-                               " modifiers4='888' modifiers5='999' names='a b' />",
-                               XmlSchema.Namespace, XmlSchema.InstanceNamespace)), WriterText, "#E");
-#endif
                }
 
                [Test]
-               [Category ("NotDotNet")] // MS bug
+               [Category ("NotWorking")] // MS bug
                public void TestSerializeField_Encoded ()
                {
                        Field_Encoded f = new Field_Encoded ();
                        SerializeEncoded (f, typeof (Field_Encoded));
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version='1.0' encoding='utf-16'?>" +
-#if NET_2_0
-                               "<q1:field xmlns:xsi='{1}' xmlns:xsd='{0}' id='id1' flag1=''" +
-                               " flag2='' flag3='' flag4='' modifiers='PuBlIc'" +
-                               " modifiers2='PuBlIc' modifiers4='PuBlIc' xmlns:q1='some:urn' />",
-#else
                                "<q1:field xmlns:xsd='{0}' xmlns:xsi='{1}' id='id1' flag1=''" +
                                " flag2='' flag3='' flag4='' modifiers='PuBlIc'" +
                                " modifiers2='PuBlIc' modifiers4='PuBlIc' xmlns:q1='some:urn' />",
-#endif
                                XmlSchema.Namespace, XmlSchema.InstanceNamespace),
                                sw.GetStringBuilder ().ToString (), "#A");
 
@@ -785,15 +751,9 @@ namespace MonoTests.System.XmlSerialization
                        SerializeEncoded (f, typeof (Field_Encoded));
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version='1.0' encoding='utf-16'?>" +
-#if NET_2_0
-                               "<q1:field xmlns:xsi='{1}' xmlns:xsd='{0}' id='id1' flag3='two'" +
-                               " flag4='' modifiers='Protected' modifiers2='PuBlIc'" +
-                               " xmlns:q1='some:urn' />",
-#else
                                "<q1:field xmlns:xsd='{0}' xmlns:xsi='{1}' id='id1' flag3='two'" +
                                " flag4='' modifiers='Protected' modifiers2='PuBlIc'" +
                                " xmlns:q1='some:urn' />",
-#endif
                                XmlSchema.Namespace, XmlSchema.InstanceNamespace),
                                sw.GetStringBuilder ().ToString (), "#B");
 
@@ -808,17 +768,10 @@ namespace MonoTests.System.XmlSerialization
                        SerializeEncoded (f, typeof (Field_Encoded));
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version='1.0' encoding='utf-16'?>" +
-#if NET_2_0
-                               "<q1:field xmlns:xsi='{1}' xmlns:xsd='{0}' id='id1' flag1='two'" +
-                               " flag2='two' flag4='' modifiers='PuBlIc' modifiers2='Protected'" +
-                               " modifiers3='Protected' modifiers4='PuBlIc' modifiers5='Protected'" +
-                               " xmlns:q1='some:urn' />",
-#else
                                "<q1:field xmlns:xsd='{0}' xmlns:xsi='{1}' id='id1' flag1='two'" +
                                " flag2='two' flag4='' modifiers='PuBlIc' modifiers2='Protected'" +
                                " modifiers3='Protected' modifiers4='PuBlIc' modifiers5='Protected'" +
                                " xmlns:q1='some:urn' />",
-#endif
                                XmlSchema.Namespace, XmlSchema.InstanceNamespace),
                                sw.GetStringBuilder ().ToString (), "#C");
 
@@ -830,11 +783,8 @@ namespace MonoTests.System.XmlSerialization
                        f.Modifiers3 = (MapModifiers) 0;
                        f.Modifiers4 = (MapModifiers) 888;
                        f.Modifiers5 = (MapModifiers) 999;
-#if NET_2_0
                        try {
-#endif
                        SerializeEncoded (f, typeof (Field_Encoded));
-#if NET_2_0
                                Assert.Fail ("#D1");
                        } catch (InvalidOperationException ex) {
                                // There was an error generating the XML document
@@ -850,15 +800,6 @@ namespace MonoTests.System.XmlSerialization
                                Assert.IsTrue (ex.InnerException.Message.IndexOf (typeof (FlagEnum_Encoded).FullName) != -1, "#D8");
                                Assert.IsNull (ex.InnerException.InnerException, "#D9");
                        }
-#else
-                       Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
-                               "<?xml version='1.0' encoding='utf-16'?>" +
-                               "<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='some:urn' />",
-                               XmlSchema.Namespace, XmlSchema.InstanceNamespace),
-                               sw.GetStringBuilder ().ToString (), "#D");
-#endif
                }
 
                [Test]
@@ -930,7 +871,6 @@ namespace MonoTests.System.XmlSerialization
                [Test]
                public void TestSerializeZeroFlagEnum_InvalidValue ()
                {
-#if NET_2_0
                        try {
                                Serialize (4, typeof (ZeroFlagEnum)); // corresponding enum field is marked XmlIgnore
                                Assert.Fail ("#1");
@@ -942,10 +882,6 @@ namespace MonoTests.System.XmlSerialization
                                Assert.IsTrue (ex.InnerException.Message.IndexOf ("'4'") != -1, "#6");
                                Assert.IsTrue (ex.InnerException.Message.IndexOf (typeof (ZeroFlagEnum).FullName) != -1, "#7");
                        }
-#else
-                       Serialize (4, typeof (ZeroFlagEnum)); // corresponding enum field is marked XmlIgnore
-                       Assert.AreEqual (Infoset ("<ZeroFlagEnum>4</ZeroFlagEnum>"), WriterText);
-#endif
                }
 
                [Test]
@@ -984,11 +920,7 @@ namespace MonoTests.System.XmlSerialization
                        TimeZone tz = TimeZone.CurrentTimeZone;
                        TimeSpan off = tz.GetUtcOffset (d);
                        string sp = string.Format ("{0}{1:00}:{2:00}", off.Ticks >= 0 ? "+" : "", off.Hours, off.Minutes);
-#if NET_2_0
                        Assert.AreEqual (Infoset ("<dateTime>0001-01-01T00:00:00</dateTime>"), WriterText);
-#else
-                       Assert.AreEqual (Infoset ("<dateTime>0001-01-01T00:00:00.0000000" + sp + "</dateTime>"), WriterText);
-#endif
                }
 
                /*
@@ -1042,11 +974,7 @@ namespace MonoTests.System.XmlSerialization
                        Serialize (optionalValue);
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version='1.0' encoding='utf-16'?>" +
-#if NET_2_0
-                               "<optionalValue xmlns:xsi='{1}' xmlns:xsd='{0}' xmlns='{2}' />",
-#else
                                "<optionalValue xmlns:xsd='{0}' xmlns:xsi='{1}' xmlns='{2}' />",
-#endif
                                XmlSchema.Namespace, XmlSchema.InstanceNamespace, AnotherNamespace),
                                sw.ToString (), "#1");
 
@@ -1060,11 +988,7 @@ namespace MonoTests.System.XmlSerialization
                        Serialize (optionalValue, overrides);
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version='1.0' encoding='utf-16'?>" +
-#if NET_2_0
-                               "<optionalValue xmlns:xsi='{1}' xmlns:xsd='{0}' xmlns='{2}'>" +
-#else
                                "<optionalValue xmlns:xsd='{0}' xmlns:xsi='{1}' xmlns='{2}'>" +
-#endif
                                "<Attributes xmlns='{3}'>one four</Attributes>" +
                                "</optionalValue>", XmlSchema.Namespace, XmlSchema.InstanceNamespace,
                                AnotherNamespace, ANamespace), sw.ToString (), "#2");
@@ -1073,18 +997,33 @@ namespace MonoTests.System.XmlSerialization
                        Serialize (optionalValue, overrides);
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version='1.0' encoding='utf-16'?>" +
-#if NET_2_0
-                               "<optionalValue xmlns:xsi='{1}' xmlns:xsd='{0}' xmlns='{2}'>" +
-#else
                                "<optionalValue xmlns:xsd='{0}' xmlns:xsi='{1}' xmlns='{2}'>" +
-#endif
                                "<Attributes xmlns='{3}'>one four</Attributes>" +
                                "<Flags xmlns='{3}'>one</Flags>" +
                                "</optionalValue>",
                                XmlSchema.Namespace, XmlSchema.InstanceNamespace, AnotherNamespace,
                                ANamespace), sw.ToString (), "#3");
                }
-
+               
+               [Test]
+               public void TestRoundTripSerializeOptionalValueTypeContainer ()
+               {
+                       var source = new OptionalValueTypeContainer ();
+                       source.IsEmpty = true;
+                       source.IsEmptySpecified = true;
+                       var ser = new XmlSerializer (typeof (OptionalValueTypeContainer));
+                       string xml;
+                       using (var t = new StringWriter ()) {
+                               ser.Serialize (t, source);
+                               xml = t.ToString();
+                       }
+                       using (var s = new StringReader (xml)) {
+                               var obj = (OptionalValueTypeContainer) ser.Deserialize(s);
+                               Assert.AreEqual (source.IsEmpty, obj.IsEmpty, "#1");
+                               Assert.AreEqual (source.IsEmptySpecified, obj.IsEmptySpecified, "#2");
+                       }
+               }
+               
                [Test]
                public void TestSerializePlainContainer ()
                {
@@ -1613,7 +1552,6 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotWorking")] // SerializationCodeGenerator outputs wrong xsi:type for flagencoded in #C1
                public void TestSerializeDefaultValueAttribute_Encoded ()
                {
                        SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
@@ -1780,7 +1718,6 @@ namespace MonoTests.System.XmlSerialization
                        // technically XmlSchemaForm.None has an XmlIgnore attribute,
                        // but it is not being serialized as a member.
 
-#if NET_2_0
                        try {
                                Serialize (XmlSchemaForm.None);
                                Assert.Fail ("#1");
@@ -1792,10 +1729,6 @@ namespace MonoTests.System.XmlSerialization
                                Assert.IsTrue (ex.InnerException.Message.IndexOf ("'0'") != -1, "#6");
                                Assert.IsTrue (ex.InnerException.Message.IndexOf (typeof (XmlSchemaForm).FullName) != -1, "#7");
                        }
-#else
-                       Serialize (XmlSchemaForm.None);
-                       Assert.AreEqual (Infoset ("<XmlSchemaForm>0</XmlSchemaForm>"), WriterText);
-#endif
                }
 
                [Test]
@@ -1816,7 +1749,7 @@ namespace MonoTests.System.XmlSerialization
 
                [Test]
                [ExpectedException (typeof (InvalidOperationException))]
-               [Category ("NotWorking")]
+               [Category ("MobileNotWorking")]
                public void TestSerializeXmlNodeArrayIncludesAttribute ()
                {
                        XmlDocument doc = new XmlDocument ();
@@ -1831,7 +1764,6 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (Infoset ("<anyType><elem1/><elem2/></anyType>"), WriterText);
                }
 
-#if NET_2_0
                [Test]
                [ExpectedException (typeof (InvalidOperationException))] // List<XmlNode> is not supported
                public void TestSerializeGenericListOfNode ()
@@ -1849,7 +1781,6 @@ namespace MonoTests.System.XmlSerialization
                        Serialize (new List<XmlElement> (new XmlElement [] { doc.CreateElement ("elem1"), doc.CreateElement ("elem2") }), typeof (object));
                        Assert.AreEqual (Infoset ("<anyType><elem1/><elem2/></anyType>"), WriterText);
                }
-#endif
                [Test]
                public void TestSerializeXmlDocument ()
                {
@@ -2006,6 +1937,17 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual (Infoset (res), WriterText);
                }
 
+               [Test] // Covers #36829
+               public void TestSubclassElementList ()
+               {
+                       var o = new SubclassTestList () { Items = new List<object> () { new SubclassTestSub () } };
+                       Serialize (o);
+
+                       string res = "<SubclassTestList xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>";
+                       res += "<b xsi:type=\"SubclassTestSub\"/></SubclassTestList>";
+                       Assert.AreEqual (Infoset (res), WriterText);
+               }
+
                [Test]
                [ExpectedException (typeof (InvalidOperationException))]
                public void TestArrayAttributeWithWrongDataType ()
@@ -2020,11 +1962,7 @@ namespace MonoTests.System.XmlSerialization
                        Serialize (new PrimitiveTypesContainer ());
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version='1.0' encoding='utf-16'?>" +
-#if NET_2_0
                                "<PrimitiveTypesContainer xmlns:xsi='{1}' xmlns:xsd='{0}' xmlns='some:urn'>" +
-#else
-                               "<PrimitiveTypesContainer xmlns:xsd='{0}' xmlns:xsi='{1}' xmlns='some:urn'>" +
-#endif
                                "<Number>2004</Number>" +
                                "<Name>some name</Name>" +
                                "<Index>56</Index>" +
@@ -2036,11 +1974,7 @@ namespace MonoTests.System.XmlSerialization
                        SerializeEncoded (new PrimitiveTypesContainer ());
                        Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
                                "<?xml version='1.0' encoding='utf-16'?>" +
-#if NET_2_0
                                "<q1:PrimitiveTypesContainer xmlns:xsi='{1}' xmlns:xsd='{0}' id='id1' xmlns:q1='{2}'>" +
-#else
-                               "<q1:PrimitiveTypesContainer xmlns:xsd='{0}' xmlns:xsi='{1}' id='id1' xmlns:q1='{2}'>" +
-#endif
                                "<Number xsi:type='xsd:int'>2004</Number>" +
                                "<Name xsi:type='xsd:string'>some name</Name>" +
                                "<Index xsi:type='xsd:unsignedByte'>56</Index>" +
@@ -2309,14 +2243,14 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("MobileNotWorking")]
                public void XmlArrayAttributeUnqualifiedWithNamespace ()
                {
                        new XmlSerializer (typeof (XmlArrayUnqualifiedWithNamespace));
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("MobileNotWorking")]
                public void XmlArrayItemAttributeUnqualifiedWithNamespace ()
                {
                        new XmlSerializer (typeof (XmlArrayItemUnqualifiedWithNamespace));
@@ -2381,16 +2315,13 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-#if !NET_2_0
-               [ExpectedException (typeof (ApplicationException))]
-#endif
                public void SerializeErrorneousIXmlSerializable ()
                {
                        Serialize (new ErrorneousGetSchema ());
                        Assert.AreEqual ("<:ErrorneousGetSchema></>", Infoset (sw.ToString ()));
                }
 
-#if NET_2_0
+               [Test]
                public void DateTimeRoundtrip ()
                {
                        // bug #337729
@@ -2400,7 +2331,6 @@ namespace MonoTests.System.XmlSerialization
                        DateTime d = (DateTime) ser.Deserialize (new StringReader (sw.ToString ()));
                        Assert.AreEqual (DateTimeKind.Utc, d.Kind);
                }
-#endif
 
                [Test]
                public void SupportIXmlSerializableImplicitlyConvertible ()
@@ -2449,7 +2379,6 @@ namespace MonoTests.System.XmlSerialization
 
                #region GenericsSeralizationTests
 
-#if NET_2_0
                [Test]
                public void TestSerializeGenSimpleClassString ()
                {
@@ -2959,10 +2888,29 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual(WriterText, expected_text, WriterText);
                }
 
-#endif
 
                #endregion //GenericsSeralizationTests
+               #region XmlInclude on abstract class tests (Bug #18558)
+               [Test]
+               public void TestSerializeIntermediateType ()
+               {
+                       string expectedXml = "<ContainerTypeForTest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><XmlIntermediateType intermediate=\"false\"/></ContainerTypeForTest>";
+                       var obj = new ContainerTypeForTest();
+                       obj.MemberToUseInclude = new IntermediateTypeForTest ();
+                       Serialize (obj);
+                       Assert.AreEqual (Infoset (expectedXml), WriterText, "Serialized Output : " + WriterText);
+               }
 
+               [Test]
+               public void TestSerializeSecondType ()
+               {
+                       string expectedXml = "<ContainerTypeForTest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><XmlSecondType intermediate=\"false\"/></ContainerTypeForTest>";
+                       var obj = new ContainerTypeForTest();
+                       obj.MemberToUseInclude = new SecondDerivedTypeForTest ();
+                       Serialize (obj);
+                       Assert.AreEqual (Infoset (expectedXml), WriterText, "Serialized Output : " + WriterText);
+               }
+               #endregion
                public class XmlArrayOnInt
                {
                        [XmlArray]
@@ -3058,7 +3006,6 @@ namespace MonoTests.System.XmlSerialization
                        public TimeSpan StringDuration = TimeSpan.FromSeconds (1);
                }
 
-#if NET_2_0
                public class Bug80759
                {
                        public string Test;
@@ -3144,7 +3091,6 @@ namespace MonoTests.System.XmlSerialization
                        }
                }
 
-#endif
 
                void CDataTextNodes_BadNode (object s, XmlNodeEventArgs e)
                {
@@ -3421,7 +3367,7 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category("NotDotNet")]
+               [Category("NotWorking")]
                public void ShouldSerializeGeneric ()
                {
                        var ser = new XmlSerializer (typeof (ClassWithShouldSerializeGeneric));
@@ -3571,4 +3517,39 @@ namespace MonoTests.System.XmlSerialization
                        generatorFallback.SetValue (null, generatorFallbackOld);
                }
        }
+
+#region XmlInclude on abstract class test classes
+
+       [XmlType]
+       public class ContainerTypeForTest
+       {
+               [XmlElement ("XmlSecondType", typeof (SecondDerivedTypeForTest))]
+               [XmlElement ("XmlIntermediateType", typeof (IntermediateTypeForTest))]
+               [XmlElement ("XmlFirstType", typeof (FirstDerivedTypeForTest))]
+               public AbstractTypeForTest MemberToUseInclude { get; set; }
+       }
+
+       [XmlInclude (typeof (SecondDerivedTypeForTest))]
+       [XmlInclude (typeof (IntermediateTypeForTest))]
+       [XmlInclude (typeof (FirstDerivedTypeForTest))]
+       public abstract class AbstractTypeForTest
+       {
+       }
+
+       public class IntermediateTypeForTest : AbstractTypeForTest
+       {
+               [XmlAttribute (AttributeName = "intermediate")]
+               public bool IntermediateMember { get; set; }
+       }
+
+       public class FirstDerivedTypeForTest : AbstractTypeForTest
+       {
+               public string FirstMember { get; set; }
+       }
+
+       public class SecondDerivedTypeForTest : IntermediateTypeForTest
+       {
+               public string SecondMember { get; set; }
+       }
+#endregion
 }