Revert "[system.xml] Serialization from reference sources for desktop"
[mono.git] / mcs / class / System.XML / Test / System.Xml.Serialization / XmlSerializerTestClasses.cs
1 //
2 // System.Xml.XmlSerializerTestClasses
3 //
4 // Authors:
5 //   Erik LeBel <eriklebel@yahoo.ca>
6 //   Hagit Yidov <hagity@mainsoft.com>
7 //
8 // (C) 2003 Erik LeBel
9 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
10 //
11 // Classes to use in the testing of the XmlSerializer
12 //
13
14 using System;
15 using System.Collections;
16 using System.Collections.Generic;
17 using System.ComponentModel;
18 using System.Xml;
19 using System.Xml.Schema;
20 using System.Xml.Serialization;
21
22 namespace MonoTests.System.Xml.TestClasses
23 {
24         public enum SimpleEnumeration { FIRST, SECOND };
25
26         [Flags]
27         public enum EnumDefaultValue { e1 = 1, e2 = 2, e3 = 3 }
28         public enum EnumDefaultValueNF { e1 = 1, e2 = 2, e3 = 3 }
29
30         [Flags]
31         public enum FlagEnum
32         {
33                 [XmlEnum ("one")]
34                 e1 = 1,
35                 [XmlEnum ("two")]
36                 e2 = 2,
37                 [XmlEnum ("four")]
38                 e4 = 4
39         }
40
41         [Flags]
42         [SoapType ("flagenum")]
43         public enum FlagEnum_Encoded
44         {
45                 [SoapEnum ("one")]
46                 e1 = 1,
47                 [SoapEnum ("two")]
48                 e2 = 2,
49                 [SoapEnum ("four")]
50                 e4 = 4
51         }
52
53         [Flags]
54         public enum ZeroFlagEnum
55         {
56                 [XmlEnum ("zero")]
57                 e0 = 0,
58                 [XmlEnum ("o<n>e")]
59                 e1 = 1,
60                 [XmlEnum ("tns:t<w>o")]
61                 e2 = 2,
62                 [XmlEnum ("four")]
63                 [XmlIgnore]
64                 e4 = 4
65         }
66
67         #region GenericsTestClasses
68
69         public class GenSimpleClass<T>
70         {
71                 public T something = default (T);
72         }
73
74         public struct GenSimpleStruct<T>
75         {
76                 public T something;
77                 public GenSimpleStruct (int dummy)
78                 {
79                         something = default (T);
80                 }
81         }
82
83         public class GenListClass<T>
84         {
85                 public List<T> somelist = new List<T> ();
86         }
87
88         public class GenArrayClass<T>
89         {
90                 public T[] arr = new T[3];
91         }
92
93         public class GenTwoClass<T1, T2>
94         {
95                 public T1 something1 = default (T1);
96                 public T2 something2 = default (T2);
97         }
98
99         public class GenDerivedClass<T1, T2> : GenTwoClass<string, int>
100         {
101                 public T1 another1 = default (T1);
102                 public T2 another2 = default (T2);
103         }
104
105         public class GenDerived2Class<T1, T2> : GenTwoClass<T1, T2>
106         {
107                 public T1 another1 = default (T1);
108                 public T2 another2 = default (T2);
109         }
110
111         public class GenNestedClass<TO, TI>
112         {
113                 public TO outer = default (TO);
114                 public class InnerClass<T>
115                 {
116                         public TI inner = default (TI);
117                         public T something = default (T);
118                 }
119         }
120
121         public struct GenComplexStruct<T1, T2>
122         {
123                 public T1 something;
124                 public GenSimpleClass<T1> simpleclass;
125                 public GenSimpleStruct<T1> simplestruct;
126                 public GenListClass<T1> listclass;
127                 public GenArrayClass<T1> arrayclass;
128                 public GenTwoClass<T1, T2> twoclass;
129                 public GenDerivedClass<T1, T2> derivedclass;
130                 public GenDerived2Class<T1, T2> derived2;
131                 public GenNestedClass<T1, T2> nestedouter;
132                 public GenNestedClass<T1, T2>.InnerClass<T1> nestedinner;
133                 public GenComplexStruct (int dummy)
134                 {
135                         something = default (T1);
136                         simpleclass = new GenSimpleClass<T1> ();
137                         simplestruct = new GenSimpleStruct<T1> ();
138                         listclass = new GenListClass<T1> ();
139                         arrayclass = new GenArrayClass<T1> ();
140                         twoclass = new GenTwoClass<T1, T2> ();
141                         derivedclass = new GenDerivedClass<T1, T2> ();
142                         derived2 = new GenDerived2Class<T1, T2> ();
143                         nestedouter = new GenNestedClass<T1, T2> ();
144                         nestedinner = new GenNestedClass<T1, T2>.InnerClass<T1> ();
145                 }
146         }
147                 
148         public class WithNulls
149         {
150                 [XmlElement (IsNullable=true)]
151                 public int? nint;
152                 
153                 [XmlElement (IsNullable=true)]
154                 public TestEnumWithNulls? nenum;
155                 
156                 [XmlElement (IsNullable=true)]
157                 public DateTime? ndate;
158         }
159         
160         public enum TestEnumWithNulls
161         {
162                 aa,
163                 bb
164         }
165         
166
167         #endregion // GenericsTestClasses
168
169         public class SimpleClass
170         {
171                 public string something = null;
172         }
173
174         public class StringCollection : CollectionBase
175         {
176                 public void Add (String parameter)
177                 {
178                         List.Insert (Count, parameter);
179                 }
180
181                 public String this[int index]
182                 {
183                         get
184                         {
185                                 if (index < 0 || index > Count)
186                                         throw new ArgumentOutOfRangeException ();
187
188                                 return (String) List[index];
189                         }
190                         set { List[index] = value; }
191                 }
192         }
193
194         public class StringCollectionContainer
195         {
196                 StringCollection messages = new StringCollection ();
197
198                 public StringCollection Messages
199                 {
200                         get { return messages; }
201                 }
202         }
203
204         public class ArrayContainer
205         {
206                 public object[] items = null;
207         }
208
209         public class ClassArrayContainer
210         {
211                 public SimpleClass[] items = null;
212         }
213
214         [XmlRoot ("simple")]
215         public class SimpleClassWithXmlAttributes
216         {
217                 [XmlAttribute ("member")]
218                 public string something = null;
219         }
220
221         [XmlRoot ("field")]
222         public class Field
223         {
224                 [XmlAttribute ("flag1")]
225                 [DefaultValue (1)]
226                 public FlagEnum Flags1;
227
228                 [XmlAttribute ("flag2")]
229                 [DefaultValue (FlagEnum.e1)]
230                 public FlagEnum Flags2;
231
232                 [XmlAttribute ("flag3", Form = XmlSchemaForm.Qualified)]
233                 [DefaultValue (FlagEnum.e1 | FlagEnum.e2)]
234                 public FlagEnum Flags3;
235
236                 [XmlAttribute ("flag4")]
237                 public FlagEnum Flags4;
238
239                 [XmlAttribute ("modifiers")]
240                 public MapModifiers Modifiers;
241
242                 [XmlAttribute ("modifiers2", Form = XmlSchemaForm.Unqualified)]
243                 public MapModifiers Modifiers2;
244
245                 [XmlAttribute ("modifiers3")]
246                 [DefaultValue (0)]
247                 public MapModifiers Modifiers3;
248
249                 [XmlAttribute ("modifiers4", Form = XmlSchemaForm.Unqualified)]
250                 [DefaultValue (MapModifiers.Protected)]
251                 public MapModifiers Modifiers4;
252
253                 [XmlAttribute ("modifiers5", Form = XmlSchemaForm.Qualified)]
254                 [DefaultValue (MapModifiers.Public)]
255                 public MapModifiers Modifiers5;
256
257                 [XmlAttribute ("names")]
258                 public string[] Names;
259
260                 [XmlAttribute ("street")]
261                 public string Street;
262         }
263
264         [SoapType ("field", Namespace = "some:urn")]
265         public class Field_Encoded
266         {
267                 [SoapAttribute ("flag1")]
268                 [DefaultValue (FlagEnum_Encoded.e1)]
269                 public FlagEnum_Encoded Flags1;
270
271                 [SoapAttribute ("flag2")]
272                 [DefaultValue (FlagEnum_Encoded.e1)]
273                 public FlagEnum_Encoded Flags2;
274
275                 [SoapAttribute ("flag3")]
276                 [DefaultValue (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e2)]
277                 public FlagEnum_Encoded Flags3;
278
279                 [SoapAttribute ("flag4")]
280                 public FlagEnum_Encoded Flags4;
281
282                 [SoapAttribute ("modifiers")]
283                 public MapModifiers Modifiers;
284
285                 [SoapAttribute ("modifiers2")]
286                 public MapModifiers Modifiers2;
287
288                 [SoapAttribute ("modifiers3")]
289                 [DefaultValue (MapModifiers.Public)]
290                 public MapModifiers Modifiers3;
291
292                 [SoapAttribute ("modifiers4")]
293                 [DefaultValue (MapModifiers.Protected)]
294                 public MapModifiers Modifiers4;
295
296                 [SoapAttribute ("modifiers5")]
297                 [DefaultValue (MapModifiers.Public)]
298                 public MapModifiers Modifiers5;
299
300                 public string[] Names;
301
302                 [SoapAttribute ("street")]
303                 public string Street;
304         }
305
306         [Flags]
307         public enum MapModifiers
308         {
309                 [XmlEnum ("public")]
310                 [SoapEnum ("PuBlIc")]
311                 Public = 0,
312                 [XmlEnum ("protected")]
313                 Protected = 1,
314         }
315
316         public class MyList : ArrayList
317         {
318                 object container;
319
320                 // NOTE: MyList has no public constructor
321                 public MyList (object container)
322                         : base ()
323                 {
324                         this.container = container;
325                 }
326         }
327
328         public class Container
329         {
330                 public MyList Items;
331
332                 public Container ()
333                 {
334                         Items = new MyList (this);
335                 }
336         }
337
338         public class Container2
339         {
340                 public MyList Items;
341
342                 public Container2 ()
343                 {
344                 }
345
346                 public Container2 (bool b)
347                 {
348                         Items = new MyList (this);
349                 }
350         }
351
352         public class MyElem : XmlElement
353         {
354                 public MyElem (XmlDocument doc)
355                         : base ("", "myelem", "", doc)
356                 {
357                         SetAttribute ("aa", "1");
358                 }
359
360                 [XmlAttribute]
361                 public int kk = 1;
362         }
363
364         public class MyDocument : XmlDocument
365         {
366                 public MyDocument ()
367                 {
368                 }
369
370                 [XmlAttribute]
371                 public int kk = 1;
372         }
373
374         public class CDataContainer
375         {
376                 public XmlCDataSection cdata;
377         }
378
379         public class NodeContainer
380         {
381                 public XmlNode node;
382         }
383
384         public class Choices
385         {
386                 [XmlElementAttribute ("ChoiceZero", typeof (string), IsNullable = false)]
387                 [XmlElementAttribute ("ChoiceOne", typeof (string), IsNullable = false)]
388                 [XmlElementAttribute ("ChoiceTwo", typeof (string), IsNullable = false)]
389                 [XmlChoiceIdentifier ("ItemType")]
390                 public string MyChoice;
391
392                 [XmlIgnore]
393                 public ItemChoiceType ItemType;
394         }
395
396         [XmlType (IncludeInSchema = false)]
397         public enum ItemChoiceType
398         {
399                 ChoiceZero,
400                 [XmlEnum ("ChoiceOne")]
401                 StrangeOne,
402                 ChoiceTwo,
403         }
404
405         public class WrongChoices
406         {
407                 [XmlElementAttribute ("ChoiceZero", typeof (string), IsNullable = false)]
408                 [XmlElementAttribute ("StrangeOne", typeof (string), IsNullable = false)]
409                 [XmlElementAttribute ("ChoiceTwo", typeof (string), IsNullable = false)]
410                 [XmlChoiceIdentifier ("ItemType")]
411                 public string MyChoice;
412
413                 [XmlIgnore]
414                 public ItemChoiceType ItemType;
415         }
416
417         [XmlType ("Type with space")]
418         public class TestSpace
419         {
420                 [XmlElement (ElementName = "Element with space")]
421                 public int elem;
422
423                 [XmlAttribute (AttributeName = "Attribute with space")]
424                 public int attr;
425         }
426
427         [Serializable]
428         public class ReadOnlyProperties
429         {
430                 string[] strArr = new string[2] { "string1", "string2" };
431                 List<string> strList = new List<string> { "listString1" };
432
433                 public string[] StrArr
434                 {
435                         get { return strArr; }
436                 }
437
438                 public string dat
439                 {
440                         get { return "fff"; }
441                 }
442
443                 public IList<string> StrList { get { return strList; } }
444         }
445
446         [Serializable]
447         public class ReadOnlyListProperty {
448                 List<string> strList = new List<string> { "listString1", "listString2" };
449
450                 public List<string> StrList
451                 {
452                         get { return strList; }
453                 }
454         }
455
456
457         [XmlRoot ("root")]
458         public class ListDefaults
459         {
460                 public ListDefaults ()
461                 {
462                         ed = new SimpleClass ();
463                         str = "hola";
464                 }
465
466                 public ArrayList list2;
467
468                 public MyList list3;
469
470                 public string[] list4;
471
472                 [XmlElement ("e", typeof (SimpleClass))]
473                 public ArrayList list5;
474
475                 [DefaultValue (null)]
476                 public SimpleClass ed;
477
478                 [DefaultValue (null)]
479                 public string str;
480         }
481
482         public class clsPerson
483         {
484                 public IList EmailAccounts;
485         }
486
487         public class ArrayClass
488         {
489                 public object names = new object[] { "un", "dos" };
490         }
491
492         public class CompositeValueType
493         {
494                 public void Init ()
495                 {
496                         Items = new object[] { 1, 2 };
497                         ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.In, ItemsChoiceType.Es };
498                 }
499
500                 [XmlElementAttribute ("Es", typeof (int))]
501                 [XmlElementAttribute ("In", typeof (int))]
502                 [XmlChoiceIdentifierAttribute ("ItemsElementName")]
503                 public object[] Items;
504
505                 [XmlElementAttribute ("ItemsElementName")]
506                 [XmlIgnoreAttribute ()]
507                 public ItemsChoiceType[] ItemsElementName;
508         }
509
510         public enum ItemsChoiceType
511         {
512                 In, Es
513         }
514
515         public class ArrayAttributeWithType
516         {
517                 [XmlAttribute (DataType = "anyURI")]
518                 public string[] at = new string[] { "a", "b" };
519
520                 [XmlAttribute (DataType = "base64Binary")]
521                 public byte[][] bin1 = new byte[][] { new byte[] { 1, 2 }, new byte[] { 1, 2 } };
522
523                 [XmlAttribute (DataType = "base64Binary")]
524                 public byte[] bin2 = new byte[] { 1, 2 };
525         }
526
527         public class ArrayAttributeWithWrongType
528         {
529                 [XmlAttribute (DataType = "int")]
530                 public string[] at = new string[] { "a", "b" };
531         }
532
533         [XmlType ("Container")]
534         public class EntityContainer
535         {
536                 EntityCollection collection1;
537                 EntityCollection collection2;
538                 EntityCollection collection3 = new EntityCollection ("root");
539                 EntityCollection collection4 = new EntityCollection ("root");
540
541                 [XmlArray (IsNullable = true)]
542                 public EntityCollection Collection1
543                 {
544                         get { return collection1; }
545                         set { collection1 = value; collection1.Container = "assigned"; }
546                 }
547
548                 [XmlArray (IsNullable = false)]
549                 public EntityCollection Collection2
550                 {
551                         get { return collection2; }
552                         set { collection2 = value; collection2.Container = "assigned"; }
553                 }
554
555                 [XmlArray (IsNullable = true)]
556                 public EntityCollection Collection3
557                 {
558                         get { return collection3; }
559                         set { collection3 = value; collection3.Container = "assigned"; }
560                 }
561
562                 [XmlArray (IsNullable = false)]
563                 public EntityCollection Collection4
564                 {
565                         get { return collection4; }
566                         set { collection4 = value; collection4.Container = "assigned"; }
567                 }
568         }
569
570         [XmlType ("Container")]
571         public class ArrayEntityContainer
572         {
573                 Entity[] collection1;
574                 Entity[] collection2;
575                 Entity[] collection3 = new Entity[0];
576                 Entity[] collection4 = new Entity[0];
577
578                 [XmlArray (IsNullable = true)]
579                 public Entity[] Collection1
580                 {
581                         get { return collection1; }
582                         set { collection1 = value; }
583                 }
584
585                 [XmlArray (IsNullable = false)]
586                 public Entity[] Collection2
587                 {
588                         get { return collection2; }
589                         set { collection2 = value; }
590                 }
591
592                 [XmlArray (IsNullable = true)]
593                 public Entity[] Collection3
594                 {
595                         get { return collection3; }
596                         set { collection3 = value; }
597                 }
598
599                 [XmlArray (IsNullable = false)]
600                 public Entity[] Collection4
601                 {
602                         get { return collection4; }
603                         set { collection4 = value; }
604                 }
605         }
606
607         public class Entity
608         {
609                 private string _name = string.Empty;
610                 private string _parent = null;
611
612                 [XmlAttribute]
613                 public string Name
614                 {
615                         get { return _name; }
616                         set { _name = value; }
617                 }
618
619                 [XmlIgnore]
620                 public string Parent
621                 {
622                         get { return _parent; }
623                         set { _parent = value; }
624                 }
625         }
626
627         public class EntityCollection : ArrayList
628         {
629                 public string _container;
630
631                 public EntityCollection ()
632                 {
633                 }
634
635                 public EntityCollection (string c)
636                 {
637                         _container = c;
638                 }
639
640                 public string Container
641                 {
642                         get { return _container; }
643                         set { _container = value; }
644                 }
645
646                 public int Add (Entity value)
647                 {
648                         if (_container != null)
649                                 value.Parent = _container;
650
651                         return base.Add (value);
652                 }
653
654                 public new Entity this[int index]
655                 {
656                         get { return (Entity) base[index]; }
657                         set { base[index] = value; }
658                 }
659         }
660
661         [XmlType ("Container")]
662         public class ObjectWithReadonlyCollection
663         {
664                 EntityCollection collection1 = new EntityCollection ("root");
665
666                 public EntityCollection Collection1
667                 {
668                         get { return collection1; }
669                 }
670         }
671
672         [XmlType ("Container")]
673         public class ObjectWithReadonlyNulCollection
674         {
675                 EntityCollection collection1;
676
677                 public EntityCollection Collection1
678                 {
679                         get { return collection1; }
680                 }
681         }
682
683         [XmlType ("Container")]
684         public class ObjectWithReadonlyArray
685         {
686                 Entity[] collection1 = new Entity[0];
687
688                 public Entity[] Collection1
689                 {
690                         get { return collection1; }
691                 }
692         }
693
694         [XmlInclude (typeof (SubclassTestSub))]
695         public class SubclassTestBase
696         {
697         }
698
699         public class SubclassTestSub : SubclassTestBase
700         {
701         }
702
703         public class SubclassTestExtra
704         {
705         }
706
707         public class SubclassTestContainer
708         {
709                 [XmlElement ("a", typeof (SubclassTestBase))]
710                 [XmlElement ("b", typeof (SubclassTestExtra))]
711                 public object data;
712         }
713
714         public class DictionaryWithIndexer : DictionaryBase
715         {
716                 public TimeSpan this[int index]
717                 {
718                         get { return TimeSpan.MinValue; }
719                 }
720
721                 public void Add (TimeSpan value)
722                 {
723                 }
724         }
725
726         [XmlRoot (Namespace = "some:urn")]
727         [SoapTypeAttribute (Namespace = "another:urn")]
728         public class PrimitiveTypesContainer
729         {
730                 public PrimitiveTypesContainer ()
731                 {
732                         Number = 2004;
733                         Name = "some name";
734                         Index = (byte) 56;
735                         Password = new byte[] { 243, 15 };
736                         PathSeparatorCharacter = '/';
737                 }
738
739                 public int Number;
740                 public string Name;
741                 public byte Index;
742                 public byte[] Password;
743                 public char PathSeparatorCharacter;
744         }
745
746         public class TestSchemaForm1
747         {
748                 public PrintTypeResponse p1;
749
750                 [XmlElement (Namespace = "urn:oo")]
751                 public PrintTypeResponse p2;
752         }
753
754         [XmlType (Namespace = "urn:testForm")]
755         public class TestSchemaForm2
756         {
757                 public PrintTypeResponse p1;
758
759                 [XmlElement (Namespace = "urn:oo")]
760                 public PrintTypeResponse p2;
761         }
762
763         [XmlType (Namespace = "urn:responseTypes")]
764         public class PrintTypeResponse
765         {
766                 [XmlElement (Form = XmlSchemaForm.Unqualified, IsNullable = true)]
767                 public OutputType result;
768                 public PrintTypeResponse intern;
769
770                 public void Init ()
771                 {
772                         result = new OutputType ();
773                         result.data = "data1";
774                         intern = new PrintTypeResponse ();
775                         intern.result = new OutputType ();
776                         intern.result.data = "data2";
777                 }
778         }
779
780         [XmlType (Namespace = "urn:responseTypes")]
781         public class OutputType
782         {
783
784                 [XmlElement (Form = XmlSchemaForm.Unqualified, IsNullable = true)]
785                 public string data;
786         }
787
788         [XmlRootAttribute ("testDefault", Namespace = "urn:myNS", IsNullable = false)]
789         [SoapType ("testDefault", Namespace = "urn:myNS")]
790         public class TestDefault
791         {
792                 public string str;
793
794                 [DefaultValue ("Default Value")]
795                 public string strDefault = "Default Value";
796
797                 [DefaultValue (true)]
798                 public bool boolT = true;
799
800                 [DefaultValue (false)]
801                 public bool boolF = false;
802
803                 [DefaultValue (typeof (decimal), "10")]
804                 public decimal decimalval = 10m;
805
806                 [DefaultValue (FlagEnum.e1 | FlagEnum.e4)]
807                 public FlagEnum flag = (FlagEnum.e1 | FlagEnum.e4);
808
809                 [DefaultValue (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e4)]
810                 public FlagEnum_Encoded flagencoded = (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e4);
811         }
812
813         [XmlType ("optionalValueType", Namespace = "some:urn")]
814         [XmlRootAttribute ("optionalValue", Namespace = "another:urn", IsNullable = false)]
815         public class OptionalValueTypeContainer
816         {
817                 [DefaultValue (FlagEnum.e1 | FlagEnum.e4)]
818                 public FlagEnum Attributes = FlagEnum.e1 | FlagEnum.e4;
819
820                 [DefaultValue (FlagEnum.e1)]
821                 public FlagEnum Flags = FlagEnum.e1;
822
823                 [XmlIgnore]
824                 [SoapIgnore]
825                 public bool FlagsSpecified;
826
827                 [DefaultValue (false)]
828                 public bool IsEmpty;
829
830                 [XmlIgnore]
831                 [SoapIgnore]
832                 public bool IsEmptySpecified
833                 {
834                         get { return _isEmptySpecified; }
835                         set { _isEmptySpecified = value; }
836                 }
837
838                 [DefaultValue (false)]
839                 public bool IsNull;
840
841                 private bool _isEmptySpecified;
842         }
843
844         public class Group
845         {
846                 [SoapAttribute (Namespace = "http://www.cpandl.com")]
847                 public string GroupName;
848
849                 [SoapAttribute (DataType = "base64Binary")]
850                 public Byte[] GroupNumber;
851
852                 [SoapAttribute (DataType = "date", AttributeName = "CreationDate")]
853                 public DateTime Today;
854
855                 [SoapElement (DataType = "nonNegativeInteger", ElementName = "PosInt")]
856                 public string PostitiveInt;
857
858                 [SoapIgnore]
859                 public bool IgnoreThis;
860
861                 [DefaultValue (GroupType.B)]
862                 public GroupType Grouptype;
863                 public Vehicle MyVehicle;
864
865                 [SoapInclude (typeof (Car))]
866                 public Vehicle myCar (string licNumber)
867                 {
868                         Vehicle v;
869                         if (licNumber == string.Empty) {
870                                 v = new Car ();
871                                 v.licenseNumber = "!!!!!!";
872                         }
873                         else {
874                                 v = new Car ();
875                                 v.licenseNumber = licNumber;
876                         }
877                         return v;
878                 }
879         }
880
881         [SoapInclude (typeof (Car))]
882         public abstract class Vehicle
883         {
884                 public string licenseNumber;
885                 [SoapElement (DataType = "date")]
886                 public DateTime makeDate;
887                 [DefaultValue ("450")]
888                 public string weight;
889         }
890
891         public class Car : Vehicle
892         {
893         }
894
895         public enum GroupType
896         {
897                 [SoapEnum ("Small")]
898                 A,
899                 [SoapEnum ("Large")]
900                 B
901         }
902
903         public class ErrorneousGetSchema : IXmlSerializable
904         {
905                 public XmlSchema GetSchema ()
906                 {
907                         throw new ApplicationException ("unexpected");
908                 }
909
910                 public void ReadXml (XmlReader reader)
911                 {
912                 }
913
914                 public void WriteXml (XmlWriter writer)
915                 {
916                 }
917
918                 // it should be serialized IF it is NOT IXmlSerializable.
919                 public string Whoa = "whoa";
920         }
921
922         [XmlRoot ("DefaultDateTimeContainer", Namespace = "urn:foo")]
923         public class DefaultDateTimeContainer // bug #378696
924         {
925                 public DateTime SimpleDateTime;
926
927                 [DefaultValue(typeof(DateTime), "2001-02-03T04:05:06")]
928                 public DateTime FancyDateTime;
929
930                 [DefaultValue (typeof (int), "123456")]
931                 public int Numeric;
932         }
933
934         public class XmlSerializableImplicitConvertible
935         {
936                 public BaseClass B = new DerivedClass ();
937
938                 public class XmlSerializable : IXmlSerializable
939                 {
940                         public void WriteXml (XmlWriter writer)
941                         {
942                         }
943
944                         public void ReadXml (XmlReader reader)
945                         {
946                         }
947
948                         public XmlSchema GetSchema ()
949                         {
950                                 return null;
951                         }
952                 }
953
954                 public class BaseClass
955                 {
956                         public static implicit operator XmlSerializable (BaseClass b)
957                         {
958                                 return new XmlSerializable ();
959
960                         }
961
962                         public static implicit operator BaseClass (XmlSerializable x)
963                         {
964                                 return new BaseClass ();
965                         }
966                 }
967
968                 public class DerivedClass : BaseClass
969                 {
970                 }
971         }
972
973         public class Bug704813Type
974         {
975                 IEnumerable<string> foo = new List<string> ();
976                 public IEnumerable<string> Foo {
977                         get { return foo; }
978                 }
979         }
980
981         public class Bug708178Type
982         {
983                 List<string> foo = new List<string> ();
984
985                 [XmlArray("Foo"), XmlArrayItem("Foo", typeof(string))]
986                 public List<string> Foo {
987                         get { return foo; }
988                 }                
989         }
990
991         [XmlRoot("root")]
992         public class ExplicitlyOrderedMembersType1
993         {
994                 [XmlElement("child0", Order = 4)]
995                 public string Child0;
996
997                 [XmlElement("child", Order = 0)]
998                 public string Child1;
999
1000                 [XmlElement("child", Order = 2)]
1001                 public string Child2;
1002         }
1003
1004         [XmlRoot("root")]
1005         public class ExplicitlyOrderedMembersType2
1006         {
1007                 [XmlElement("child0", Order = 4)]
1008                 public string Child0;
1009
1010                 [XmlElement("child")] // wrong. Needs to be Ordered as well.
1011                 public string Child1;
1012
1013                 [XmlElement("child", Order = 2)]
1014                 public string Child2;
1015         }
1016
1017         [XmlRoot("root")]
1018         public class ExplicitlyOrderedMembersType3
1019         {
1020                 [XmlElement("child0", Order = 1)] // it's between 0 and 2. After two "child" elements, child0 is not recognized as this member.
1021                 public string Child0;
1022
1023                 [XmlElement("child", Order = 0)]
1024                 public string Child1;
1025
1026                 [XmlElement("child", Order = 2)]
1027                 public string Child2;
1028         }
1029
1030         [XmlRoot("root")]
1031         public class ExplicitlyOrderedMembersType4
1032         {
1033                 [XmlElement("child0", Order = 1)] // it's between 0 and 2. After two "child" elements, child0 is not recognized as this member.
1034                 public string Child0;
1035                 
1036                 [XmlElement("child", Order = 0)]
1037                 public string Child1;
1038                 
1039                 [XmlElement("child", Order = 2)]
1040                 public string Child2;
1041                 
1042                 [XmlAttribute]
1043                 public string Child3;
1044         }
1045
1046         [XmlRoot ("root")]
1047         public class NullableDatesAndTimes {
1048                 [XmlElementAttribute ("MyTime", DataType = "time", IsNullable = false)]
1049                 public DateTime MyTime;
1050                         
1051                 [XmlElementAttribute ("MyTimeNullable", DataType = "time", IsNullable = true)]
1052                 public DateTime? MyTimeNullable;
1053                 
1054                 [XmlElementAttribute ("MyDate", DataType = "date", IsNullable = false)]
1055                 public DateTime MyDate;
1056                 
1057                 [XmlElementAttribute ("MyDateNullable", DataType = "date", IsNullable = true)]
1058                 public DateTime? MyDateNullable;
1059         }
1060
1061         public class NotExactDateParseClass
1062         {
1063                 [XmlElementAttribute (DataType = "date")]
1064                 public DateTime SomeDate;
1065         }
1066
1067         public class Bug8468BaseClass
1068         {
1069                 public string Base;
1070         }
1071
1072         public class Bug8468MidClass: Bug8468BaseClass
1073         {
1074                 public string Mid;
1075         }
1076
1077         [XmlRoot("Test", Namespace="http://test-namespace")]
1078         public class Bug8468Subclass: Bug8468MidClass
1079         {
1080         }
1081
1082         [XmlRoot("Test")]
1083         public class Bug8468SubclassNoNamespace: Bug8468MidClass
1084         {
1085         }
1086
1087         [XmlRoot("Test", Namespace="")]
1088         public class Bug8468BaseClassV2
1089         {
1090                 public string Base;
1091         }
1092
1093         public class Bug8468MidClassV2: Bug8468BaseClassV2
1094         {
1095                 public string Mid;
1096         }
1097
1098         [XmlRoot("Test", Namespace="http://test-namespace")]
1099         public class Bug8468SubclassV2: Bug8468MidClassV2
1100         {
1101         }
1102
1103         [XmlRoot("Test")]
1104         public class Bug8468SubclassNoNamespaceV2: Bug8468MidClassV2
1105         {
1106         }
1107         
1108         [XmlRoot("Test")]
1109         public class Bug9193Class
1110         {
1111                 [XmlElement ("Data", Order=0)]
1112                 public string[] Data;
1113                 [XmlElement ("Extra", Order=1)]
1114                 public string[] Extra;
1115         }
1116
1117         public class SimpleObjectA
1118         {
1119                 [XmlAttribute]
1120                 public string Text
1121                 {
1122                         get; set;
1123                 }
1124
1125                 public static implicit operator SimpleObjectA (SimpleObjectB o)
1126                 {
1127                         return new SimpleObjectA { Text = o.Text };
1128                 }
1129
1130                 public static implicit operator SimpleObjectB (SimpleObjectA o)
1131                 {
1132                  return new SimpleObjectB { Text = o.Text };
1133                 }
1134         }
1135
1136         public class SimpleObjectB
1137         {
1138                 [XmlAttribute]
1139                 public string Text
1140                 {
1141                         get; set;
1142                 }
1143         }
1144
1145         public class ObjectWithElementRequiringImplicitCast
1146         {
1147                 public ObjectWithElementRequiringImplicitCast () { }
1148                 public ObjectWithElementRequiringImplicitCast (string text)
1149                 {
1150                         Object = new SimpleObjectB { Text = text };
1151                 }
1152
1153                 [XmlElement(Type = typeof (SimpleObjectA))]
1154                 public SimpleObjectB Object
1155                 {
1156                         get; set;
1157                 }
1158         }
1159
1160         public class ObjectWithNullableArrayItems
1161         {
1162                 [XmlArrayItem ("Element", IsNullable = true)]
1163                 public List<SimpleClass> Elements;
1164         }
1165
1166         public class ObjectWithNonNullableArrayItems
1167         {
1168                 [XmlArrayItem ("Element", IsNullable = false)]
1169                 public List<SimpleClass> Elements;
1170         }
1171
1172         public class ObjectWithNotSpecifiedNullableArrayItems
1173         {
1174                 [XmlArrayItem ("Element")]
1175                 public List<SimpleClass> Elements;
1176         }
1177
1178         [Serializable]
1179         public sealed class ClassWithDefaultTextNotNull
1180         {
1181                 [XmlText]
1182                 public string Value;
1183
1184                 public const string DefaultValue = "NotNull";
1185
1186                 public ClassWithDefaultTextNotNull (string v) {
1187                         Value = v;
1188                 }
1189
1190                 public ClassWithDefaultTextNotNull () {
1191                         Value = DefaultValue;
1192                 }
1193     }
1194 }
1195