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;
GenSimpleStructMonoTests.System.Xml.TestClasses.GenSimpleStruct77 		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;
GenComplexStructMonoTests.System.Xml.TestClasses.GenComplexStruct133 		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 	{
Add(String parameter)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
MyList(object container)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 
Container()332 		public Container ()
333 		{
334 			Items = new MyList (this);
335 		}
336 	}
337 
338 	public class Container2
339 	{
340 		public MyList Items;
341 
Container2()342 		public Container2 ()
343 		{
344 		}
345 
Container2(bool b)346 		public Container2 (bool b)
347 		{
348 			Items = new MyList (this);
349 		}
350 	}
351 
352 	public class MyElem : XmlElement
353 	{
MyElem(XmlDocument doc)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 	{
MyDocument()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 	{
ListDefaults()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 	{
Init()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 
EntityCollection()631 		public EntityCollection ()
632 		{
633 		}
634 
EntityCollection(string c)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 
Add(Entity value)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 SubclassTestList
715 	{
716 		[XmlElement ("a", typeof (SimpleClass))]
717 		[XmlElement ("b", typeof (SubclassTestBase))]
718 		public List<object> Items;
719 	}
720 
721 	public class DictionaryWithIndexer : DictionaryBase
722 	{
723 		public TimeSpan this[int index]
724 		{
725 			get { return TimeSpan.MinValue; }
726 		}
727 
Add(TimeSpan value)728 		public void Add (TimeSpan value)
729 		{
730 		}
731 	}
732 
733 	[XmlRoot (Namespace = "some:urn")]
734 	[SoapTypeAttribute (Namespace = "another:urn")]
735 	public class PrimitiveTypesContainer
736 	{
PrimitiveTypesContainer()737 		public PrimitiveTypesContainer ()
738 		{
739 			Number = 2004;
740 			Name = "some name";
741 			Index = (byte) 56;
742 			Password = new byte[] { 243, 15 };
743 			PathSeparatorCharacter = '/';
744 		}
745 
746 		public int Number;
747 		public string Name;
748 		public byte Index;
749 		public byte[] Password;
750 		public char PathSeparatorCharacter;
751 	}
752 
753 	public class TestSchemaForm1
754 	{
755 		public PrintTypeResponse p1;
756 
757 		[XmlElement (Namespace = "urn:oo")]
758 		public PrintTypeResponse p2;
759 	}
760 
761 	[XmlType (Namespace = "urn:testForm")]
762 	public class TestSchemaForm2
763 	{
764 		public PrintTypeResponse p1;
765 
766 		[XmlElement (Namespace = "urn:oo")]
767 		public PrintTypeResponse p2;
768 	}
769 
770 	[XmlType (Namespace = "urn:responseTypes")]
771 	public class PrintTypeResponse
772 	{
773 		[XmlElement (Form = XmlSchemaForm.Unqualified, IsNullable = true)]
774 		public OutputType result;
775 		public PrintTypeResponse intern;
776 
Init()777 		public void Init ()
778 		{
779 			result = new OutputType ();
780 			result.data = "data1";
781 			intern = new PrintTypeResponse ();
782 			intern.result = new OutputType ();
783 			intern.result.data = "data2";
784 		}
785 	}
786 
787 	[XmlType (Namespace = "urn:responseTypes")]
788 	public class OutputType
789 	{
790 
791 		[XmlElement (Form = XmlSchemaForm.Unqualified, IsNullable = true)]
792 		public string data;
793 	}
794 
795 	[XmlRootAttribute ("testDefault", Namespace = "urn:myNS", IsNullable = false)]
796 	[SoapType ("testDefault", Namespace = "urn:myNS")]
797 	public class TestDefault
798 	{
799 		public string str;
800 
801 		[DefaultValue ("Default Value")]
802 		public string strDefault = "Default Value";
803 
804 		[DefaultValue (true)]
805 		public bool boolT = true;
806 
807 		[DefaultValue (false)]
808 		public bool boolF = false;
809 
810 		[DefaultValue (typeof (decimal), "10")]
811 		public decimal decimalval = 10m;
812 
813 		[DefaultValue (FlagEnum.e1 | FlagEnum.e4)]
814 		public FlagEnum flag = (FlagEnum.e1 | FlagEnum.e4);
815 
816 		[DefaultValue (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e4)]
817 		public FlagEnum_Encoded flagencoded = (FlagEnum_Encoded.e1 | FlagEnum_Encoded.e4);
818 	}
819 
820 	[XmlType ("optionalValueType", Namespace = "some:urn")]
821 	[XmlRootAttribute ("optionalValue", Namespace = "another:urn", IsNullable = false)]
822 	public class OptionalValueTypeContainer
823 	{
824 		[DefaultValue (FlagEnum.e1 | FlagEnum.e4)]
825 		public FlagEnum Attributes = FlagEnum.e1 | FlagEnum.e4;
826 
827 		[DefaultValue (FlagEnum.e1)]
828 		public FlagEnum Flags = FlagEnum.e1;
829 
830 		[XmlIgnore]
831 		[SoapIgnore]
832 		public bool FlagsSpecified;
833 
834 		[DefaultValue (false)]
835 		public bool IsEmpty;
836 
837 		[XmlIgnore]
838 		[SoapIgnore]
839 		public bool IsEmptySpecified
840 		{
841 			get { return _isEmptySpecified; }
842 			set { _isEmptySpecified = value; }
843 		}
844 
845 		[DefaultValue (false)]
846 		public bool IsNull;
847 
848 		private bool _isEmptySpecified;
849 	}
850 
851 	public class Group
852 	{
853 		[SoapAttribute (Namespace = "http://www.cpandl.com")]
854 		public string GroupName;
855 
856 		[SoapAttribute (DataType = "base64Binary")]
857 		public Byte[] GroupNumber;
858 
859 		[SoapAttribute (DataType = "date", AttributeName = "CreationDate")]
860 		public DateTime Today;
861 
862 		[SoapElement (DataType = "nonNegativeInteger", ElementName = "PosInt")]
863 		public string PostitiveInt;
864 
865 		[SoapIgnore]
866 		public bool IgnoreThis;
867 
868 		[DefaultValue (GroupType.B)]
869 		public GroupType Grouptype;
870 		public Vehicle MyVehicle;
871 
872 		[SoapInclude (typeof (Car))]
myCar(string licNumber)873 		public Vehicle myCar (string licNumber)
874 		{
875 			Vehicle v;
876 			if (licNumber == string.Empty) {
877 				v = new Car ();
878 				v.licenseNumber = "!!!!!!";
879 			}
880 			else {
881 				v = new Car ();
882 				v.licenseNumber = licNumber;
883 			}
884 			return v;
885 		}
886 	}
887 
888 	[SoapInclude (typeof (Car))]
889 	public abstract class Vehicle
890 	{
891 		public string licenseNumber;
892 		[SoapElement (DataType = "date")]
893 		public DateTime makeDate;
894 		[DefaultValue ("450")]
895 		public string weight;
896 	}
897 
898 	public class Car : Vehicle
899 	{
900 	}
901 
902 	public enum GroupType
903 	{
904 		[SoapEnum ("Small")]
905 		A,
906 		[SoapEnum ("Large")]
907 		B
908 	}
909 
910 	public class ErrorneousGetSchema : IXmlSerializable
911 	{
GetSchema()912 		public XmlSchema GetSchema ()
913 		{
914 			throw new ApplicationException ("unexpected");
915 		}
916 
ReadXml(XmlReader reader)917 		public void ReadXml (XmlReader reader)
918 		{
919 		}
920 
WriteXml(XmlWriter writer)921 		public void WriteXml (XmlWriter writer)
922 		{
923 		}
924 
925 		// it should be serialized IF it is NOT IXmlSerializable.
926 		public string Whoa = "whoa";
927 	}
928 
929 	[XmlRoot ("DefaultDateTimeContainer", Namespace = "urn:foo")]
930 	public class DefaultDateTimeContainer // bug #378696
931 	{
932 		public DateTime SimpleDateTime;
933 
934 		[DefaultValue(typeof(DateTime), "2001-02-03T04:05:06")]
935 		public DateTime FancyDateTime;
936 
937 		[DefaultValue (typeof (int), "123456")]
938 		public int Numeric;
939 	}
940 
941 	public class XmlSerializableImplicitConvertible
942 	{
943 		public BaseClass B = new DerivedClass ();
944 
945 		public class XmlSerializable : IXmlSerializable
946 		{
WriteXml(XmlWriter writer)947 			public void WriteXml (XmlWriter writer)
948 			{
949 			}
950 
ReadXml(XmlReader reader)951 			public void ReadXml (XmlReader reader)
952 			{
953 			}
954 
GetSchema()955 			public XmlSchema GetSchema ()
956 			{
957 				return null;
958 			}
959 		}
960 
961 		public class BaseClass
962 		{
operator XmlSerializable(BaseClass b)963 			public static implicit operator XmlSerializable (BaseClass b)
964 			{
965 				return new XmlSerializable ();
966 
967 			}
968 
operator BaseClass(XmlSerializable x)969 			public static implicit operator BaseClass (XmlSerializable x)
970 			{
971 				return new BaseClass ();
972 			}
973 		}
974 
975 		public class DerivedClass : BaseClass
976 		{
977 		}
978 	}
979 
980 	public class Bug704813Type
981 	{
982 		IEnumerable<string> foo = new List<string> ();
983 		public IEnumerable<string> Foo {
984 			get { return foo; }
985 		}
986 	}
987 
988 	public class Bug708178Type
989 	{
990 		List<string> foo = new List<string> ();
991 
992 		[XmlArray("Foo"), XmlArrayItem("Foo", typeof(string))]
993 		public List<string> Foo {
994 			get { return foo; }
995 		}
996 	}
997 
998 	[XmlRoot("root")]
999 	public class ExplicitlyOrderedMembersType1
1000 	{
1001 		[XmlElement("child0", Order = 4)]
1002 		public string Child0;
1003 
1004 		[XmlElement("child", Order = 0)]
1005 		public string Child1;
1006 
1007 		[XmlElement("child", Order = 2)]
1008 		public string Child2;
1009 	}
1010 
1011 	[XmlRoot("root")]
1012 	public class ExplicitlyOrderedMembersType2
1013 	{
1014 		[XmlElement("child0", Order = 4)]
1015 		public string Child0;
1016 
1017 		[XmlElement("child")] // wrong. Needs to be Ordered as well.
1018 		public string Child1;
1019 
1020 		[XmlElement("child", Order = 2)]
1021 		public string Child2;
1022 	}
1023 
1024 	[XmlRoot("root")]
1025 	public class ExplicitlyOrderedMembersType3
1026 	{
1027 		[XmlElement("child0", Order = 1)] // it's between 0 and 2. After two "child" elements, child0 is not recognized as this member.
1028 		public string Child0;
1029 
1030 		[XmlElement("child", Order = 0)]
1031 		public string Child1;
1032 
1033 		[XmlElement("child", Order = 2)]
1034 		public string Child2;
1035 	}
1036 
1037 	[XmlRoot("root")]
1038 	public class ExplicitlyOrderedMembersType4
1039 	{
1040 		[XmlElement("child0", Order = 1)] // it's between 0 and 2. After two "child" elements, child0 is not recognized as this member.
1041 		public string Child0;
1042 
1043 		[XmlElement("child", Order = 0)]
1044 		public string Child1;
1045 
1046 		[XmlElement("child", Order = 2)]
1047 		public string Child2;
1048 
1049 		[XmlAttribute]
1050 		public string Child3;
1051 	}
1052 
1053 	[XmlRoot ("root")]
1054 	public class NullableDatesAndTimes {
1055 		[XmlElementAttribute ("MyTime", DataType = "time", IsNullable = false)]
1056 		public DateTime MyTime;
1057 
1058 		[XmlElementAttribute ("MyTimeNullable", DataType = "time", IsNullable = true)]
1059 		public DateTime? MyTimeNullable;
1060 
1061 		[XmlElementAttribute ("MyDate", DataType = "date", IsNullable = false)]
1062 		public DateTime MyDate;
1063 
1064 		[XmlElementAttribute ("MyDateNullable", DataType = "date", IsNullable = true)]
1065 		public DateTime? MyDateNullable;
1066 	}
1067 
1068 	public class NotExactDateParseClass
1069 	{
1070 		[XmlElementAttribute (DataType = "date")]
1071 		public DateTime SomeDate;
1072 	}
1073 
1074 	public class UtcTimeClass
1075 	{
1076 		[XmlElementAttribute (DataType = "time")]
1077 		public DateTime DateTimeValue;
1078 	}
1079 
1080 	public class Bug8468BaseClass
1081 	{
1082 		public string Base;
1083 	}
1084 
1085 	public class Bug8468MidClass: Bug8468BaseClass
1086 	{
1087 		public string Mid;
1088 	}
1089 
1090 	[XmlRoot("Test", Namespace="http://test-namespace")]
1091 	public class Bug8468Subclass: Bug8468MidClass
1092 	{
1093 	}
1094 
1095 	[XmlRoot("Test")]
1096 	public class Bug8468SubclassNoNamespace: Bug8468MidClass
1097 	{
1098 	}
1099 
1100 	[XmlRoot("Test", Namespace="")]
1101 	public class Bug8468BaseClassV2
1102 	{
1103 		public string Base;
1104 	}
1105 
1106 	public class Bug8468MidClassV2: Bug8468BaseClassV2
1107 	{
1108 		public string Mid;
1109 	}
1110 
1111 	[XmlRoot("Test", Namespace="http://test-namespace")]
1112 	public class Bug8468SubclassV2: Bug8468MidClassV2
1113 	{
1114 	}
1115 
1116 	[XmlRoot("Test")]
1117 	public class Bug8468SubclassNoNamespaceV2: Bug8468MidClassV2
1118 	{
1119 	}
1120 
1121 	[XmlRoot("Test")]
1122 	public class Bug9193Class
1123 	{
1124 		[XmlElement ("Data", Order=0)]
1125 		public string[] Data;
1126 		[XmlElement ("Extra", Order=1)]
1127 		public string[] Extra;
1128 	}
1129 
1130 	public class SimpleObjectA
1131 	{
1132 		[XmlAttribute]
1133 		public string Text
1134 		{
1135 			get; set;
1136 		}
1137 
operator SimpleObjectA(SimpleObjectB o)1138 		public static implicit operator SimpleObjectA (SimpleObjectB o)
1139 		{
1140 			return new SimpleObjectA { Text = o.Text };
1141 		}
1142 
operator SimpleObjectB(SimpleObjectA o)1143 		public static implicit operator SimpleObjectB (SimpleObjectA o)
1144 		{
1145 		 return new SimpleObjectB { Text = o.Text };
1146 		}
1147 	}
1148 
1149 	public class SimpleObjectB
1150 	{
1151 		[XmlAttribute]
1152 		public string Text
1153 		{
1154 			get; set;
1155 		}
1156 	}
1157 
1158 	public class ObjectWithElementRequiringImplicitCast
1159 	{
ObjectWithElementRequiringImplicitCast()1160 		public ObjectWithElementRequiringImplicitCast () { }
ObjectWithElementRequiringImplicitCast(string text)1161 		public ObjectWithElementRequiringImplicitCast (string text)
1162 		{
1163 			Object = new SimpleObjectB { Text = text };
1164 		}
1165 
1166 		[XmlElement(Type = typeof (SimpleObjectA))]
1167 		public SimpleObjectB Object
1168 		{
1169 			get; set;
1170 		}
1171 	}
1172 
1173 	public class ObjectWithNullableArrayItems
1174 	{
1175 		[XmlArrayItem ("Element", IsNullable = true)]
1176 		public List<SimpleClass> Elements;
1177 	}
1178 
1179 	public class ObjectWithNonNullableArrayItems
1180 	{
1181 		[XmlArrayItem ("Element", IsNullable = false)]
1182 		public List<SimpleClass> Elements;
1183 	}
1184 
1185 	public class ObjectWithNotSpecifiedNullableArrayItems
1186 	{
1187 		[XmlArrayItem ("Element")]
1188 		public List<SimpleClass> Elements;
1189 	}
1190 
1191 	[Serializable]
1192 	public sealed class ClassWithDefaultTextNotNull
1193 	{
1194 		[XmlText]
1195 		public string Value;
1196 
1197 		public const string DefaultValue = "NotNull";
1198 
ClassWithDefaultTextNotNull(string v)1199 		public ClassWithDefaultTextNotNull (string v) {
1200 			Value = v;
1201 		}
1202 
ClassWithDefaultTextNotNull()1203 		public ClassWithDefaultTextNotNull () {
1204 			Value = DefaultValue;
1205 		}
1206     }
1207 }
1208 
1209