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