Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ComplexDataStructure.cs « System.Xml.Serialization « Test « System.XML « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 589d7f60826183e014a460545fc40ded955367af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
//
// ComplexDataStructure.cs
//
// Author:
//	Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2004 Novell, Inc.
//
//
using System;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Collections;
using System.ComponentModel; 
using NUnit.Framework;
using System.Linq;

using MonoTests.Helpers;

namespace MonoTests.System.XmlSerialization
{
	[TestFixture]
	public class ComplexDataStructure
	{
		[Test]
		[NUnit.Framework.Category("NotDotNet")] // FDBK50639 
		public void WriteLiteral ()
		{
			Test data = BuildTestObject ();

			XmlSerializer ss = new XmlSerializer (GetLiteralTypeMapping ());
			XmlSerializerNamespaces nams = new XmlSerializerNamespaces ();
			StringWriter sw = new StringWriter();
			ss.Serialize (sw,data,nams);
			string serialized = sw.ToString ();
			serialized = XmlSerializerTests.Infoset (serialized);

			StreamReader sr = new StreamReader (TestResourceHelper.GetFullPathOfResource ("Test/XmlFiles/literal-data.xml"));
			string expected = sr.ReadToEnd ();
			sr.Close ();
			
			expected = XmlSerializerTests.Infoset (expected);
			Assert.AreEqual (expected, serialized);
		}
		
		[Test]
		[NUnit.Framework.Category ("NotDotNet")] // MS.NET results in compilation error (probably it generates bogus source.)
		[NUnit.Framework.Category ("MobileNotWorking")]
		public void ReadLiteral ()
		{
			XmlSerializer ss = new XmlSerializer (GetLiteralTypeMapping ());
			XmlSerializerNamespaces nams = new XmlSerializerNamespaces ();
			
			StreamReader sr = new StreamReader (TestResourceHelper.GetFullPathOfResource ("Test/XmlFiles/literal-data.xml"));
			Test data = (Test) ss.Deserialize (sr);
			sr.Close ();
			
			CheckObjectContent (BuildTestObject(), data);
		}
		
		XmlTypeMapping GetLiteralTypeMapping ()
		{
			XmlRootAttribute root = new XmlRootAttribute("rootroot");
			Type[] types = new Type[] {typeof(UknTestPart), typeof(AnotherTestPart), typeof(DblStringContainer) };
			XmlReflectionImporter ri = new XmlReflectionImporter ();
			foreach (Type t in types) ri.IncludeType (t);
			return ri.ImportTypeMapping (typeof(Test), root);
		}

		XmlTypeMapping GetEncodedTypeMapping ()
		{
			SoapReflectionImporter sri = new SoapReflectionImporter ();
			sri.IncludeType (typeof(UknTestPart));
			sri.IncludeType (typeof(AnotherTestPart));
			sri.IncludeType (typeof(DblStringContainer));
			return sri.ImportTypeMapping (typeof(Test));
		}
		
		Test BuildTestObject ()
		{
			XmlDocument doc = new XmlDocument();

			Test t = new UknTestPart();
			t.a = 1;
			t.b = "hola";
			t.bbis = t.b;
			t.c = 44;
			t.parts = new TestPart[3];
			t.parts[0] = new TestPart();
			t.parts[0].name = "un";
			t.parts[0].bval = true;
			t.parts[1] = new TestPart();
			t.parts[1].name = "dos";
			t.parts[1].bval = false;
			t.parts[2] = t.parts[0];
			t.part = t.parts[1];
			t.strings = new string[] { "un", "dos", null, "tres" };
			t.ushorts = new ushort[] { 1,2,3 };
			t.ta = new TB();
			t.ta.extraTextNodes = new XmlNode[] { doc.CreateTextNode ("AA"), doc.CreateTextNode ("BB") };

			t.tam2 = new TA[][][]
					{
						new TA[][] { new TA[] {new TA(), new TA()}, new TA[] {new TA(), new TA()}},
						new TA[][] { new TA[] {new TB(), new TA()}, new TA[] {new TB(), new TA()}},
						new TA[][] { new TA[] {new TA(), new TB()}, new TA[] {new TA(), new TA()}} 
					};

			t.tam3 = t.tam2;
			t.flatParts = t.parts;

			t.flatParts2 = new TA[] {new TA(), new TB(), null, new TB()};

			t.anot = new AnotherTestPart ();
			((AnotherTestPart)t.anot).lo = 1234567890;

			t.ob = t.parts[1];
			t.ob2 = t.parts[1];

			XmlElement e1 = doc.CreateElement ("explicitElement");
			XmlElement e2 = doc.CreateElement ("subElement");
			e2.SetAttribute ("unAtrib","val");
			doc.AppendChild (e1);
			e1.AppendChild (e2);

			t.oneElem = e1;
			t.oneElem2 = e1;
			t.someElems = new XmlNode[3];
			t.someElems[0] = e1;
			t.someElems[1] = null;
			t.someElems[2] = e2;

			t.extraElems = new XmlElement[1];
			t.extraElems[0] = doc.CreateElement ("extra1");
			t.extraElems[0].SetAttribute ("val","1");

			t.extraElems23 = new XmlElement[2];
			t.extraElems23[0] = doc.CreateElement ("extra2");
			t.extraElems23[0].SetAttribute ("val","2");
			t.extraElems23[1] = doc.CreateElement ("extra3");
			t.extraElems23[1].SetAttribute ("val","3");

			t.extraElemsRest = doc.CreateElement ("extra4");
			t.extraElemsRest.SetAttribute ("val","4");

			t.uktester = new UnknownAttributeTester();
			t.uktester.aa = "hihi";

			t.uktester.extraAtts = new XmlAttribute[3];
			t.uktester.extraAtts[0] = doc.CreateAttribute ("extraAtt1");
			t.uktester.extraAtts[0].Value = "val1";
			t.uktester.extraAtts[1] = doc.CreateAttribute ("extraAtt2");
			t.uktester.extraAtts[1].Value = "val2";
			t.uktester.extraAtts[2] = doc.CreateAttribute ("extraAtt3");
			t.uktester.extraAtts[2].Value = "val3";

			t.ob3 = 12345;
			t.ob4 = (float)54321.12;

			t.op1 = option.AA;
			t.opArray = new option[] { option.CC, option.BB, option.AA };
			t.ukOpt = option.DD;
			t.opAtt = option.BB;

			t.byteArray = new byte[] { 11,33,55,222 };
			t.byteByteArray = new byte[][] { t.byteArray, t.byteArray };

			t.ttList = new ArrayList();
			t.ttList.Add ("two");
			t.ttList.Add ("strings");
			//			t.extraText = "Additional text";

			t.RoList = new ArrayList ();
			t.RoList.Add (t.parts[0]);
			t.RoList.Add (t.parts[1]);

/*			t.struc = new OneStruct();
			t.struc.aa = 776655;
			t.struc.cc = "this is a struct";
*/
			t.multiList = new ArrayList[2];
			t.multiList[0] = new ArrayList ();
			t.multiList[0].Add (22);
			t.multiList[0].Add (33);
			t.multiList[1] = new ArrayList ();
			t.multiList[1].Add (888);
			t.multiList[1].Add (999);

			// XmlSerializer does not deserialize default values explicitly.
			//t.defElem = "theDefValue";
			//t.defAttr = "theDefValue";

			t.special = new CustomHashtable ();
			t.special.Add ("one","1");
			t.special.Add ("two","2");
			t.special.Add ("three","3");

			t.attqname = new XmlQualifiedName ("thename","thenamespace");

			DblStringContainer dbc = new DblStringContainer ();
			dbc.doublestring = new string [][] { null, new string[] {"hello"} };
			AnotherTestPart at = new AnotherTestPart ();
			at.lo = 567;
			dbc.at = at;

			DblStringContainerAnm dbca = new DblStringContainerAnm ();
			dbca.at = dbc;
			t.dbscontainer = dbca;
			
			return t;
		}
		
		void CheckObjectContent (Test exp, Test t)
		{
			Assert.AreEqual (exp.a, t.a, "t.a");
			Assert.AreEqual (exp.b, t.b, "t.b");
			Assert.AreEqual (exp.bbis, t.bbis, "t.bbis");
			Assert.AreEqual (exp.c, t.c, "t.c");
			
			Assert.IsNotNull (t.parts, "t.parts");
			CheckParts ("t.parts", exp.parts, t.parts);
			
			TestPart.AssertEquals ("t.part", exp.part, t.part);
			
			AssertionHelper.AssertEqualsArray ("t.strings", exp.strings, t.strings);
			AssertionHelper.AssertEqualsArray ("t.ushorts", exp.ushorts, t.ushorts);
			
			TA.AssertEquals ("t.ta", exp.ta, t.ta);

			Assert.IsNotNull (t.tam2, "t.tam2");
			CheckTaArray ("t.tam2", exp.tam2, t.tam2);
			
			Assert.IsNotNull (t.tam3, "t.tam3");
			CheckTaArray ("t.tam3", exp.tam3, t.tam3);
			
			Assert.IsNotNull (t.flatParts, "t.flatParts");
			CheckParts ("t.flatParts", exp.flatParts, t.flatParts);

			// Null element is ignored
			Assert.IsNotNull (t.flatParts2, "t.flatParts2");
			Assert.AreEqual (3, t.flatParts2.Length, "t.flatParts2.Length");
			TA.AssertEquals ("t.flatParts2 0", exp.flatParts2[0], t.flatParts2[0]);
			TA.AssertEquals ("t.flatParts2 1", exp.flatParts2[1], t.flatParts2[1]);
			TA.AssertEquals ("t.flatParts2 2", exp.flatParts2[3], t.flatParts2[2]);
			
			Assert.IsNotNull (t.anot, "t.anot");
			Assert.AreEqual (((AnotherTestPart)exp.anot).lo, ((AnotherTestPart)t.anot).lo, "t.anot.lo");

			TestPart.AssertEquals ("t.ob", exp.ob as TestPart, t.ob as TestPart);
			TestPart.AssertEquals ("t.ob2", exp.ob2 as TestPart, t.ob2 as TestPart);
			
			AssertionHelper.AssertEqualsXml ("t.oneElem", exp.oneElem, t.oneElem);
			AssertionHelper.AssertEqualsXml ("t.oneElem2", exp.oneElem2, t.oneElem2);
			
			// One of the elements was null and it is ignored
			Assert.IsNotNull (t.someElems, "t.someElems");
			Assert.AreEqual (2, t.someElems.Length, "t.someElems.Length");
			AssertionHelper.AssertEqualsXml ("t.someElems[0]", exp.someElems[0], t.someElems[0]);
			AssertionHelper.AssertEqualsXml ("t.someElems[1]", exp.someElems[2], t.someElems[1]);

			Assert.IsNotNull (t.extraElems, "t.extraElems");
			Assert.AreEqual (exp.extraElems.Length, t.extraElems.Length, "t.extraElems.Length");
			for (int n=0; n<exp.extraElems.Length; n++)
				AssertionHelper.AssertEqualsXml ("t.extraElems[" + n + "]", exp.extraElems[n], t.extraElems[n]);
			
			Assert.IsNotNull (t.extraElems23, "t.extraElems23");
			Assert.AreEqual (exp.extraElems23.Length, t.extraElems23.Length, "t.extraElems23.Length");
			for (int n=0; n<t.extraElems23.Length; n++)
				AssertionHelper.AssertEqualsXml ("t.extraElems23[" + n + "]", exp.extraElems23[n], t.extraElems23[n]);
			
			AssertionHelper.AssertEqualsXml ("t.extraElemsRest", exp.extraElemsRest, t.extraElemsRest);
			
			UnknownAttributeTester.AssertEquals ("t.uktester", exp.uktester, t.uktester);

			Assert.AreEqual (exp.ob3, t.ob3, "t.ob3");
			Assert.AreEqual (exp.ob4, t.ob4, "t.ob4");
			Assert.AreEqual (exp.op1, t.op1, "t.op1");
			
			AssertionHelper.AssertEqualsArray ("t.opArray", exp.opArray, t.opArray);

			Assert.AreEqual (exp.ukOpt, t.ukOpt, "t.ukOpt");
			Assert.AreEqual (exp.opAtt, t.opAtt, "t.opAtt");

			AssertionHelper.AssertEqualsArray ("t.byteArray", exp.byteArray, t.byteArray);
			AssertionHelper.AssertEqualsArray ("t.byteByteArray", exp.byteByteArray, t.byteByteArray);
			
			Assert.IsNotNull (t.ttList, "t.ttList");
			AssertionHelper.AssertEqualsArray ("t.ttList", exp.ttList.ToArray(), t.ttList.ToArray());
			
			Assert.IsNotNull (t.RoList, "t.RoList");
//			Assert.AreEqual (exp.RoList.Count, t.RoList.Count, "t.RoList.Count");
			for (int n=0; n<t.RoList.Count; n++)
				TestPart.AssertEquals ("t.RoList " + n, (TestPart)exp.RoList[n], (TestPart)t.RoList[n]);
			
			Assert.AreEqual (exp.struc.aa, t.struc.aa, "t.struc.aa");
			Assert.AreSame (exp.struc.cc, t.struc.cc, "t.struc.cc");

			Assert.IsNull (t.multiList, "t.multiList");
//			Assert.AreEqual (exp.multiList.Length, t.multiList.Length, "t.multiList.Count");
//			for (int n=0; n<exp.multiList.Length; n++)
//				AssertionHelper.AssertEqualsArray ("t.multiList " + n, exp.multiList[n].ToArray(), t.multiList[n].ToArray());
			
			Assert.AreEqual (exp.defElem, t.defElem, "t.defElem");
			Assert.AreEqual (exp.defAttr, t.defAttr, "t.defAttr");

			CustomHashtable.AssertEquals ("t.special", exp.special, t.special);

			Assert.AreEqual (exp.attqname, t.attqname, "t.attqname");

			Assert.IsNull (t.dbscontainer, "t.dbscontainer");
//			DblStringContainer tdbca = t.dbscontainer.at as DblStringContainer;
//			DblStringContainer expdbca = exp.dbscontainer.at as DblStringContainer;
//			Assert.IsNotNull (tdbca, "t.dbscontainer.at");
			
//			Assert.IsNotNull (tdbca, "t.dbscontainer.dbca");
//			AssertionHelper.AssertEqualsArray ("t.dbscontainer.at.doublestring", expdbca.doublestring, tdbca.doublestring);
			
//			AnotherTestPart tat = tdbca.at as AnotherTestPart;
//			AnotherTestPart expat = expdbca.at as AnotherTestPart;
//			Assert.IsNotNull (tat, "t.dbscontainer.dbca.at");
//			Assert.AreEqual (expat.lo, tat.lo, "t.dbscontainer.dbca.at.lo");
		}
		
		void CheckParts (string id, TestPart[] exp, TestPart[] parts)
		{
			AssertionHelper.AssertType (id, exp, parts);
			Assert.AreEqual (exp.Length, parts.Length, id + " Len");
			for (int n=0; n<exp.Length; n++)
				TestPart.AssertEquals (id + "[" + n + "]", exp[n], parts[n]);
		}
		
		void CheckTaArray (string id, TA[][][] exp, TA[][][] arr)
		{
			AssertionHelper.AssertType (id, exp, arr);
			Assert.AreEqual (exp.Length, arr.Length, id + " Len");
			for (int n=0; n<exp.Length; n++)
			{
				TA[][] tar = arr[n];
				TA[][] expar = exp[n];
				
				AssertionHelper.AssertType (id, expar, tar);
				Assert.AreEqual (expar.Length, tar.Length);
				
				for (int m=0; m<expar.Length; m++)
				{
					TA[] tar2 = tar[m];
					TA[] expar2 = expar[m];
					
					AssertionHelper.AssertType (id, expar2, tar2);
					Assert.AreEqual (expar2.Length, tar2.Length, id);
					
					for (int i=0; i<expar2.Length; i++)
						TA.AssertEquals (id + "[" + n + "][" + m + "][" + i + "]", expar2[i], tar2[i]);
				}
			}
		}
	}
	
	public class AssertionHelper
	{
		public static bool AssertType (string id, object exp, object ob)
		{
			if (exp == null) {
				Assert.IsNull (ob, id);
				return false;
			}
			else {
				Assert.IsNotNull (ob, id);
				Assert.AreEqual (exp.GetType(), ob.GetType(), id + " type");
				return true;
			}
		}
		
		public static void AssertEqualsXml (string id, XmlNode exp, XmlNode ob)
		{
			if (!AssertType (id, exp, ob)) return;
			Assert.AreEqual (XmlSerializerTests.Infoset (exp), XmlSerializerTests.Infoset (ob), id);
		}
		
		public static void AssertEqualsArray (string id, Array exp, Array ob)
		{
			if (!AssertType (id, exp, ob)) return;
			Assert.AreEqual (exp.GetLength(0), ob.GetLength(0), id + " Length");
			for (int n=0; n<exp.GetLength(0); n++) {
				object it = exp.GetValue(n);
				if (it is Array) 
					AssertEqualsArray (id + "[" + n + "]", it as Array, ob.GetValue(n) as Array);
				else
					Assert.AreEqual (it, ob.GetValue(n), id + "[" + n + "]");
			}
		}
	}
	
	[XmlType(TypeName="")]
	[XmlRoot(ElementName="aaaaaa",Namespace="")]
	[XmlInclude(typeof(UknTestPart))]
	[SoapInclude(typeof(UknTestPart))]
	public class Test
	{
		//		public option op;elem.SchemaTypeName
		public object anot;

		[SoapElement(ElementName="suba")]
		[XmlElement(ElementName="suba",Namespace="kk")]
		public int a;

		public string b;
		public string bbis;

		[SoapAttribute]
		[XmlAttribute (Namespace="attribns")]
		public byte c;

		[XmlElement(Namespace="oo")]
		public TestPart part;

		public TA ta;

		public TestPart[] parts;

		[SoapElement(ElementName="multita")]
		[XmlArray(ElementName="multita")]
			//		[XmlArrayItem(ElementName="itema",NestingLevel=1)]
		[XmlArrayItem(ElementName="itema",Type=typeof(TA),NestingLevel=1)]
		[XmlArrayItem(ElementName="itemb",Type=typeof(TB),NestingLevel=1)]
		public TA[][] tam = new TA[][] { new TA[] {new TA(), new TB()}, new TA[] {new TA(), new TA()}};

//		[SoapElement(ElementName="multita2")]
		[SoapIgnore]
		[XmlArray(ElementName="multita2")]
		[XmlArrayItem(ElementName="data1",NestingLevel=0)]

		[XmlArrayItem(ElementName="data2",NestingLevel=1,Namespace="da2")]
		[XmlArrayItem(ElementName="data3a",Type=typeof(TA),NestingLevel=2,Namespace="da3")]
		[XmlArrayItem(ElementName="data3b",Type=typeof(TB),NestingLevel=2,Namespace="da3")]
		public TA[][][] tam2;

		[SoapIgnore]
		public TA[][][] tam3;

		[SoapElement(IsNullable=true)]
		[XmlElement(IsNullable=true)]
		public string mayBeNull;

		public string[] strings;

		[XmlArray(Namespace="arrayNamespace")]
		public ushort[] ushorts;

		[XmlElement]
		public TestPart[] flatParts;

		[SoapElement (ElementName="flatTAs")]
		[XmlElement (ElementName="flatTAs")]
		public TA[] flatParts2;

		public object ob;

		[XmlElement (Namespace="uimp")]
		public object ob2;

		public object ob3;
		public object ob4;

		[SoapIgnore]
		public XmlElement oneElem;

		[SoapIgnore]
		[XmlElement (ElementName="unElement", Namespace="elemns")]
		public XmlElement oneElem2;

		[SoapIgnore]
		[XmlElement (ElementName="unsElements", Namespace="elemns")]
		public XmlNode[] someElems;

		[SoapIgnore]
		[XmlAnyElement ("extra1")]
		public XmlElement[] extraElems;

		[SoapIgnore]
		[XmlAnyElement ("extra2")]
		[XmlAnyElement ("extra3")]
		[XmlAnyElement ("extra3","nnn")]
		public XmlElement[] extraElems23;

		[SoapIgnore]
		[XmlAnyElement]
		public XmlElement extraElemsRest;

		public UnknownAttributeTester uktester;

		public option op1;
		public option[] opArray;
		public object ukOpt;

		[XmlAttribute]
		[SoapIgnore]
		public option opAtt;


		public byte[] byteArray;
		[SoapIgnore]
		public byte[][] byteByteArray;

		[XmlElement(Type=typeof(string))]
		[XmlElement(ElementName="kk",Type=typeof(int))]
		public object[] tt = new object[] { "aa",22 };

		public ArrayList ttList;

		ArrayList roList;
		public ArrayList RoList
		{
			get { return roList; }
			set { roList = value; }
		}

		[SoapIgnore]
		[XmlIgnore] // Causes NRE in System.Xml.Serialization.CodeGenerator.GetVariableType (System.Object var)
		public ArrayList[] multiList;

		[SoapIgnore]
		[XmlIgnore]
		public OneStruct struc;

		[DefaultValue("theDefValue")]
		public string defElem;

		[XmlAttribute]
		[DefaultValue("theDefValue")]
		public string defAttr;

		[XmlText (Type=typeof(string))]
		[XmlElement (Type=typeof(int))]
		public object[] xmltext = new object[] {"aa",33,"bb",776};

		[SoapIgnore]
		public CustomHashtable special;

		[XmlAttribute]
		public XmlQualifiedName attqname;

		[XmlAttribute]
		public DateTime[] arrayAttribute;

		[XmlArray (Namespace="mm")]
		public string[][] dummyStringArray = new string[][] {null,null};
		
		[XmlElement (Namespace="mm")]
		public DblStringContainerAnm dbscontainer;
	}

	public class DblStringContainerAnm
	{
		public object at;
	}

	[XmlType(Namespace="mm")]
	public class DblStringContainer
	{
		[XmlArrayItem (NestingLevel=1, IsNullable=true)]
		public string [][] doublestring;
		public object at;
	}

	[SoapType(TypeName="TC")]
	[XmlType(TypeName="TC")]
	[XmlInclude(typeof(TB))]
	[SoapInclude(typeof(TB))]
	public class TA
	{
		public int xx = 1;

		[XmlText]
		[SoapIgnore]
		public XmlNode[] extraTextNodes;
		
		public static void AssertEquals (string id, TA expected, TA ob)
		{
			if (!AssertionHelper.AssertType (id, expected, ob)) return;
			Assert.AreEqual (expected.xx, ob.xx, id + " xx");
			// TODO: extraTextNodes
		}
	}

	public class TB: TA
	{
		public int yy = 2;
		
		public static void AssertEquals (string id, TB expected, TB ob)
		{
			if (!AssertionHelper.AssertType (id, expected, ob)) return;
			Assert.AreEqual (expected.yy, ob.yy, id + " yy");
			TA.AssertEquals (id + " base", expected, ob);
		}
	}

	public class UnknownAttributeTester

	{
		[SoapAttribute]
		[XmlAttribute]
		public string aa;
	
		[SoapIgnore]
		[XmlAnyAttribute]
		public XmlAttribute[] extraAtts;

		//		[XmlText(Type=typeof(XmlNode))]
		//		public XmlNode extraText;
		
		public static void AssertEquals (string id, UnknownAttributeTester exp, UnknownAttributeTester ob)
		{
			if (!AssertionHelper.AssertType (id, exp, ob)) return;
			Assert.AreEqual (exp.aa, ob.aa, id + " aa");
			
			if (!AssertionHelper.AssertType (id + " extraAtts", exp.extraAtts, ob.extraAtts)) return;
			
			int p = 0;
			for (int n=0; n<ob.extraAtts.Length; n++)
			{
				XmlAttribute at = ob.extraAtts [n];
				if (at.NamespaceURI == "http://www.w3.org/2000/xmlns/") continue;
				Assert.IsTrue (p < exp.extraAtts.Length, id + " extraAtts length");
				AssertionHelper.AssertEqualsXml (id + ".extraAtts " + n, exp.extraAtts [p], ob.extraAtts[n]);
				p++;
			}
		}
	}

	[SoapType(TypeName="UnTestPart", Namespace="mm")]
	[XmlType(TypeName="UnTestPart", Namespace="mm")]
	public class TestPart
	{
		public string name;
		public bool bval;
		
		public static void AssertEquals (string id, TestPart expected, TestPart ob)
		{
			if (!AssertionHelper.AssertType (id, expected, ob)) return;
			Assert.AreEqual (expected.name, ob.name, id + " name");
			Assert.AreEqual (expected.bval, ob.bval, id + " bval");
		}
	}

	[SoapType(Namespace="mm")]
	[XmlType(Namespace="mm")]
	public class AnotherTestPart
	{
		[XmlText]
		public long lo;
	}

	public class UknTestPart : Test
	{
		[XmlElement(IsNullable=true)]
		public string uname;
		public bool uval;
	}

	public struct OneStruct
	{
		public int aa;
		public string cc;
	}

//	[XmlType(Namespace="enum_namespace")]
	public enum option 
	{ 
		AA, 
		[SoapEnum(Name="xmlBB")]
		[XmlEnum(Name="xmlBB")]
		BB, 
		CC, 
		DD 
	}

	public class CustomHashtable : IXmlSerializable
	{
		Hashtable data = new Hashtable ();

		public void Add (string key, string value)
		{
			data.Add (key, value);
		}
		
		public static void AssertEquals (string id, CustomHashtable exp, CustomHashtable ob)
		{
			if (!AssertionHelper.AssertType (id, exp, ob)) return;
			if (!AssertionHelper.AssertType (id, exp.data, ob.data)) return;
			
			Assert.AreEqual (exp.data.Count, ob.data.Count, id + " data Count");
			
			foreach (DictionaryEntry entry in exp.data)
				Assert.AreEqual (entry.Value, ob.data[entry.Key]);
		}
		
		public void ReadXml (XmlReader reader)
		{
			// Read the element enclosing the object
			reader.ReadStartElement();
			reader.MoveToContent ();

			// Reads the "data" element
			reader.ReadStartElement();
			reader.MoveToContent ();
			while (reader.NodeType != XmlNodeType.EndElement)
			{
				if (reader.NodeType == XmlNodeType.Element)
				{
					string key = reader.LocalName;
					data [key] = reader.ReadElementString ();
				}
				else
					reader.Skip ();
				reader.MoveToContent ();
			}

			reader.ReadEndElement ();
		}

		public void WriteXml (XmlWriter writer)
		{
			writer.WriteStartElement ("data");
			foreach (DictionaryEntry entry in data.Cast<DictionaryEntry> ().OrderBy (l => l.Key)) 
			{
				writer.WriteElementString ((string)entry.Key, (string)entry.Value);
			}
			writer.WriteEndElement ();
		}

		public XmlSchema GetSchema ()
		{
			XmlSchema s = new XmlSchema ();
			s.TargetNamespace = "http://www.go-mono.org/schemas";
			s.Id = "monoschema";
			XmlSchemaElement e = new XmlSchemaElement ();
			e.Name = "data";
			s.Items.Add (e);
			XmlSchemaComplexType cs = new XmlSchemaComplexType ();
			XmlSchemaSequence seq = new XmlSchemaSequence ();
			XmlSchemaAny any = new XmlSchemaAny ();
			any.MinOccurs = 0;
			any.MaxOccurs = decimal.MaxValue;
			seq.Items.Add (any);
			cs.Particle = seq;
			e.SchemaType = cs;
			return s;
		}
	}
}