* System.Xml.Serialization/XmlSerializerTestClasses.cs,
[mono.git] / mcs / class / System.XML / Test / System.Xml.Serialization / XmlSerializerTestClasses.cs
index 84b5d53e26768ba627d9e3fe9177219cefc0b9c1..1bb0d0b672cb19531a0cebac27fe56cdcaa85af6 100644 (file)
-//\r
-// System.Xml.XmlSerializerTestClasses\r
-//\r
-// Author:\r
-//   Erik LeBel <eriklebel@yahoo.ca>\r
-//\r
-// (C) 2003 Erik LeBel\r
-//\r
-// Classes to use in the testing of the XmlSerializer\r
-//\r
-\r
-using System;\r
-using System.ComponentModel;\r
-using System.Collections;\r
-using System.Xml;\r
-using System.Xml.Schema;\r
-using System.Xml.Serialization;\r
-\r
-namespace MonoTests.System.Xml.TestClasses\r
-{\r
-       public enum SimpleEnumeration { FIRST, SECOND };\r
-\r
-       [Flags]\r
-       public enum EnumDefaultValue { e1 = 1, e2 = 2, e3 = 3 }\r
-       public enum EnumDefaultValueNF { e1 = 1, e2 = 2, e3 = 3 }\r
-\r
-       [Flags]\r
-       public enum FlagEnum { \r
-               [XmlEnum ("one")]\r
-               e1 = 1,\r
-               [XmlEnum ("two")]\r
-               e2 = 2,\r
-               [XmlEnum ("four")]\r
-               e4 = 4\r
-       }\r
-\r
-       [Flags]\r
-       [SoapType ("flagenum")]\r
-       public enum FlagEnum_Encoded\r
-       {\r
-               [SoapEnum ("one")]\r
-               e1 = 1,\r
-               [SoapEnum ("two")]\r
-               e2 = 2,\r
-               [SoapEnum ("four")]\r
-               e4 = 4\r
-       }\r
-\r
-       [Flags]\r
-       public enum ZeroFlagEnum {\r
-               [XmlEnum ("zero")]\r
-               e0 = 0,\r
-               [XmlEnum ("o<n>e")]\r
-               e1 = 1,\r
-               [XmlEnum ("tns:t<w>o")]\r
-               e2 = 2,\r
-               [XmlEnum ("four")]\r
-               [XmlIgnore]\r
-               e4 = 4\r
-       }\r
-       \r
-       public class SimpleClass\r
-       {\r
-               public string something = null;\r
-       }\r
-\r
-       public class StringCollection : CollectionBase\r
-       {\r
-               public void Add (String parameter) \r
-               {\r
-                       List.Insert (Count, parameter);\r
-               }\r
-                       \r
-               public String this [int index]\r
-               {\r
-                       get\r
-                       { \r
-                               if (index < 0 || index > Count)\r
-                                       throw new ArgumentOutOfRangeException ();\r
-                                       \r
-                               return (String) List [index]; \r
-                       }\r
-                       set { List [index] = value; }\r
-               }\r
-       }\r
-       \r
-       public class StringCollectionContainer\r
-       {\r
-               StringCollection messages = new StringCollection();\r
-               \r
-               public StringCollection Messages\r
-               {\r
-                       get { return messages; }\r
-               }\r
-       }\r
-\r
-       public class ArrayContainer\r
-       {\r
-               public object [] items = null;\r
-       }\r
-       \r
-       public class ClassArrayContainer\r
-       {\r
-               public SimpleClass [] items = null;\r
-       }\r
-       \r
-       [XmlRoot("simple")]\r
-       public class SimpleClassWithXmlAttributes\r
-       {\r
-               [XmlAttribute("member")]\r
-               public string something = null;\r
-       }\r
-       \r
-       [XmlRoot("field")]\r
-       public class Field\r
-       {\r
-               [XmlAttribute ("flag1")]\r
-               [DefaultValue (1)]\r
-               public FlagEnum Flags1;\r
-\r
-               [XmlAttribute ("flag2")]\r
-               [DefaultValue (FlagEnum.e1)]\r
-               public FlagEnum Flags2;\r
-\r
-               [XmlAttribute ("flag3", Form = XmlSchemaForm.Qualified)]\r
-               [DefaultValue (FlagEnum.e1 | FlagEnum.e2)]\r
-               public FlagEnum Flags3;\r
-\r
-               [XmlAttribute ("flag4")]\r
-               public FlagEnum Flags4;\r
-\r
-               [XmlAttribute("modifiers")]\r
-               public MapModifiers Modifiers;\r
-\r
-               [XmlAttribute ("modifiers2", Form=XmlSchemaForm.Unqualified)]\r
-               public MapModifiers Modifiers2;\r
-\r
-               [XmlAttribute ("modifiers3")]\r
-               [DefaultValue (0)]\r
-               public MapModifiers Modifiers3;\r
-\r
-               [XmlAttribute ("modifiers4", Form=XmlSchemaForm.Unqualified)]\r
-               [DefaultValue (MapModifiers.Protected)]\r
-               public MapModifiers Modifiers4;\r
-\r
-               [XmlAttribute ("modifiers5", Form = XmlSchemaForm.Qualified)]\r
-               [DefaultValue (MapModifiers.Public)]\r
-               public MapModifiers Modifiers5;\r
-\r
-               [XmlAttribute ("names")]\r
-               public string[] Names;\r
-\r
-               [XmlAttribute ("street")]\r
-               public string Street;\r
-       }\r
-\r
-       [SoapType ("field", Namespace = "some:urn")]\r
-       public class Field_Encoded\r
-       {\r
-               [SoapAttribute ("flag1")]\r
-               [DefaultValue (FlagEnum_Encoded.e1)]\r
-               public FlagEnum_Encoded Flags1;\r
-\r
-               [SoapAttribute ("flag2")]\r
-               [DefaultValue (FlagEnum_Encoded.e1)]\r
-               public FlagEnum_Encoded Flags2;\r
-\r
-               [SoapAttribute ("flag3")]\r
-               [DefaultValue (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e2)]\r
-               public FlagEnum_Encoded Flags3;\r
-\r
-               [SoapAttribute ("flag4")]\r
-               public FlagEnum_Encoded Flags4;\r
-\r
-               [SoapAttribute ("modifiers")]\r
-               public MapModifiers Modifiers;\r
-\r
-               [SoapAttribute ("modifiers2")]\r
-               public MapModifiers Modifiers2;\r
-\r
-               [SoapAttribute ("modifiers3")]\r
-               [DefaultValue (MapModifiers.Public)]\r
-               public MapModifiers Modifiers3;\r
-\r
-               [SoapAttribute ("modifiers4")]\r
-               [DefaultValue (MapModifiers.Protected)]\r
-               public MapModifiers Modifiers4;\r
-\r
-               [SoapAttribute ("modifiers5")]\r
-               [DefaultValue (MapModifiers.Public)]\r
-               public MapModifiers Modifiers5;\r
-\r
-               public string[] Names;\r
-\r
-               [SoapAttribute ("street")]\r
-               public string Street;\r
-       }\r
-\r
-       [Flags]\r
-       public enum MapModifiers\r
-       {\r
-               [XmlEnum("public")]\r
-               Public = 0,\r
-               [XmlEnum("protected")]\r
-               Protected = 1,\r
-       }\r
-\r
-       public class MyList : ArrayList\r
-       {\r
-               object container;\r
-               \r
-               // NOTE: MyList has no public constructor\r
-               public MyList (object container) : base()\r
-               {\r
-                       this.container = container;\r
-               }\r
-       }\r
-       \r
-       public class Container\r
-       {\r
-               public MyList Items;\r
-               \r
-               public Container () {\r
-                       Items = new MyList(this);\r
-               }\r
-       }\r
-       \r
-       public class Container2\r
-       {\r
-               public MyList Items;\r
-               \r
-               public Container2 () {\r
-               }\r
-               \r
-               public Container2 (bool b) {\r
-                       Items = new MyList(this);\r
-               }\r
-       }\r
-\r
-       public class MyElem: XmlElement\r
-       {\r
-               public MyElem (XmlDocument doc): base ("","myelem","", doc)\r
-               {\r
-                       SetAttribute ("aa","1");\r
-               }\r
-\r
-               [XmlAttribute]\r
-               public int kk=1;\r
-       }\r
-\r
-       public class MyDocument: XmlDocument\r
-       {\r
-               public MyDocument ()\r
-               {\r
-               }\r
-\r
-               [XmlAttribute]\r
-               public int kk=1;\r
-       }\r
-       \r
-       public class CDataContainer\r
-       {\r
-               public XmlCDataSection cdata;\r
-       }\r
-       \r
-       public class NodeContainer\r
-       {\r
-               public XmlNode node;\r
-       }\r
-       \r
-       public class Choices\r
-       {\r
-               [XmlElementAttribute("ChoiceZero", typeof(string), IsNullable=false)]\r
-               [XmlElementAttribute("ChoiceOne", typeof(string), IsNullable=false)]\r
-               [XmlElementAttribute("ChoiceTwo", typeof(string), IsNullable=false)]\r
-               [XmlChoiceIdentifier("ItemType")]\r
-               public string MyChoice;\r
-\r
-               [XmlIgnore]\r
-               public ItemChoiceType ItemType;\r
-       }\r
-       \r
-       [XmlType(IncludeInSchema = false)]\r
-       public enum ItemChoiceType\r
-       {\r
-               ChoiceZero,\r
-               [XmlEnum ("ChoiceOne")]\r
-               StrangeOne,\r
-               ChoiceTwo,\r
-       }\r
-       \r
-       public class WrongChoices\r
-       {\r
-               [XmlElementAttribute("ChoiceZero", typeof(string), IsNullable=false)]\r
-               [XmlElementAttribute("StrangeOne", typeof(string), IsNullable=false)]\r
-               [XmlElementAttribute("ChoiceTwo", typeof(string), IsNullable=false)]\r
-               [XmlChoiceIdentifier("ItemType")]\r
-               public string MyChoice;\r
-\r
-               [XmlIgnore]\r
-               public ItemChoiceType ItemType;\r
-       }\r
-       \r
-       [XmlType ("Type with space")]\r
-       public class TestSpace\r
-       {\r
-          [XmlElement (ElementName = "Element with space")]\r
-          public int elem;\r
-           \r
-          [XmlAttribute (AttributeName = "Attribute with space")]\r
-          public int attr; \r
-       }\r
-\r
-       [Serializable]\r
-       public class ReadOnlyProperties {\r
-               string[] strArr = new string[2] { "string1", "string2" };\r
-\r
-               public string[] StrArr {\r
-                       get { return strArr; }\r
-               }\r
-               \r
-               public string dat {\r
-                       get { return "fff"; }\r
-               } \r
-       }\r
-       \r
-       [XmlRoot("root")]\r
-       public class ListDefaults\r
-       {\r
-               public ListDefaults ()\r
-               {\r
-                       ed = new SimpleClass ();\r
-                       str = "hola";\r
-               }\r
-               \r
-           public ArrayList list2;\r
-           \r
-           public MyList list3;\r
-           \r
-           public string[] list4;\r
-           \r
-               [XmlElement("e", typeof(SimpleClass))]\r
-           public ArrayList list5;\r
-           \r
-               [DefaultValue (null)]\r
-           public SimpleClass ed;\r
-           \r
-               [DefaultValue (null)]\r
-           public string str; \r
-       }\r
-       \r
-       public class clsPerson\r
-       {\r
-               public IList EmailAccounts;\r
-       }\r
-       \r
-       public class ArrayClass\r
-       {\r
-               public object names = new object[] { "un","dos" };\r
-       }\r
-       \r
-       public class CompositeValueType\r
-       {\r
-               public void Init ()\r
-               {\r
-                       Items = new object[] { 1, 2 };\r
-                       ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.In, ItemsChoiceType.Es };\r
-               }\r
-          \r
-               [XmlElementAttribute("Es", typeof(int))]\r
-               [XmlElementAttribute("In", typeof(int))]\r
-               [XmlChoiceIdentifierAttribute("ItemsElementName")]\r
-               public object[] Items;\r
-          \r
-               [XmlElementAttribute("ItemsElementName")]\r
-               [XmlIgnoreAttribute()]\r
-               public ItemsChoiceType[] ItemsElementName;\r
-       }\r
-\r
-       public enum ItemsChoiceType {\r
-          In, Es\r
-       }\r
-       \r
-       public class ArrayAttributeWithType\r
-       {\r
-               [XmlAttribute (DataType="anyURI")]\r
-               public string[] at = new string [] { "a","b" };\r
-\r
-               [XmlAttribute (DataType="base64Binary")]\r
-               public byte[][] bin1 = new byte[][] { new byte[]{1,2},  new byte[]{1,2}};\r
-               \r
-               [XmlAttribute (DataType="base64Binary")]\r
-               public byte[] bin2 = new byte[] { 1,2 };\r
-       }\r
-       \r
-       public class ArrayAttributeWithWrongType\r
-       {\r
-               [XmlAttribute (DataType="int")]\r
-               public string[] at = new string [] { "a","b" };\r
-       }\r
-       \r
-       [XmlType ("Container")]\r
-       public class EntityContainer\r
-       {\r
-               EntityCollection collection1;\r
-               EntityCollection collection2;\r
-               EntityCollection collection3 = new EntityCollection ("root");\r
-               EntityCollection collection4 = new EntityCollection ("root");\r
-               \r
-               [XmlArray (IsNullable=true)]\r
-               public EntityCollection Collection1 {\r
-                       get { return collection1; }\r
-                       set { collection1 = value; collection1.Container = "assigned"; }\r
-               }\r
-               \r
-               [XmlArray (IsNullable=false)]\r
-               public EntityCollection Collection2 {\r
-                       get { return collection2; }\r
-                       set { collection2 = value; collection2.Container = "assigned"; }\r
-               }\r
-               \r
-               [XmlArray (IsNullable=true)]\r
-               public EntityCollection Collection3 {\r
-                       get { return collection3; }\r
-                       set { collection3 = value; collection3.Container = "assigned"; }\r
-               }\r
-               \r
-               [XmlArray (IsNullable=false)]\r
-               public EntityCollection Collection4 {\r
-                       get { return collection4; }\r
-                       set { collection4 = value; collection4.Container = "assigned"; }\r
-               }\r
-       }\r
-       \r
-       [XmlType ("Container")]\r
-       public class ArrayEntityContainer\r
-       {\r
-               Entity[] collection1;\r
-               Entity[] collection2;\r
-               Entity[] collection3 = new Entity [0];\r
-               Entity[] collection4 = new Entity [0];\r
-               \r
-               [XmlArray (IsNullable=true)]\r
-               public Entity[] Collection1 {\r
-                       get { return collection1; }\r
-                       set { collection1 = value; }\r
-               }\r
-               \r
-               [XmlArray (IsNullable=false)]\r
-               public Entity[] Collection2 {\r
-                       get { return collection2; }\r
-                       set { collection2 = value; }\r
-               }\r
-               \r
-               [XmlArray (IsNullable=true)]\r
-               public Entity[] Collection3 {\r
-                       get { return collection3; }\r
-                       set { collection3 = value; }\r
-               }\r
-               \r
-               [XmlArray (IsNullable=false)]\r
-               public Entity[] Collection4 {\r
-                       get { return collection4; }\r
-                       set { collection4 = value; }\r
-               }\r
-       }\r
-       \r
-       public class Entity\r
-       {\r
-               private string _name = string.Empty;\r
-               private string _parent = null;\r
-\r
-               [XmlAttribute]\r
-               public string Name {\r
-                       get { return _name; }\r
-                       set { _name = value; }\r
-               }\r
-\r
-               [XmlIgnore] \r
-               public string Parent {\r
-                       get { return _parent; }\r
-                       set { _parent = value; }\r
-               }\r
-       }\r
-\r
-       public class EntityCollection : ArrayList\r
-       {\r
-               public string _container;\r
-\r
-               public EntityCollection ()\r
-               {\r
-               }\r
-\r
-               public EntityCollection (string c)\r
-               {\r
-                       _container = c;\r
-               }\r
-\r
-               public string Container {\r
-                       get { return _container; }\r
-                       set { _container = value; }\r
-               }\r
-\r
-               public int Add (Entity value)\r
-               {\r
-                       if(_container != null)\r
-                               value.Parent = _container;\r
-\r
-                       return base.Add(value);\r
-               }\r
-\r
-               public new Entity this[int index]\r
-               {\r
-                       get { return (Entity) base[index]; }\r
-                       set { base[index] = value; }\r
-               }\r
-       }\r
-       \r
-       [XmlType ("Container")]\r
-       public class ObjectWithReadonlyCollection\r
-       {\r
-               EntityCollection collection1 = new EntityCollection ("root");\r
-               \r
-               public EntityCollection Collection1 {\r
-                       get { return collection1; }\r
-               }\r
-       }\r
-       \r
-       [XmlType ("Container")]\r
-       public class ObjectWithReadonlyNulCollection\r
-       {\r
-               EntityCollection collection1;\r
-               \r
-               public EntityCollection Collection1 {\r
-                       get { return collection1; }\r
-               }\r
-       }\r
-       \r
-       [XmlType ("Container")]\r
-       public class ObjectWithReadonlyArray\r
-       {\r
-               Entity[] collection1 = new Entity [0];\r
-               \r
-               public Entity[] Collection1 {\r
-                       get { return collection1; }\r
-               }\r
-       }\r
-       \r
-       [XmlInclude (typeof(SubclassTestSub))]\r
-       public class SubclassTestBase\r
-       {\r
-       }\r
-       \r
-       public class SubclassTestSub: SubclassTestBase\r
-       {\r
-       }\r
-       \r
-       public class SubclassTestExtra\r
-       {\r
-       }\r
-       \r
-       public class SubclassTestContainer\r
-       {\r
-               [XmlElement ("a", typeof(SubclassTestBase))]\r
-               [XmlElement ("b", typeof(SubclassTestExtra))]\r
-               public object data;\r
-       }\r
-\r
-       public class DictionaryWithIndexer : DictionaryBase\r
-       {\r
-               public TimeSpan this[int index] {\r
-                       get { return TimeSpan.MinValue; }\r
-               }\r
-\r
-               public void Add (TimeSpan value)\r
-               {\r
-               }\r
-       }\r
-\r
-       [XmlRoot(Namespace="some:urn")]\r
-       [SoapTypeAttribute (Namespace="another:urn")]\r
-       public class PrimitiveTypesContainer\r
-       {\r
-               public PrimitiveTypesContainer ()\r
-               {\r
-                       Number = 2004;\r
-                       Name = "some name";\r
-                       Index = (byte) 56;\r
-                       Password = new byte[] { 243, 15 };\r
-                       PathSeparatorCharacter = '/';\r
-               }\r
-\r
-               public int Number;\r
-               public string Name;\r
-               public byte Index;\r
-               public byte[] Password;\r
-               public char PathSeparatorCharacter;\r
-       }\r
-       \r
-       public class TestSchemaForm1\r
-       {\r
-               public PrintTypeResponse p1;\r
-               \r
-               [XmlElement(Namespace="urn:oo")]\r
-               public PrintTypeResponse p2;\r
-       }\r
-\r
-       [XmlType (Namespace="urn:testForm")]\r
-       public class TestSchemaForm2\r
-       {\r
-               public PrintTypeResponse p1;\r
-               \r
-               [XmlElement(Namespace="urn:oo")]\r
-               public PrintTypeResponse p2;\r
-       }\r
-\r
-       [XmlType (Namespace="urn:responseTypes")]\r
-       public class PrintTypeResponse {\r
-               [XmlElement (Form=XmlSchemaForm.Unqualified, IsNullable=true)]\r
-           public OutputType result;\r
-           public PrintTypeResponse intern;\r
-           \r
-           public void Init ()\r
-           {\r
-               result = new OutputType ();\r
-               result.data = "data1";\r
-               intern = new PrintTypeResponse ();\r
-               intern.result = new OutputType ();\r
-               intern.result.data = "data2";\r
-           }\r
-       }\r
-\r
-       [XmlType (Namespace="urn:responseTypes")]\r
-       public class OutputType {\r
-           \r
-               [XmlElement (Form=XmlSchemaForm.Unqualified, IsNullable=true)]\r
-           public string data;\r
-       }\r
-\r
-       [XmlRootAttribute ("testDefault", Namespace="urn:myNS", IsNullable=false)]\r
-       [SoapType("testDefault", Namespace="urn:myNS")]\r
-       public class TestDefault\r
-       {\r
-               public string str;\r
-\r
-               [DefaultValue ("Default Value")]\r
-               public string strDefault = "Default Value";\r
-\r
-               [DefaultValue (true)]\r
-               public bool boolT = true;\r
-\r
-               [DefaultValue (false)]\r
-               public bool boolF = false;\r
-\r
-               [DefaultValue (typeof (decimal), "10")]\r
-               public decimal decimalval = 10m;\r
-\r
-               [DefaultValue (FlagEnum.e1 | FlagEnum.e4)]\r
-               public FlagEnum flag = (FlagEnum.e1 | FlagEnum.e4);\r
-\r
-               [DefaultValue (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e4)]\r
-               public FlagEnum_Encoded flagencoded = (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e4);\r
-       }\r
-\r
-       [XmlType ("optionalValueType", Namespace="some:urn")]\r
-       [XmlRootAttribute ("optionalValue", Namespace="another:urn", IsNullable=false)]\r
-       public class OptionalValueTypeContainer\r
-       {\r
-               [DefaultValue (FlagEnum.e1 | FlagEnum.e4)]\r
-               public FlagEnum Attributes = FlagEnum.e1 | FlagEnum.e4;\r
-\r
-               [DefaultValue (FlagEnum.e1)]\r
-               public FlagEnum Flags = FlagEnum.e1;\r
-\r
-               [XmlIgnore]\r
-               [SoapIgnore]\r
-               public bool FlagsSpecified;\r
-\r
-               [DefaultValue (false)]\r
-               public bool IsEmpty;\r
-\r
-               [XmlIgnore]\r
-               [SoapIgnore]\r
-               public bool IsEmptySpecified {\r
-                       get { return _isEmptySpecified; }\r
-                       set { _isEmptySpecified = value; }\r
-               }\r
-\r
-               [DefaultValue (false)]\r
-               public bool IsNull;\r
-\r
-               private bool _isEmptySpecified;\r
-       }\r
-}\r
-\r
+//
+// System.Xml.XmlSerializerTestClasses
+//
+// Authors:
+//   Erik LeBel <eriklebel@yahoo.ca>
+//   Hagit Yidov <hagity@mainsoft.com>
+//
+// (C) 2003 Erik LeBel
+// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
+//
+// Classes to use in the testing of the XmlSerializer
+//
+
+using System;
+using System.Collections;
+#if NET_2_0
+using System.Collections.Generic;
+#endif
+using System.ComponentModel;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.Serialization;
+
+namespace MonoTests.System.Xml.TestClasses
+{
+       public enum SimpleEnumeration { FIRST, SECOND };
+
+       [Flags]
+       public enum EnumDefaultValue { e1 = 1, e2 = 2, e3 = 3 }
+       public enum EnumDefaultValueNF { e1 = 1, e2 = 2, e3 = 3 }
+
+       [Flags]
+       public enum FlagEnum
+       {
+               [XmlEnum ("one")]
+               e1 = 1,
+               [XmlEnum ("two")]
+               e2 = 2,
+               [XmlEnum ("four")]
+               e4 = 4
+       }
+
+       [Flags]
+       [SoapType ("flagenum")]
+       public enum FlagEnum_Encoded
+       {
+               [SoapEnum ("one")]
+               e1 = 1,
+               [SoapEnum ("two")]
+               e2 = 2,
+               [SoapEnum ("four")]
+               e4 = 4
+       }
+
+       [Flags]
+       public enum ZeroFlagEnum
+       {
+               [XmlEnum ("zero")]
+               e0 = 0,
+               [XmlEnum ("o<n>e")]
+               e1 = 1,
+               [XmlEnum ("tns:t<w>o")]
+               e2 = 2,
+               [XmlEnum ("four")]
+               [XmlIgnore]
+               e4 = 4
+       }
+
+       #region GenericsTestClasses
+
+#if NET_2_0
+       public class GenSimpleClass<T>
+       {
+               public T something = default (T);
+       }
+
+       public struct GenSimpleStruct<T>
+       {
+               public T something;
+               public GenSimpleStruct (int dummy)
+               {
+                       something = default (T);
+               }
+       }
+
+       public class GenListClass<T>
+       {
+               public List<T> somelist = new List<T> ();
+       }
+
+       public class GenArrayClass<T>
+       {
+               public T[] arr = new T[3];
+       }
+
+       public class GenTwoClass<T1, T2>
+       {
+               public T1 something1 = default (T1);
+               public T2 something2 = default (T2);
+       }
+
+       public class GenDerivedClass<T1, T2> : GenTwoClass<string, int>
+       {
+               public T1 another1 = default (T1);
+               public T2 another2 = default (T2);
+       }
+
+       public class GenDerived2Class<T1, T2> : GenTwoClass<T1, T2>
+       {
+               public T1 another1 = default (T1);
+               public T2 another2 = default (T2);
+       }
+
+       public class GenNestedClass<TO, TI>
+       {
+               public TO outer = default (TO);
+               public class InnerClass<T>
+               {
+                       public TI inner = default (TI);
+                       public T something = default (T);
+               }
+       }
+
+       public struct GenComplexStruct<T1, T2>
+       {
+               public T1 something;
+               public GenSimpleClass<T1> simpleclass;
+               public GenSimpleStruct<T1> simplestruct;
+               public GenListClass<T1> listclass;
+               public GenArrayClass<T1> arrayclass;
+               public GenTwoClass<T1, T2> twoclass;
+               public GenDerivedClass<T1, T2> derivedclass;
+               public GenDerived2Class<T1, T2> derived2;
+               public GenNestedClass<T1, T2> nestedouter;
+               public GenNestedClass<T1, T2>.InnerClass<T1> nestedinner;
+               public GenComplexStruct (int dummy)
+               {
+                       something = default (T1);
+                       simpleclass = new GenSimpleClass<T1> ();
+                       simplestruct = new GenSimpleStruct<T1> ();
+                       listclass = new GenListClass<T1> ();
+                       arrayclass = new GenArrayClass<T1> ();
+                       twoclass = new GenTwoClass<T1, T2> ();
+                       derivedclass = new GenDerivedClass<T1, T2> ();
+                       derived2 = new GenDerived2Class<T1, T2> ();
+                       nestedouter = new GenNestedClass<T1, T2> ();
+                       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
+
+       public class SimpleClass
+       {
+               public string something = null;
+       }
+
+       public class StringCollection : CollectionBase
+       {
+               public void Add (String parameter)
+               {
+                       List.Insert (Count, parameter);
+               }
+
+               public String this[int index]
+               {
+                       get
+                       {
+                               if (index < 0 || index > Count)
+                                       throw new ArgumentOutOfRangeException ();
+
+                               return (String) List[index];
+                       }
+                       set { List[index] = value; }
+               }
+       }
+
+       public class StringCollectionContainer
+       {
+               StringCollection messages = new StringCollection ();
+
+               public StringCollection Messages
+               {
+                       get { return messages; }
+               }
+       }
+
+       public class ArrayContainer
+       {
+               public object[] items = null;
+       }
+
+       public class ClassArrayContainer
+       {
+               public SimpleClass[] items = null;
+       }
+
+       [XmlRoot ("simple")]
+       public class SimpleClassWithXmlAttributes
+       {
+               [XmlAttribute ("member")]
+               public string something = null;
+       }
+
+       [XmlRoot ("field")]
+       public class Field
+       {
+               [XmlAttribute ("flag1")]
+               [DefaultValue (1)]
+               public FlagEnum Flags1;
+
+               [XmlAttribute ("flag2")]
+               [DefaultValue (FlagEnum.e1)]
+               public FlagEnum Flags2;
+
+               [XmlAttribute ("flag3", Form = XmlSchemaForm.Qualified)]
+               [DefaultValue (FlagEnum.e1 | FlagEnum.e2)]
+               public FlagEnum Flags3;
+
+               [XmlAttribute ("flag4")]
+               public FlagEnum Flags4;
+
+               [XmlAttribute ("modifiers")]
+               public MapModifiers Modifiers;
+
+               [XmlAttribute ("modifiers2", Form = XmlSchemaForm.Unqualified)]
+               public MapModifiers Modifiers2;
+
+               [XmlAttribute ("modifiers3")]
+               [DefaultValue (0)]
+               public MapModifiers Modifiers3;
+
+               [XmlAttribute ("modifiers4", Form = XmlSchemaForm.Unqualified)]
+               [DefaultValue (MapModifiers.Protected)]
+               public MapModifiers Modifiers4;
+
+               [XmlAttribute ("modifiers5", Form = XmlSchemaForm.Qualified)]
+               [DefaultValue (MapModifiers.Public)]
+               public MapModifiers Modifiers5;
+
+               [XmlAttribute ("names")]
+               public string[] Names;
+
+               [XmlAttribute ("street")]
+               public string Street;
+       }
+
+       [SoapType ("field", Namespace = "some:urn")]
+       public class Field_Encoded
+       {
+               [SoapAttribute ("flag1")]
+               [DefaultValue (FlagEnum_Encoded.e1)]
+               public FlagEnum_Encoded Flags1;
+
+               [SoapAttribute ("flag2")]
+               [DefaultValue (FlagEnum_Encoded.e1)]
+               public FlagEnum_Encoded Flags2;
+
+               [SoapAttribute ("flag3")]
+               [DefaultValue (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e2)]
+               public FlagEnum_Encoded Flags3;
+
+               [SoapAttribute ("flag4")]
+               public FlagEnum_Encoded Flags4;
+
+               [SoapAttribute ("modifiers")]
+               public MapModifiers Modifiers;
+
+               [SoapAttribute ("modifiers2")]
+               public MapModifiers Modifiers2;
+
+               [SoapAttribute ("modifiers3")]
+               [DefaultValue (MapModifiers.Public)]
+               public MapModifiers Modifiers3;
+
+               [SoapAttribute ("modifiers4")]
+               [DefaultValue (MapModifiers.Protected)]
+               public MapModifiers Modifiers4;
+
+               [SoapAttribute ("modifiers5")]
+               [DefaultValue (MapModifiers.Public)]
+               public MapModifiers Modifiers5;
+
+               public string[] Names;
+
+               [SoapAttribute ("street")]
+               public string Street;
+       }
+
+       [Flags]
+       public enum MapModifiers
+       {
+               [XmlEnum ("public")]
+               [SoapEnum ("PuBlIc")]
+               Public = 0,
+               [XmlEnum ("protected")]
+               Protected = 1,
+       }
+
+       public class MyList : ArrayList
+       {
+               object container;
+
+               // NOTE: MyList has no public constructor
+               public MyList (object container)
+                       : base ()
+               {
+                       this.container = container;
+               }
+       }
+
+       public class Container
+       {
+               public MyList Items;
+
+               public Container ()
+               {
+                       Items = new MyList (this);
+               }
+       }
+
+       public class Container2
+       {
+               public MyList Items;
+
+               public Container2 ()
+               {
+               }
+
+               public Container2 (bool b)
+               {
+                       Items = new MyList (this);
+               }
+       }
+
+       public class MyElem : XmlElement
+       {
+               public MyElem (XmlDocument doc)
+                       : base ("", "myelem", "", doc)
+               {
+                       SetAttribute ("aa", "1");
+               }
+
+               [XmlAttribute]
+               public int kk = 1;
+       }
+
+       public class MyDocument : XmlDocument
+       {
+               public MyDocument ()
+               {
+               }
+
+               [XmlAttribute]
+               public int kk = 1;
+       }
+
+       public class CDataContainer
+       {
+               public XmlCDataSection cdata;
+       }
+
+       public class NodeContainer
+       {
+               public XmlNode node;
+       }
+
+       public class Choices
+       {
+               [XmlElementAttribute ("ChoiceZero", typeof (string), IsNullable = false)]
+               [XmlElementAttribute ("ChoiceOne", typeof (string), IsNullable = false)]
+               [XmlElementAttribute ("ChoiceTwo", typeof (string), IsNullable = false)]
+               [XmlChoiceIdentifier ("ItemType")]
+               public string MyChoice;
+
+               [XmlIgnore]
+               public ItemChoiceType ItemType;
+       }
+
+       [XmlType (IncludeInSchema = false)]
+       public enum ItemChoiceType
+       {
+               ChoiceZero,
+               [XmlEnum ("ChoiceOne")]
+               StrangeOne,
+               ChoiceTwo,
+       }
+
+       public class WrongChoices
+       {
+               [XmlElementAttribute ("ChoiceZero", typeof (string), IsNullable = false)]
+               [XmlElementAttribute ("StrangeOne", typeof (string), IsNullable = false)]
+               [XmlElementAttribute ("ChoiceTwo", typeof (string), IsNullable = false)]
+               [XmlChoiceIdentifier ("ItemType")]
+               public string MyChoice;
+
+               [XmlIgnore]
+               public ItemChoiceType ItemType;
+       }
+
+       [XmlType ("Type with space")]
+       public class TestSpace
+       {
+               [XmlElement (ElementName = "Element with space")]
+               public int elem;
+
+               [XmlAttribute (AttributeName = "Attribute with space")]
+               public int attr;
+       }
+
+       [Serializable]
+       public class ReadOnlyProperties
+       {
+               string[] strArr = new string[2] { "string1", "string2" };
+
+               public string[] StrArr
+               {
+                       get { return strArr; }
+               }
+
+               public string dat
+               {
+                       get { return "fff"; }
+               }
+       }
+
+       [XmlRoot ("root")]
+       public class ListDefaults
+       {
+               public ListDefaults ()
+               {
+                       ed = new SimpleClass ();
+                       str = "hola";
+               }
+
+               public ArrayList list2;
+
+               public MyList list3;
+
+               public string[] list4;
+
+               [XmlElement ("e", typeof (SimpleClass))]
+               public ArrayList list5;
+
+               [DefaultValue (null)]
+               public SimpleClass ed;
+
+               [DefaultValue (null)]
+               public string str;
+       }
+
+       public class clsPerson
+       {
+               public IList EmailAccounts;
+       }
+
+       public class ArrayClass
+       {
+               public object names = new object[] { "un", "dos" };
+       }
+
+       public class CompositeValueType
+       {
+               public void Init ()
+               {
+                       Items = new object[] { 1, 2 };
+                       ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.In, ItemsChoiceType.Es };
+               }
+
+               [XmlElementAttribute ("Es", typeof (int))]
+               [XmlElementAttribute ("In", typeof (int))]
+               [XmlChoiceIdentifierAttribute ("ItemsElementName")]
+               public object[] Items;
+
+               [XmlElementAttribute ("ItemsElementName")]
+               [XmlIgnoreAttribute ()]
+               public ItemsChoiceType[] ItemsElementName;
+       }
+
+       public enum ItemsChoiceType
+       {
+               In, Es
+       }
+
+       public class ArrayAttributeWithType
+       {
+               [XmlAttribute (DataType = "anyURI")]
+               public string[] at = new string[] { "a", "b" };
+
+               [XmlAttribute (DataType = "base64Binary")]
+               public byte[][] bin1 = new byte[][] { new byte[] { 1, 2 }, new byte[] { 1, 2 } };
+
+               [XmlAttribute (DataType = "base64Binary")]
+               public byte[] bin2 = new byte[] { 1, 2 };
+       }
+
+       public class ArrayAttributeWithWrongType
+       {
+               [XmlAttribute (DataType = "int")]
+               public string[] at = new string[] { "a", "b" };
+       }
+
+       [XmlType ("Container")]
+       public class EntityContainer
+       {
+               EntityCollection collection1;
+               EntityCollection collection2;
+               EntityCollection collection3 = new EntityCollection ("root");
+               EntityCollection collection4 = new EntityCollection ("root");
+
+               [XmlArray (IsNullable = true)]
+               public EntityCollection Collection1
+               {
+                       get { return collection1; }
+                       set { collection1 = value; collection1.Container = "assigned"; }
+               }
+
+               [XmlArray (IsNullable = false)]
+               public EntityCollection Collection2
+               {
+                       get { return collection2; }
+                       set { collection2 = value; collection2.Container = "assigned"; }
+               }
+
+               [XmlArray (IsNullable = true)]
+               public EntityCollection Collection3
+               {
+                       get { return collection3; }
+                       set { collection3 = value; collection3.Container = "assigned"; }
+               }
+
+               [XmlArray (IsNullable = false)]
+               public EntityCollection Collection4
+               {
+                       get { return collection4; }
+                       set { collection4 = value; collection4.Container = "assigned"; }
+               }
+       }
+
+       [XmlType ("Container")]
+       public class ArrayEntityContainer
+       {
+               Entity[] collection1;
+               Entity[] collection2;
+               Entity[] collection3 = new Entity[0];
+               Entity[] collection4 = new Entity[0];
+
+               [XmlArray (IsNullable = true)]
+               public Entity[] Collection1
+               {
+                       get { return collection1; }
+                       set { collection1 = value; }
+               }
+
+               [XmlArray (IsNullable = false)]
+               public Entity[] Collection2
+               {
+                       get { return collection2; }
+                       set { collection2 = value; }
+               }
+
+               [XmlArray (IsNullable = true)]
+               public Entity[] Collection3
+               {
+                       get { return collection3; }
+                       set { collection3 = value; }
+               }
+
+               [XmlArray (IsNullable = false)]
+               public Entity[] Collection4
+               {
+                       get { return collection4; }
+                       set { collection4 = value; }
+               }
+       }
+
+       public class Entity
+       {
+               private string _name = string.Empty;
+               private string _parent = null;
+
+               [XmlAttribute]
+               public string Name
+               {
+                       get { return _name; }
+                       set { _name = value; }
+               }
+
+               [XmlIgnore]
+               public string Parent
+               {
+                       get { return _parent; }
+                       set { _parent = value; }
+               }
+       }
+
+       public class EntityCollection : ArrayList
+       {
+               public string _container;
+
+               public EntityCollection ()
+               {
+               }
+
+               public EntityCollection (string c)
+               {
+                       _container = c;
+               }
+
+               public string Container
+               {
+                       get { return _container; }
+                       set { _container = value; }
+               }
+
+               public int Add (Entity value)
+               {
+                       if (_container != null)
+                               value.Parent = _container;
+
+                       return base.Add (value);
+               }
+
+               public new Entity this[int index]
+               {
+                       get { return (Entity) base[index]; }
+                       set { base[index] = value; }
+               }
+       }
+
+       [XmlType ("Container")]
+       public class ObjectWithReadonlyCollection
+       {
+               EntityCollection collection1 = new EntityCollection ("root");
+
+               public EntityCollection Collection1
+               {
+                       get { return collection1; }
+               }
+       }
+
+       [XmlType ("Container")]
+       public class ObjectWithReadonlyNulCollection
+       {
+               EntityCollection collection1;
+
+               public EntityCollection Collection1
+               {
+                       get { return collection1; }
+               }
+       }
+
+       [XmlType ("Container")]
+       public class ObjectWithReadonlyArray
+       {
+               Entity[] collection1 = new Entity[0];
+
+               public Entity[] Collection1
+               {
+                       get { return collection1; }
+               }
+       }
+
+       [XmlInclude (typeof (SubclassTestSub))]
+       public class SubclassTestBase
+       {
+       }
+
+       public class SubclassTestSub : SubclassTestBase
+       {
+       }
+
+       public class SubclassTestExtra
+       {
+       }
+
+       public class SubclassTestContainer
+       {
+               [XmlElement ("a", typeof (SubclassTestBase))]
+               [XmlElement ("b", typeof (SubclassTestExtra))]
+               public object data;
+       }
+
+       public class DictionaryWithIndexer : DictionaryBase
+       {
+               public TimeSpan this[int index]
+               {
+                       get { return TimeSpan.MinValue; }
+               }
+
+               public void Add (TimeSpan value)
+               {
+               }
+       }
+
+       [XmlRoot (Namespace = "some:urn")]
+       [SoapTypeAttribute (Namespace = "another:urn")]
+       public class PrimitiveTypesContainer
+       {
+               public PrimitiveTypesContainer ()
+               {
+                       Number = 2004;
+                       Name = "some name";
+                       Index = (byte) 56;
+                       Password = new byte[] { 243, 15 };
+                       PathSeparatorCharacter = '/';
+               }
+
+               public int Number;
+               public string Name;
+               public byte Index;
+               public byte[] Password;
+               public char PathSeparatorCharacter;
+       }
+
+       public class TestSchemaForm1
+       {
+               public PrintTypeResponse p1;
+
+               [XmlElement (Namespace = "urn:oo")]
+               public PrintTypeResponse p2;
+       }
+
+       [XmlType (Namespace = "urn:testForm")]
+       public class TestSchemaForm2
+       {
+               public PrintTypeResponse p1;
+
+               [XmlElement (Namespace = "urn:oo")]
+               public PrintTypeResponse p2;
+       }
+
+       [XmlType (Namespace = "urn:responseTypes")]
+       public class PrintTypeResponse
+       {
+               [XmlElement (Form = XmlSchemaForm.Unqualified, IsNullable = true)]
+               public OutputType result;
+               public PrintTypeResponse intern;
+
+               public void Init ()
+               {
+                       result = new OutputType ();
+                       result.data = "data1";
+                       intern = new PrintTypeResponse ();
+                       intern.result = new OutputType ();
+                       intern.result.data = "data2";
+               }
+       }
+
+       [XmlType (Namespace = "urn:responseTypes")]
+       public class OutputType
+       {
+
+               [XmlElement (Form = XmlSchemaForm.Unqualified, IsNullable = true)]
+               public string data;
+       }
+
+       [XmlRootAttribute ("testDefault", Namespace = "urn:myNS", IsNullable = false)]
+       [SoapType ("testDefault", Namespace = "urn:myNS")]
+       public class TestDefault
+       {
+               public string str;
+
+               [DefaultValue ("Default Value")]
+               public string strDefault = "Default Value";
+
+               [DefaultValue (true)]
+               public bool boolT = true;
+
+               [DefaultValue (false)]
+               public bool boolF = false;
+
+               [DefaultValue (typeof (decimal), "10")]
+               public decimal decimalval = 10m;
+
+               [DefaultValue (FlagEnum.e1 | FlagEnum.e4)]
+               public FlagEnum flag = (FlagEnum.e1 | FlagEnum.e4);
+
+               [DefaultValue (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e4)]
+               public FlagEnum_Encoded flagencoded = (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e4);
+       }
+
+       [XmlType ("optionalValueType", Namespace = "some:urn")]
+       [XmlRootAttribute ("optionalValue", Namespace = "another:urn", IsNullable = false)]
+       public class OptionalValueTypeContainer
+       {
+               [DefaultValue (FlagEnum.e1 | FlagEnum.e4)]
+               public FlagEnum Attributes = FlagEnum.e1 | FlagEnum.e4;
+
+               [DefaultValue (FlagEnum.e1)]
+               public FlagEnum Flags = FlagEnum.e1;
+
+               [XmlIgnore]
+               [SoapIgnore]
+               public bool FlagsSpecified;
+
+               [DefaultValue (false)]
+               public bool IsEmpty;
+
+               [XmlIgnore]
+               [SoapIgnore]
+               public bool IsEmptySpecified
+               {
+                       get { return _isEmptySpecified; }
+                       set { _isEmptySpecified = value; }
+               }
+
+               [DefaultValue (false)]
+               public bool IsNull;
+
+               private bool _isEmptySpecified;
+       }
+
+       public class Group
+       {
+               [SoapAttribute (Namespace = "http://www.cpandl.com")]
+               public string GroupName;
+
+               [SoapAttribute (DataType = "base64Binary")]
+               public Byte[] GroupNumber;
+
+               [SoapAttribute (DataType = "date", AttributeName = "CreationDate")]
+               public DateTime Today;
+
+               [SoapElement (DataType = "nonNegativeInteger", ElementName = "PosInt")]
+               public string PostitiveInt;
+
+               [SoapIgnore]
+               public bool IgnoreThis;
+
+               [DefaultValue (GroupType.B)]
+               public GroupType Grouptype;
+               public Vehicle MyVehicle;
+
+               [SoapInclude (typeof (Car))]
+               public Vehicle myCar (string licNumber)
+               {
+                       Vehicle v;
+                       if (licNumber == string.Empty) {
+                               v = new Car ();
+                               v.licenseNumber = "!!!!!!";
+                       }
+                       else {
+                               v = new Car ();
+                               v.licenseNumber = licNumber;
+                       }
+                       return v;
+               }
+       }
+
+       [SoapInclude (typeof (Car))]
+       public abstract class Vehicle
+       {
+               public string licenseNumber;
+               [SoapElement (DataType = "date")]
+               public DateTime makeDate;
+               [DefaultValue ("450")]
+               public string weight;
+       }
+
+       public class Car : Vehicle
+       {
+       }
+
+       public enum GroupType
+       {
+               [SoapEnum ("Small")]
+               A,
+               [SoapEnum ("Large")]
+               B
+       }
+}
+