Merge pull request #1213 from fengari/system_timers_timer_opt
[mono.git] / mcs / class / System.XML / Test / System.Xml.Serialization / XmlSerializerTestClasses.cs
index fe1c4d3ab12a454bafabf7694ba55d7fd59b0fc7..62b3698c8370b86be8543b05441ba6af55b8237f 100644 (file)
@@ -147,6 +147,25 @@ namespace MonoTests.System.Xml.TestClasses
                        nestedinner = new GenNestedClass<T1, T2>.InnerClass<T1> ();
                }
        }
+               
+       public class WithNulls
+       {
+               [XmlElement (IsNullable=true)]
+               public int? nint;
+               
+               [XmlElement (IsNullable=true)]
+               public TestEnumWithNulls? nenum;
+               
+               [XmlElement (IsNullable=true)]
+               public DateTime? ndate;
+       }
+       
+       public enum TestEnumWithNulls
+       {
+               aa,
+               bb
+       }
+       
 #endif
 
        #endregion // GenericsTestClasses
@@ -413,6 +432,7 @@ namespace MonoTests.System.Xml.TestClasses
        public class ReadOnlyProperties
        {
                string[] strArr = new string[2] { "string1", "string2" };
+               List<string> strList = new List<string> { "listString1" };
 
                public string[] StrArr
                {
@@ -423,8 +443,21 @@ namespace MonoTests.System.Xml.TestClasses
                {
                        get { return "fff"; }
                }
+
+               public IList<string> StrList { get { return strList; } }
        }
 
+       [Serializable]
+       public class ReadOnlyListProperty {
+               List<string> strList = new List<string> { "listString1", "listString2" };
+
+               public List<string> StrList
+               {
+                       get { return strList; }
+               }
+       }
+
+
        [XmlRoot ("root")]
        public class ListDefaults
        {
@@ -870,5 +903,219 @@ namespace MonoTests.System.Xml.TestClasses
                [SoapEnum ("Large")]
                B
        }
+
+       public class ErrorneousGetSchema : IXmlSerializable
+       {
+               public XmlSchema GetSchema ()
+               {
+                       throw new ApplicationException ("unexpected");
+               }
+
+               public void ReadXml (XmlReader reader)
+               {
+               }
+
+               public void WriteXml (XmlWriter writer)
+               {
+               }
+
+               // it should be serialized IF it is NOT IXmlSerializable.
+               public string Whoa = "whoa";
+       }
+
+       [XmlRoot ("DefaultDateTimeContainer", Namespace = "urn:foo")]
+       public class DefaultDateTimeContainer // bug #378696
+       {
+               public DateTime SimpleDateTime;
+
+               [DefaultValue(typeof(DateTime), "2001-02-03T04:05:06")]
+               public DateTime FancyDateTime;
+
+               [DefaultValue (typeof (int), "123456")]
+               public int Numeric;
+       }
+
+       public class XmlSerializableImplicitConvertible
+       {
+               public BaseClass B = new DerivedClass ();
+
+               public class XmlSerializable : IXmlSerializable
+               {
+                       public void WriteXml (XmlWriter writer)
+                       {
+                       }
+
+                       public void ReadXml (XmlReader reader)
+                       {
+                       }
+
+                       public XmlSchema GetSchema ()
+                       {
+                               return null;
+                       }
+               }
+
+               public class BaseClass
+               {
+                       public static implicit operator XmlSerializable (BaseClass b)
+                       {
+                               return new XmlSerializable ();
+
+                       }
+
+                       public static implicit operator BaseClass (XmlSerializable x)
+                       {
+                               return new BaseClass ();
+                       }
+               }
+
+               public class DerivedClass : BaseClass
+               {
+               }
+       }
+
+       public class Bug704813Type
+       {
+               IEnumerable<string> foo = new List<string> ();
+               public IEnumerable<string> Foo {
+                       get { return foo; }
+               }
+       }
+
+       public class Bug708178Type
+       {
+               List<string> foo = new List<string> ();
+
+               [XmlArray("Foo"), XmlArrayItem("Foo", typeof(string))]
+               public List<string> Foo {
+                       get { return foo; }
+               }                
+       }
+
+       [XmlRoot("root")]
+       public class ExplicitlyOrderedMembersType1
+       {
+               [XmlElement("child0", Order = 4)]
+               public string Child0;
+
+               [XmlElement("child", Order = 0)]
+               public string Child1;
+
+               [XmlElement("child", Order = 2)]
+               public string Child2;
+       }
+
+       [XmlRoot("root")]
+       public class ExplicitlyOrderedMembersType2
+       {
+               [XmlElement("child0", Order = 4)]
+               public string Child0;
+
+               [XmlElement("child")] // wrong. Needs to be Ordered as well.
+               public string Child1;
+
+               [XmlElement("child", Order = 2)]
+               public string Child2;
+       }
+
+       [XmlRoot("root")]
+       public class ExplicitlyOrderedMembersType3
+       {
+               [XmlElement("child0", Order = 1)] // it's between 0 and 2. After two "child" elements, child0 is not recognized as this member.
+               public string Child0;
+
+               [XmlElement("child", Order = 0)]
+               public string Child1;
+
+               [XmlElement("child", Order = 2)]
+               public string Child2;
+       }
+
+       [XmlRoot("root")]
+       public class ExplicitlyOrderedMembersType4
+       {
+               [XmlElement("child0", Order = 1)] // it's between 0 and 2. After two "child" elements, child0 is not recognized as this member.
+               public string Child0;
+               
+               [XmlElement("child", Order = 0)]
+               public string Child1;
+               
+               [XmlElement("child", Order = 2)]
+               public string Child2;
+               
+               [XmlAttribute]
+               public string Child3;
+       }
+
+       [XmlRoot ("root")]
+       public class NullableDatesAndTimes {
+               [XmlElementAttribute ("MyTime", DataType = "time", IsNullable = false)]
+               public DateTime MyTime;
+                       
+               [XmlElementAttribute ("MyTimeNullable", DataType = "time", IsNullable = true)]
+               public DateTime? MyTimeNullable;
+               
+               [XmlElementAttribute ("MyDate", DataType = "date", IsNullable = false)]
+               public DateTime MyDate;
+               
+               [XmlElementAttribute ("MyDateNullable", DataType = "date", IsNullable = true)]
+               public DateTime? MyDateNullable;
+       }
+
+       public class NotExactDateParseClass
+       {
+               [XmlElementAttribute (DataType = "date")]
+               public DateTime SomeDate;
+       }
+
+       public class Bug8468BaseClass
+       {
+               public string Base;
+       }
+
+       public class Bug8468MidClass: Bug8468BaseClass
+       {
+               public string Mid;
+       }
+
+       [XmlRoot("Test", Namespace="http://test-namespace")]
+       public class Bug8468Subclass: Bug8468MidClass
+       {
+       }
+
+       [XmlRoot("Test")]
+       public class Bug8468SubclassNoNamespace: Bug8468MidClass
+       {
+       }
+
+       [XmlRoot("Test", Namespace="")]
+       public class Bug8468BaseClassV2
+       {
+               public string Base;
+       }
+
+       public class Bug8468MidClassV2: Bug8468BaseClassV2
+       {
+               public string Mid;
+       }
+
+       [XmlRoot("Test", Namespace="http://test-namespace")]
+       public class Bug8468SubclassV2: Bug8468MidClassV2
+       {
+       }
+
+       [XmlRoot("Test")]
+       public class Bug8468SubclassNoNamespaceV2: Bug8468MidClassV2
+       {
+       }
+       
+       [XmlRoot("Test")]
+       public class Bug9193Class
+       {
+               [XmlElement ("Data", Order=0)]
+               public string[] Data;
+               [XmlElement ("Extra", Order=1)]
+               public string[] Extra;
+       }
 }