importing messaging-2008 branch to trunk, going on.
[mono.git] / mcs / class / System.XML / Test / System.Xml.Serialization / XmlReflectionImporterTests.cs
1 //
2 // System.Xml.Serialization.XmlReflectionImporterTests
3 //
4 // Author:
5 //   Erik LeBel (eriklebel@yahoo.ca)
6 //
7 // (C) 2003 Erik LeBel
8 // 
9 // FIXME test some of these with Xml Attributes attached to some members: 
10 // do the names get carried over to Element for XmlAttributeAttribute and XmlElementAttribute?
11 // 
12
13 using System;
14 using System.Collections;
15 using System.Xml;
16 using System.Xml.Schema;
17 using System.Xml.Serialization;
18
19 using NUnit.Framework;
20 #if NET_2_0
21 using System.Collections.Generic;
22 #endif
23
24 using MonoTests.System.Xml.TestClasses;
25
26 namespace MonoTests.System.XmlSerialization
27 {
28         // debugging class
29         internal class Debug
30         {
31                 public static void Print(XmlTypeMapping tm)
32                 {
33                         Console.WriteLine("/XmlTypeMapping:");
34                         Console.WriteLine("ElementName: {0} ", tm.ElementName);
35                         Console.WriteLine("Namespace: {0} ", tm.Namespace);
36                         Console.WriteLine("TypeName: {0} ", tm.TypeName);
37                         Console.WriteLine("FullTypeName: {0} ", tm.TypeFullName);
38                 }
39
40                 public static void Print(XmlMemberMapping mm)
41                 {
42                         Console.WriteLine("/XmlMemberMapping:");
43                         Console.WriteLine("Any: {0} ", mm.Any);
44                         Console.WriteLine("ElementName: {0} ", mm.ElementName);
45                         Console.WriteLine("MemberName: {0} ", mm.MemberName);
46                         Console.WriteLine("Namespace: {0} ", mm.Namespace);
47                         Console.WriteLine("TypeFullName: {0} ", mm.TypeFullName);
48                         Console.WriteLine("TypeName: {0} ", mm.TypeName);
49                         Console.WriteLine("TypeNamespace: {0} ", mm.TypeNamespace);
50                 }
51         }
52
53         [TestFixture]
54         public class XmlReflectionImporterTests
55         {
56                 private const string SomeNamespace = "some:urn";
57                 private const string AnotherNamespace = "another:urn";
58                 private const string XmlSchemaNamespace = "http://www.w3.org/2001/XMLSchema";
59
60                 // these Map methods re-create the XmlReflectionImporter at every call.
61
62                 private XmlTypeMapping Map(Type t)
63                 {
64                         XmlReflectionImporter ri = new XmlReflectionImporter();
65                         XmlTypeMapping tm = ri.ImportTypeMapping(t);
66                         //Debug.Print(tm);
67
68                         return tm;
69                 }
70
71                 private XmlTypeMapping Map(Type t, XmlRootAttribute root)
72                 {
73                         XmlReflectionImporter ri = new XmlReflectionImporter();
74                         XmlTypeMapping tm = ri.ImportTypeMapping(t, root);
75
76                         return tm;
77                 }
78
79                 private XmlTypeMapping Map(Type t, string ns)
80                 {
81                         XmlReflectionImporter ri = new XmlReflectionImporter(ns);
82                         XmlTypeMapping tm = ri.ImportTypeMapping(t);
83                         //Debug.Print(tm);
84
85                         return tm;
86                 }
87
88                 private XmlTypeMapping Map (Type t, string ns, XmlRootAttribute root)
89                 {
90                         XmlReflectionImporter ri = new XmlReflectionImporter (ns);
91                         XmlTypeMapping tm = ri.ImportTypeMapping (t, root);
92
93                         return tm;
94                 }
95
96                 private XmlTypeMapping Map(Type t, XmlAttributeOverrides overrides)
97                 {
98                         XmlReflectionImporter ri = new XmlReflectionImporter(overrides);
99                         XmlTypeMapping tm = ri.ImportTypeMapping(t);
100                         //Debug.Print(tm);
101
102                         return tm;
103                 }
104
105                 private XmlMembersMapping MembersMap(Type t, XmlAttributeOverrides overrides, 
106                         XmlReflectionMember [] members, bool inContainer)
107                 {
108                         XmlReflectionImporter ri = new XmlReflectionImporter(overrides);
109                         XmlMembersMapping mm = ri.ImportMembersMapping(null, null, members, inContainer);
110                         
111                         return mm;
112                 }
113                 
114                 [Test]
115                 public void TestIntTypeMapping()
116                 {
117                         XmlTypeMapping tm = Map(typeof(int));
118                         Assert.AreEqual ("int", tm.ElementName, "#1");
119                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
120                         Assert.AreEqual ("Int32", tm.TypeName, "#3");
121                         Assert.AreEqual ("System.Int32", tm.TypeFullName, "#4");
122                 }
123
124                 [Test]
125 #if NET_2_0
126                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
127 #endif
128                 public void TestIntTypeMapping_Array ()
129                 {
130                         XmlTypeMapping tm = Map(typeof(int[]));
131                         Assert.AreEqual ("ArrayOfInt", tm.ElementName, "#A1");
132                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
133 #if NET_2_0
134                         Assert.AreEqual ("ArrayOfInt32", tm.TypeName, "#A3");
135 #else
136                         Assert.AreEqual ("Int32[]", tm.TypeName, "#A3");
137 #endif
138                         Assert.AreEqual ("System.Int32[]", tm.TypeFullName, "#A4");
139
140                         tm = Map (typeof (int[][]));
141                         Assert.AreEqual ("ArrayOfArrayOfInt", tm.ElementName, "#B1");
142                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
143 #if NET_2_0
144                         Assert.AreEqual ("ArrayOfArrayOfInt32", tm.TypeName, "#B3");
145 #else
146                         Assert.AreEqual ("Int32[][]", tm.TypeName, "#B3");
147 #endif
148                         Assert.AreEqual ("System.Int32[][]", tm.TypeFullName, "#B4");
149
150                         tm = Map (typeof (int[][][]));
151                         Assert.AreEqual ("ArrayOfArrayOfArrayOfInt", tm.ElementName, "#C1");
152                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
153 #if NET_2_0
154                         Assert.AreEqual ("ArrayOfArrayOfArrayOfInt32", tm.TypeName, "#C3");
155 #else
156                         Assert.AreEqual ("Int32[][][]", tm.TypeName, "#C3");
157 #endif
158                         Assert.AreEqual ("System.Int32[][][]", tm.TypeFullName, "#C4");
159                 }
160
161                 [Test]
162                 public void TestStringTypeMapping()
163                 {
164                         XmlTypeMapping tm = Map(typeof(string));
165                         Assert.AreEqual ("string", tm.ElementName, "#1");
166                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
167                         Assert.AreEqual ("String", tm.TypeName, "#3");
168                         Assert.AreEqual ("System.String", tm.TypeFullName, "#4");
169                 }
170
171                 [Test]
172 #if NET_2_0
173                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
174 #endif
175                 public void TestStringTypeMapping_Array ()
176                 {
177                         XmlTypeMapping tm = Map (typeof (string[]));
178                         Assert.AreEqual ("ArrayOfString", tm.ElementName, "#A1");
179                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
180 #if NET_2_0
181                         Assert.AreEqual ("ArrayOfString", tm.TypeName, "#A3");
182 #else
183                         Assert.AreEqual ("String[]", tm.TypeName, "#A3");
184 #endif
185                         Assert.AreEqual ("System.String[]", tm.TypeFullName, "#A4");
186
187                         tm = Map (typeof (string[][]));
188                         Assert.AreEqual ("ArrayOfArrayOfString", tm.ElementName, "#B1");
189                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
190 #if NET_2_0
191                         Assert.AreEqual ("ArrayOfArrayOfString", tm.TypeName, "#B3");
192 #else
193                         Assert.AreEqual ("String[][]", tm.TypeName, "#B3");
194 #endif
195                         Assert.AreEqual ("System.String[][]", tm.TypeFullName, "#B4");
196
197                         tm = Map (typeof (string[][][]));
198                         Assert.AreEqual ("ArrayOfArrayOfArrayOfString", tm.ElementName, "#C1");
199                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
200 #if NET_2_0
201                         Assert.AreEqual ("ArrayOfArrayOfArrayOfString", tm.TypeName, "#C3");
202 #else
203                         Assert.AreEqual ("String[][][]", tm.TypeName, "#C3");
204 #endif
205                         Assert.AreEqual ("System.String[][][]", tm.TypeFullName, "#C4");
206                 }
207
208                 [Test]
209                 public void TestObjectTypeMapping()
210                 {
211                         XmlTypeMapping tm = Map(typeof(object));
212                         Assert.AreEqual ("anyType", tm.ElementName, "#1");
213                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
214                         Assert.AreEqual ("Object", tm.TypeName, "#3");
215                         Assert.AreEqual ("System.Object", tm.TypeFullName, "#4");
216                 }
217
218                 [Test]
219 #if NET_2_0
220                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
221 #endif
222                 public void TestObjectTypeMapping_Array ()
223                 {
224                         XmlTypeMapping tm = Map (typeof (object[]));
225                         Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#A1");
226                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
227 #if NET_2_0
228                         Assert.AreEqual ("ArrayOfObject", tm.TypeName, "#A3");
229 #else
230                         Assert.AreEqual ("Object[]", tm.TypeName, "#A3");
231 #endif
232                         Assert.AreEqual ("System.Object[]", tm.TypeFullName, "#A4");
233
234                         tm = Map (typeof (object[][]));
235                         Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#B1");
236                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
237 #if NET_2_0
238                         Assert.AreEqual ("ArrayOfArrayOfObject", tm.TypeName, "#B3");
239 #else
240                         Assert.AreEqual ("Object[][]", tm.TypeName, "#B3");
241 #endif
242                         Assert.AreEqual ("System.Object[][]", tm.TypeFullName, "#B4");
243
244                         tm = Map (typeof (object[][][]));
245                         Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
246                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
247 #if NET_2_0
248                         Assert.AreEqual ("ArrayOfArrayOfArrayOfObject", tm.TypeName, "#C3");
249 #else
250                         Assert.AreEqual ("Object[][][]", tm.TypeName, "#C3");
251 #endif
252                         Assert.AreEqual ("System.Object[][][]", tm.TypeFullName, "#C4");
253                 }
254
255                 [Test]
256                 public void TestByteTypeMapping()
257                 {
258                         XmlTypeMapping tm = Map(typeof(byte));
259                         Assert.AreEqual ("unsignedByte", tm.ElementName, "#1");
260                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
261                         Assert.AreEqual ("Byte", tm.TypeName, "#3");
262                         Assert.AreEqual ("System.Byte", tm.TypeFullName, "#4");
263                 }
264
265                 [Test]
266 #if NET_2_0
267                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
268 #endif
269                 public void TestByteTypeMapping_Array ()
270                 {
271                         XmlTypeMapping tm = Map(typeof(byte[]));
272                         Assert.AreEqual ("base64Binary", tm.ElementName, "#A1");
273                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
274                         Assert.AreEqual ("Byte[]", tm.TypeName, "#A3");
275                         Assert.AreEqual ("System.Byte[]", tm.TypeFullName, "#A4");
276
277                         tm = Map (typeof (byte[][]));
278                         Assert.AreEqual ("ArrayOfBase64Binary", tm.ElementName, "#B1");
279                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
280 #if NET_2_0
281                         Assert.AreEqual ("ArrayOfArrayOfByte", tm.TypeName, "#B3");
282 #else
283                         Assert.AreEqual ("Byte[][]", tm.TypeName, "#B3");
284 #endif
285                         Assert.AreEqual ("System.Byte[][]", tm.TypeFullName, "#B4");
286
287                         tm = Map (typeof (byte[][][]));
288                         Assert.AreEqual ("ArrayOfArrayOfBase64Binary", tm.ElementName, "#C1");
289                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
290 #if NET_2_0
291                         Assert.AreEqual ("ArrayOfArrayOfArrayOfByte", tm.TypeName, "#C3");
292 #else
293                         Assert.AreEqual ("Byte[][][]", tm.TypeName, "#C3");
294 #endif
295                         Assert.AreEqual ("System.Byte[][][]", tm.TypeFullName, "#C4");
296                 }
297
298                 [Test]
299                 public void TestBoolTypeMapping()
300                 {
301                         XmlTypeMapping tm = Map(typeof(bool));
302                         Assert.AreEqual ("boolean", tm.ElementName, "#1");
303                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
304                         Assert.AreEqual ("Boolean", tm.TypeName, "#3");
305                         Assert.AreEqual ("System.Boolean", tm.TypeFullName, "#4");
306                 }
307
308                 [Test]
309                 public void TestShortTypeMapping()
310                 {
311                         XmlTypeMapping tm = Map(typeof(short));
312                         Assert.AreEqual ("short", tm.ElementName, "#1");
313                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
314                         Assert.AreEqual ("Int16", tm.TypeName, "#3");
315                         Assert.AreEqual ("System.Int16", tm.TypeFullName, "#4");
316                 }
317
318                 [Test]
319                 public void TestUnsignedShortTypeMapping()
320                 {
321                         XmlTypeMapping tm = Map(typeof(ushort));
322                         Assert.AreEqual ("unsignedShort", tm.ElementName, "#1");
323                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
324                         Assert.AreEqual ("UInt16", tm.TypeName, "#3");
325                         Assert.AreEqual ("System.UInt16", tm.TypeFullName, "#4");
326                 }
327                 
328                 [Test]
329                 public void TestUIntTypeMapping()
330                 {
331                         XmlTypeMapping tm = Map(typeof(uint));
332                         Assert.AreEqual ("unsignedInt", tm.ElementName, "#1");
333                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
334                         Assert.AreEqual ("UInt32", tm.TypeName, "#3");
335                         Assert.AreEqual ("System.UInt32", tm.TypeFullName, "#4");
336                 }
337                 
338                 [Test]
339                 public void TestLongTypeMapping()
340                 {
341                         XmlTypeMapping tm = Map(typeof(long));
342                         Assert.AreEqual ("long", tm.ElementName, "#1");
343                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
344                         Assert.AreEqual ("Int64", tm.TypeName, "#3");
345                         Assert.AreEqual ("System.Int64", tm.TypeFullName, "#4");
346                 }
347                 
348                 [Test]
349                 public void TestULongTypeMapping()
350                 {
351                         XmlTypeMapping tm = Map(typeof(ulong));
352                         Assert.AreEqual ("unsignedLong", tm.ElementName, "#1");
353                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
354                         Assert.AreEqual ("UInt64", tm.TypeName, "#3");
355                         Assert.AreEqual ("System.UInt64", tm.TypeFullName, "#4");
356                 }
357                 
358                 [Test]
359                 public void TestFloatTypeMapping()
360                 {
361                         XmlTypeMapping tm = Map(typeof(float));
362                         Assert.AreEqual ("float", tm.ElementName, "#1");
363                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
364                         Assert.AreEqual ("Single", tm.TypeName, "#3");
365                         Assert.AreEqual ("System.Single", tm.TypeFullName, "#4");
366                 }
367                 
368                 [Test]
369                 public void TestDoubleTypeMapping()
370                 {
371                         XmlTypeMapping tm = Map(typeof(double));
372                         Assert.AreEqual ("double", tm.ElementName, "#1");
373                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
374                         Assert.AreEqual ("Double", tm.TypeName, "#3");
375                         Assert.AreEqual ("System.Double", tm.TypeFullName, "#4");
376                 }
377                 
378                 [Test]
379                 public void TestDateTimeTypeMapping()
380                 {
381                         XmlTypeMapping tm = Map(typeof(DateTime));
382                         Assert.AreEqual ("dateTime", tm.ElementName, "#1");
383                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
384                         Assert.AreEqual ("DateTime", tm.TypeName, "#3");
385                         Assert.AreEqual ("System.DateTime", tm.TypeFullName, "#4");
386                 }
387
388                 [Test]
389 #if NET_2_0
390                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
391 #endif
392                 public void TestDateTimeTypeMapping_Array ()
393                 {
394                         XmlTypeMapping tm = Map (typeof (DateTime[]));
395                         Assert.AreEqual ("ArrayOfDateTime", tm.ElementName, "#A1");
396                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
397 #if NET_2_0
398                         Assert.AreEqual ("ArrayOfDateTime", tm.TypeName, "#A3");
399 #else
400                         Assert.AreEqual ("DateTime[]", tm.TypeName, "#A3");
401 #endif
402                         Assert.AreEqual ("System.DateTime[]", tm.TypeFullName, "#A4");
403
404                         tm = Map (typeof (DateTime[][]));
405                         Assert.AreEqual ("ArrayOfArrayOfDateTime", tm.ElementName, "#B1");
406                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
407 #if NET_2_0
408                         Assert.AreEqual ("ArrayOfArrayOfDateTime", tm.TypeName, "#B3");
409 #else
410                         Assert.AreEqual ("DateTime[][]", tm.TypeName, "#B3");
411 #endif
412                         Assert.AreEqual ("System.DateTime[][]", tm.TypeFullName, "#B4");
413
414                         tm = Map (typeof (DateTime[][][]));
415                         Assert.AreEqual ("ArrayOfArrayOfArrayOfDateTime", tm.ElementName, "#C1");
416                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
417 #if NET_2_0
418                         Assert.AreEqual ("ArrayOfArrayOfArrayOfDateTime", tm.TypeName, "#C3");
419 #else
420                         Assert.AreEqual ("DateTime[][][]", tm.TypeName, "#C3");
421 #endif
422                         Assert.AreEqual ("System.DateTime[][][]", tm.TypeFullName, "#C4");
423                 }
424
425                 [Test]
426                 public void TestGuidTypeMapping()
427                 {
428                         XmlTypeMapping tm = Map(typeof(Guid));
429                         Assert.AreEqual ("guid", tm.ElementName, "#1");
430                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
431                         Assert.AreEqual ("Guid", tm.TypeName, "#3");
432                         Assert.AreEqual ("System.Guid", tm.TypeFullName, "#4");
433                 }
434
435                 [Test]
436 #if NET_2_0
437                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
438 #endif
439                 public void TestGuidTypeMapping_Array ()
440                 {
441                         XmlTypeMapping tm = Map (typeof (Guid[]));
442                         Assert.AreEqual ("ArrayOfGuid", tm.ElementName, "#A1");
443                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
444 #if NET_2_0
445                         Assert.AreEqual ("ArrayOfGuid", tm.TypeName, "#A3");
446 #else
447                         Assert.AreEqual ("Guid[]", tm.TypeName, "#A3");
448 #endif
449                         Assert.AreEqual ("System.Guid[]", tm.TypeFullName, "#A4");
450
451                         tm = Map (typeof (Guid[][]));
452                         Assert.AreEqual ("ArrayOfArrayOfGuid", tm.ElementName, "#B1");
453                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
454 #if NET_2_0
455                         Assert.AreEqual ("ArrayOfArrayOfGuid", tm.TypeName, "#B3");
456 #else
457                         Assert.AreEqual ("Guid[][]", tm.TypeName, "#B3");
458 #endif
459                         Assert.AreEqual ("System.Guid[][]", tm.TypeFullName, "#B4");
460
461                         tm = Map (typeof (Guid[][][]));
462                         Assert.AreEqual ("ArrayOfArrayOfArrayOfGuid", tm.ElementName, "#C1");
463                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
464 #if NET_2_0
465                         Assert.AreEqual ("ArrayOfArrayOfArrayOfGuid", tm.TypeName, "#C3");
466 #else
467                         Assert.AreEqual ("Guid[][][]", tm.TypeName, "#C3");
468 #endif
469                         Assert.AreEqual ("System.Guid[][][]", tm.TypeFullName, "#C4");
470                 }
471
472                 [Test]
473                 public void TestDecimalTypeMapping()
474                 {
475                         XmlTypeMapping tm = Map(typeof(decimal));
476                         Assert.AreEqual ("decimal", tm.ElementName, "#1");
477                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
478                         Assert.AreEqual ("Decimal", tm.TypeName, "#3");
479                         Assert.AreEqual ("System.Decimal", tm.TypeFullName, "#4");
480                 }
481                 
482                 [Test]
483                 public void TestXmlQualifiedNameTypeMapping()
484                 {
485                         XmlTypeMapping tm = Map(typeof(XmlQualifiedName));
486                         Assert.AreEqual ("QName", tm.ElementName, "#1");
487                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
488                         Assert.AreEqual ("XmlQualifiedName", tm.TypeName, "#3");
489                         Assert.AreEqual ("System.Xml.XmlQualifiedName", tm.TypeFullName, "#4");
490                 }
491                 
492                 [Test]
493                 public void TestSByteTypeMapping()
494                 {
495                         XmlTypeMapping tm = Map(typeof(sbyte));
496                         Assert.AreEqual ("byte", tm.ElementName, "#1");
497                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
498                         Assert.AreEqual ("SByte", tm.TypeName, "#3");
499                         Assert.AreEqual ("System.SByte", tm.TypeFullName, "#4");
500                 }
501                 
502
503                 [Test]
504                 public void TestCharTypeMapping()
505                 {
506                         XmlTypeMapping tm = Map(typeof(char));
507                         Assert.AreEqual ("char", tm.ElementName, "#1");
508                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
509                         Assert.AreEqual ("Char", tm.TypeName, "#3");
510                         Assert.AreEqual ("System.Char", tm.TypeFullName, "#4");
511                 }
512
513                 [Test]
514 #if NET_2_0
515                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
516 #endif
517                 public void TestCharTypeMapping_Array ()
518                 {
519                         XmlTypeMapping tm = Map (typeof (char[]));
520                         Assert.AreEqual ("ArrayOfChar", tm.ElementName, "#A1");
521                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
522 #if NET_2_0
523                         Assert.AreEqual ("ArrayOfChar", tm.TypeName, "#A3");
524 #else
525                         Assert.AreEqual ("Char[]", tm.TypeName, "#A3");
526 #endif
527                         Assert.AreEqual ("System.Char[]", tm.TypeFullName, "#A4");
528
529                         tm = Map (typeof (char[][]));
530                         Assert.AreEqual ("ArrayOfArrayOfChar", tm.ElementName, "#B1");
531                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
532 #if NET_2_0
533                         Assert.AreEqual ("ArrayOfArrayOfChar", tm.TypeName, "#B3");
534 #else
535                         Assert.AreEqual ("Char[][]", tm.TypeName, "#B3");
536 #endif
537                         Assert.AreEqual ("System.Char[][]", tm.TypeFullName, "#B4");
538
539                         tm = Map (typeof (char[][][]));
540                         Assert.AreEqual ("ArrayOfArrayOfArrayOfChar", tm.ElementName, "#C1");
541                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
542 #if NET_2_0
543                         Assert.AreEqual ("ArrayOfArrayOfArrayOfChar", tm.TypeName, "#C3");
544 #else
545                         Assert.AreEqual ("Char[][][]", tm.TypeName, "#C3");
546 #endif
547                         Assert.AreEqual ("System.Char[][][]", tm.TypeFullName, "#C4");
548                 }
549
550                 [Test]
551                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
552                 public void TestXmlNodeTypeMapping ()
553                 {
554                         Type type = typeof (XmlNode);
555
556                         XmlTypeMapping tm = Map (type);
557                         Assert.AreEqual (string.Empty, tm.ElementName, "#A1");
558                         Assert.IsNull (tm.Namespace, "#A2");
559                         Assert.AreEqual ("XmlNode", tm.TypeName, "#A3");
560                         Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#A4");
561
562                         tm = Map (type, AnotherNamespace);
563                         Assert.AreEqual (string.Empty, tm.ElementName, "#B1");
564                         Assert.IsNull (tm.Namespace, "#B2");
565                         Assert.AreEqual ("XmlNode", tm.TypeName, "#B3");
566                         Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#B4");
567
568                         XmlRootAttribute root = new XmlRootAttribute ("somename");
569                         root.Namespace = SomeNamespace;
570                         tm = Map (type, root);
571                         Assert.AreEqual ("somename", tm.ElementName, "#C1");
572                         Assert.IsNull (tm.Namespace, "#C2");
573                         Assert.AreEqual ("XmlNode", tm.TypeName, "#C3");
574                         Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#C4");
575
576                         tm = Map (type, AnotherNamespace, root);
577                         Assert.AreEqual ("somename", tm.ElementName, "#D1");
578                         Assert.IsNull (tm.Namespace, "#D2");
579                         Assert.AreEqual ("XmlNode", tm.TypeName, "#D3");
580                         Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#D4");
581
582                         root.Namespace = null;
583                         tm = Map (type, root);
584                         Assert.AreEqual ("somename", tm.ElementName, "#E1");
585                         Assert.IsNull (tm.Namespace, "#E2");
586                         Assert.AreEqual ("XmlNode", tm.TypeName, "#E3");
587                         Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#E4");
588
589                         tm = Map (type, AnotherNamespace, root);
590                         Assert.AreEqual ("somename", tm.ElementName, "#F1");
591                         Assert.IsNull (tm.Namespace, "#F2");
592                         Assert.AreEqual ("XmlNode", tm.TypeName, "#F3");
593                         Assert.AreEqual ("System.Xml.XmlNode", tm.TypeFullName, "#F4");
594                 }
595
596                 [Test]
597                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
598                 public void TestXmlElementTypeMapping ()
599                 {
600                         Type type = typeof (XmlElement);
601
602                         XmlTypeMapping tm = Map (type);
603                         Assert.AreEqual (string.Empty, tm.ElementName, "#1");
604                         Assert.IsNull (tm.Namespace, "#2");
605                         Assert.AreEqual ("XmlElement", tm.TypeName, "#3");
606                         Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#4");
607
608                         tm = Map (type, AnotherNamespace);
609                         Assert.AreEqual (string.Empty, tm.ElementName, "#B1");
610                         Assert.IsNull (tm.Namespace, "#B2");
611                         Assert.AreEqual ("XmlElement", tm.TypeName, "#B3");
612                         Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#B4");
613
614                         XmlRootAttribute root = new XmlRootAttribute ("somename");
615                         root.Namespace = SomeNamespace;
616                         tm = Map (type, root);
617                         Assert.AreEqual ("somename", tm.ElementName, "#C1");
618                         Assert.IsNull (tm.Namespace, "#C2");
619                         Assert.AreEqual ("XmlElement", tm.TypeName, "#C3");
620                         Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#C4");
621
622                         tm = Map (type, AnotherNamespace, root);
623                         Assert.AreEqual ("somename", tm.ElementName, "#D1");
624                         Assert.IsNull (tm.Namespace, "#D2");
625                         Assert.AreEqual ("XmlElement", tm.TypeName, "#D3");
626                         Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#D4");
627
628                         root.Namespace = null;
629                         tm = Map (type, root);
630                         Assert.AreEqual ("somename", tm.ElementName, "#E1");
631                         Assert.IsNull (tm.Namespace, "#E2");
632                         Assert.AreEqual ("XmlElement", tm.TypeName, "#E3");
633                         Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#E4");
634
635                         tm = Map (type, AnotherNamespace, root);
636                         Assert.AreEqual ("somename", tm.ElementName, "#F1");
637                         Assert.IsNull (tm.Namespace, "#F2");
638                         Assert.AreEqual ("XmlElement", tm.TypeName, "#F3");
639                         Assert.AreEqual ("System.Xml.XmlElement", tm.TypeFullName, "#F4");
640                 }
641
642                 [Test]
643                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
644                 public void TestXmlNotationTypeMapping ()
645                 {
646                         Type type = typeof (XmlNotation);
647
648                         XmlTypeMapping tm = Map (type);
649                         Assert.AreEqual (string.Empty, tm.ElementName, "#1");
650                         Assert.IsNull (tm.Namespace, "#2");
651                         Assert.AreEqual ("XmlNotation", tm.TypeName, "#3");
652                         Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#4");
653
654                         tm = Map (type, AnotherNamespace);
655                         Assert.AreEqual (string.Empty, tm.ElementName, "#B1");
656                         Assert.IsNull (tm.Namespace, "#B2");
657                         Assert.AreEqual ("XmlNotation", tm.TypeName, "#B3");
658                         Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#B4");
659
660                         XmlRootAttribute root = new XmlRootAttribute ("somename");
661                         root.Namespace = SomeNamespace;
662                         tm = Map (type, root);
663                         Assert.AreEqual ("somename", tm.ElementName, "#C1");
664                         Assert.IsNull (tm.Namespace, "#C2");
665                         Assert.AreEqual ("XmlNotation", tm.TypeName, "#C3");
666                         Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#C4");
667
668                         tm = Map (type, AnotherNamespace, root);
669                         Assert.AreEqual ("somename", tm.ElementName, "#D1");
670                         Assert.IsNull (tm.Namespace, "#D2");
671                         Assert.AreEqual ("XmlNotation", tm.TypeName, "#D3");
672                         Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#D4");
673
674                         root.Namespace = null;
675                         tm = Map (type, root);
676                         Assert.AreEqual ("somename", tm.ElementName, "#E1");
677                         Assert.IsNull (tm.Namespace, "#E2");
678                         Assert.AreEqual ("XmlNotation", tm.TypeName, "#E3");
679                         Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#E4");
680
681                         tm = Map (type, AnotherNamespace, root);
682                         Assert.AreEqual ("somename", tm.ElementName, "#F1");
683                         Assert.IsNull (tm.Namespace, "#F2");
684                         Assert.AreEqual ("XmlNotation", tm.TypeName, "#F3");
685                         Assert.AreEqual ("System.Xml.XmlNotation", tm.TypeFullName, "#F4");
686                 }
687
688                 [Test]
689                 public void TestXmlSerializableTypeMapping ()
690                 {
691                         XmlTypeMapping tm = Map (typeof (Employee));
692                         Assert.AreEqual ("Employee", tm.ElementName, "#1");
693                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
694                         Assert.AreEqual ("Employee", tm.TypeName, "#3");
695                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.Employee", tm.TypeFullName, "#4");
696                 }
697
698                 [Test]
699 #if NET_2_0
700                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
701 #endif
702                 public void TestXmlSerializableTypeMapping_Array ()
703                 {
704                         XmlTypeMapping tm = Map (typeof (Employee[]));
705                         Assert.AreEqual ("ArrayOfEmployee", tm.ElementName, "#A1");
706                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
707 #if NET_2_0
708                         Assert.AreEqual ("ArrayOfEmployee", tm.TypeName, "#A3");
709 #else
710                         Assert.AreEqual ("Employee[]", tm.TypeName, "#A3");
711 #endif
712                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.Employee[]", tm.TypeFullName, "#A4");
713
714                         tm = Map (typeof (Employee[][]));
715                         Assert.AreEqual ("ArrayOfArrayOfEmployee", tm.ElementName, "#B1");
716                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
717 #if NET_2_0
718                         Assert.AreEqual ("ArrayOfArrayOfEmployee", tm.TypeName, "#B3");
719 #else
720                         Assert.AreEqual ("Employee[][]", tm.TypeName, "#B3");
721 #endif
722                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.Employee[][]", tm.TypeFullName, "#B4");
723
724                         tm = Map (typeof (Employee[][][]));
725                         Assert.AreEqual ("ArrayOfArrayOfArrayOfEmployee", tm.ElementName, "#C1");
726                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
727 #if NET_2_0
728                         Assert.AreEqual ("ArrayOfArrayOfArrayOfEmployee", tm.TypeName, "#C3");
729 #else
730                         Assert.AreEqual ("Employee[][][]", tm.TypeName, "#C3");
731 #endif
732                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.Employee[][][]", tm.TypeFullName, "#C4");
733                 }
734
735                 [Test]
736                 public void TestClassTypeMapping_NestedStruct ()
737                 {
738                         XmlTypeMapping tm = Map (typeof (NestedStruct));
739                         Assert.AreEqual ("NestedStruct", tm.ElementName, "#1");
740                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
741                         Assert.AreEqual ("NestedStruct", tm.TypeName, "#3");
742                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.NestedStruct", tm.TypeFullName, "#4");
743                 }
744
745                 [Test]
746                 [ExpectedException (typeof (ArgumentNullException))]
747                 public void TestNullTypeMapping()
748                 {
749                         Map(null);
750                 }
751
752                 [Test]
753                 public void TestIntTypeMappingWithDefaultNamespaces()
754                 {
755                         XmlTypeMapping tm = Map(typeof(int), SomeNamespace);
756                         Assert.AreEqual ("int", tm.ElementName, "#1");
757                         Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
758                         Assert.AreEqual ("Int32", tm.TypeName, "#3");
759                         Assert.AreEqual ("System.Int32", tm.TypeFullName, "#4");
760                 }
761
762                 [Test]
763                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
764                 public void TestStructTypeMapping ()
765                 {
766                         XmlTypeMapping tm = Map (typeof (TimeSpan));
767                         Assert.AreEqual ("TimeSpan", tm.ElementName, "#1");
768                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
769                         Assert.AreEqual ("TimeSpan", tm.TypeName, "#3");
770                         Assert.AreEqual ("System.TimeSpan", tm.TypeFullName, "#4");
771                 }
772
773                 [Test]
774                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
775                 public void TestStructTypeMapping_Array ()
776                 {
777                         XmlTypeMapping tm = Map (typeof (TimeSpan[]));
778                         Assert.AreEqual ("ArrayOfTimeSpan", tm.ElementName, "#A1");
779                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
780 #if NET_2_0
781                         Assert.AreEqual ("ArrayOfTimeSpan", tm.TypeName, "#A3");
782 #else
783                         Assert.AreEqual ("TimeSpan[]", tm.TypeName, "#A3");
784 #endif
785                         Assert.AreEqual ("System.TimeSpan[]", tm.TypeFullName, "#A4");
786
787                         tm = Map (typeof (TimeSpan[][]));
788                         Assert.AreEqual ("ArrayOfArrayOfTimeSpan", tm.ElementName, "#B1");
789                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
790 #if NET_2_0
791                         Assert.AreEqual ("ArrayOfArrayOfTimeSpan", tm.TypeName, "#B3");
792 #else
793                         Assert.AreEqual ("TimeSpan[][]", tm.TypeName, "#B3");
794 #endif
795                         Assert.AreEqual ("System.TimeSpan[][]", tm.TypeFullName, "#B4");
796
797                         tm = Map (typeof (TimeSpan[][][]));
798                         Assert.AreEqual ("ArrayOfArrayOfArrayOfTimeSpan", tm.ElementName, "#C1");
799                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
800 #if NET_2_0
801                         Assert.AreEqual ("ArrayOfArrayOfArrayOfTimeSpan", tm.TypeName, "#C3");
802 #else
803                         Assert.AreEqual ("TimeSpan[][][]", tm.TypeName, "#C3");
804 #endif
805                         Assert.AreEqual ("System.TimeSpan[][][]", tm.TypeFullName, "#C4");
806                 }
807
808                 [Test]
809                 public void TestEnumTypeMapping ()
810                 {
811                         XmlTypeMapping tm = Map (typeof (AttributeTargets));
812                         Assert.AreEqual ("AttributeTargets", tm.ElementName, "#1");
813                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
814                         Assert.AreEqual ("AttributeTargets", tm.TypeName, "#3");
815                         Assert.AreEqual ("System.AttributeTargets", tm.TypeFullName, "#4");
816                 }
817
818                 [Test]
819 #if NET_2_0
820                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
821 #endif
822                 public void TestEnumTypeMapping_Array ()
823                 {
824                         XmlTypeMapping tm = Map (typeof (AttributeTargets[]));
825                         Assert.AreEqual ("ArrayOfAttributeTargets", tm.ElementName, "#A1");
826                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
827 #if NET_2_0
828                         Assert.AreEqual ("ArrayOfAttributeTargets", tm.TypeName, "#A3");
829 #else
830                         Assert.AreEqual ("AttributeTargets[]", tm.TypeName, "#A3");
831 #endif
832                         Assert.AreEqual ("System.AttributeTargets[]", tm.TypeFullName, "#A4");
833
834                         tm = Map (typeof (AttributeTargets[][]));
835                         Assert.AreEqual ("ArrayOfArrayOfAttributeTargets", tm.ElementName, "#B1");
836                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
837 #if NET_2_0
838                         Assert.AreEqual ("ArrayOfArrayOfAttributeTargets", tm.TypeName, "#B3");
839 #else
840                         Assert.AreEqual ("AttributeTargets[][]", tm.TypeName, "#B3");
841 #endif
842                         Assert.AreEqual ("System.AttributeTargets[][]", tm.TypeFullName, "#B4");
843
844                         tm = Map (typeof (AttributeTargets[][][]));
845                         Assert.AreEqual ("ArrayOfArrayOfArrayOfAttributeTargets", tm.ElementName, "#C1");
846                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
847 #if NET_2_0
848                         Assert.AreEqual ("ArrayOfArrayOfArrayOfAttributeTargets", tm.TypeName, "#C3");
849 #else
850                         Assert.AreEqual ("AttributeTargets[][][]", tm.TypeName, "#C3");
851 #endif
852                         Assert.AreEqual ("System.AttributeTargets[][][]", tm.TypeFullName, "#C4");
853                 }
854
855                 [Test]
856                 public void TestClassTypeMapping()
857                 {
858                         XmlTypeMapping tm = Map (typeof (SimpleClass));
859                         Assert.AreEqual ("SimpleClass", tm.ElementName, "#1");
860                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
861                         Assert.AreEqual ("SimpleClass", tm.TypeName, "#3");
862                         Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass", tm.TypeFullName, "#4");
863                 }
864
865                 [Test]
866 #if NET_2_0
867                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
868 #endif
869                 public void TestClassTypeMapping_Array ()
870                 {
871                         XmlTypeMapping tm = Map (typeof (SimpleClass[]));
872                         Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#A1");
873                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
874 #if NET_2_0
875                         Assert.AreEqual ("ArrayOfSimpleClass", tm.TypeName, "#A3");
876 #else
877                         Assert.AreEqual ("SimpleClass[]", tm.TypeName, "#A3");
878 #endif
879                         Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[]", tm.TypeFullName, "#A4");
880
881                         tm = Map (typeof (SimpleClass[][]));
882                         Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
883                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
884 #if NET_2_0
885                         Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.TypeName, "#B3");
886 #else
887                         Assert.AreEqual ("SimpleClass[][]", tm.TypeName, "#B3");
888 #endif
889                         Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[][]", tm.TypeFullName, "#B4");
890
891                         tm = Map (typeof (SimpleClass[][][]));
892                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#C1");
893                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
894 #if NET_2_0
895                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.TypeName, "#C3");
896 #else
897                         Assert.AreEqual ("SimpleClass[][][]", tm.TypeName, "#C3");
898 #endif
899                         Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[][][]", tm.TypeFullName, "#C4");
900                 }
901
902                 [Test]
903                 [ExpectedException (typeof (NotSupportedException))]
904                 public void TypeMapping_IDictionary ()
905                 {
906                         // The type MonoTests.System.Xml.TestClasses.DictionaryWithIndexer 
907                         // is not supported because it implements IDictionary.
908                         Map (typeof (DictionaryWithIndexer));
909                 }
910
911                 [Test]
912 #if NET_2_0
913                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
914 #endif
915                 public void TypeMapping_IEnumerable_SimpleClass ()
916                 {
917                         XmlTypeMapping tm = Map (typeof (SimpleClassEnumerable));
918                         Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#1");
919                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
920                         Assert.AreEqual ("SimpleClassEnumerable", tm.TypeName, "#3");
921                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerable", tm.TypeFullName, "#4");
922
923                         tm = Map (typeof (SimpleClassEnumerable[]));
924                         Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#A1");
925                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
926 #if NET_2_0
927                         Assert.AreEqual ("ArrayOfSimpleClassEnumerable", tm.TypeName, "#A3");
928 #else
929                         Assert.AreEqual ("SimpleClassEnumerable[]", tm.TypeName, "#A3");
930 #endif
931                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerable[]", tm.TypeFullName, "#A4");
932
933                         tm = Map (typeof (SimpleClassEnumerable[][]));
934                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
935                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
936 #if NET_2_0
937                         Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerable", tm.TypeName, "#B3");
938 #else
939                         Assert.AreEqual ("SimpleClassEnumerable[][]", tm.TypeName, "#B3");
940 #endif
941                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerable[][]", tm.TypeFullName, "#B4");
942
943                         tm = Map (typeof (SimpleClassEnumerable[][][]));
944                         Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#C1");
945                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
946 #if NET_2_0
947                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassEnumerable", tm.TypeName, "#C3");
948 #else
949                         Assert.AreEqual ("SimpleClassEnumerable[][][]", tm.TypeName, "#C3");
950 #endif
951                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerable[][][]", tm.TypeFullName, "#C4");
952                 }
953
954                 [Test]
955 #if NET_2_0
956                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
957 #endif
958                 public void TypeMapping_IEnumerable_Object ()
959                 {
960                         XmlTypeMapping tm = Map (typeof (ObjectEnumerable));
961                         Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
962                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
963                         Assert.AreEqual ("ObjectEnumerable", tm.TypeName, "#3");
964                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectEnumerable", tm.TypeFullName, "#4");
965
966                         tm = Map (typeof (ObjectEnumerable[]));
967                         Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
968                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
969 #if NET_2_0
970                         Assert.AreEqual ("ArrayOfObjectEnumerable", tm.TypeName, "#A3");
971 #else
972                         Assert.AreEqual ("ObjectEnumerable[]", tm.TypeName, "#A3");
973 #endif
974                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectEnumerable[]", tm.TypeFullName, "#A4");
975
976                         tm = Map (typeof (ObjectEnumerable[][]));
977                         Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
978                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
979 #if NET_2_0
980                         Assert.AreEqual ("ArrayOfArrayOfObjectEnumerable", tm.TypeName, "#B3");
981 #else
982                         Assert.AreEqual ("ObjectEnumerable[][]", tm.TypeName, "#B3");
983 #endif
984                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectEnumerable[][]", tm.TypeFullName, "#B4");
985
986                         tm = Map (typeof (ObjectEnumerable[][][]));
987                         Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
988                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
989 #if NET_2_0
990                         Assert.AreEqual ("ArrayOfArrayOfArrayOfObjectEnumerable", tm.TypeName, "#C3");
991 #else
992                         Assert.AreEqual ("ObjectEnumerable[][][]", tm.TypeName, "#C3");
993 #endif
994                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectEnumerable[][][]", tm.TypeFullName, "#C4");
995                 }
996
997                 [Test]
998                 [ExpectedException (typeof (InvalidOperationException))]
999                 public void TypeMapping_IEnumerable_Object_NoMatchingAddMethod ()
1000                 {
1001                         Map (typeof (ObjectEnumerableNoMatchingAddMethod));
1002                 }
1003
1004                 [Test]
1005                 [ExpectedException (typeof (InvalidOperationException))]
1006                 public void TypeMapping_IEnumerable_Object_NoMatchingAddMethod_Array ()
1007                 {
1008                         Map (typeof (ObjectEnumerableNoMatchingAddMethod[]));
1009                 }
1010
1011                 [Test]
1012 #if NET_2_0
1013                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1014 #endif
1015                 public void TypeMapping_IEnumerable_SimpleClass_PrivateCurrent ()
1016                 {
1017                         XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateCurrent));
1018                         Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
1019                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1020                         Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent", tm.TypeName, "#3");
1021                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateCurrent", tm.TypeFullName, "#4");
1022
1023                         tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[]));
1024                         Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
1025                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1026 #if NET_2_0
1027                         Assert.AreEqual ("ArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#A3");
1028 #else
1029                         Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[]", tm.TypeName, "#A3");
1030 #endif
1031                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[]", tm.TypeFullName, "#A4");
1032
1033                         tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[][]));
1034                         Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
1035                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1036 #if NET_2_0
1037                         Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#B3");
1038 #else
1039                         Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[][]", tm.TypeName, "#B3");
1040 #endif
1041                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[][]", tm.TypeFullName, "#B4");
1042
1043                         tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[][][]));
1044                         Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
1045                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
1046 #if NET_2_0
1047                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#C3");
1048 #else
1049                         Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[][][]", tm.TypeName, "#C3");
1050 #endif
1051                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[][][]", tm.TypeFullName, "#C4");
1052                 }
1053
1054                 [Test]
1055 #if NET_2_0
1056                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1057 #endif
1058 #if ONLY_1_1
1059                 [Category ("NotDotNet")] // results in NullReferenceException in .NET 1.1 (SP1)
1060 #endif
1061                 public void TypeMapping_IEnumerable_SimpleClass_PrivateGetEnumerator ()
1062                 {
1063                         XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator));
1064                         Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
1065                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1066                         Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#3");
1067                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator", tm.TypeFullName, "#4");
1068
1069                         tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[]));
1070                         Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
1071                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1072 #if NET_2_0
1073                         Assert.AreEqual ("ArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#A3");
1074 #else
1075                         Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[]", tm.TypeName, "#A3");
1076 #endif
1077                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[]", tm.TypeFullName, "#A4");
1078
1079                         tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[][]));
1080                         Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
1081                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1082 #if NET_2_0
1083                         Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#B3");
1084 #else
1085                         Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[][]", tm.TypeName, "#B3");
1086 #endif
1087                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[][]", tm.TypeFullName, "#B4");
1088
1089                         tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[][][]));
1090                         Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
1091                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
1092 #if NET_2_0
1093                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#C3");
1094 #else
1095                         Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[][][]", tm.TypeName, "#C3");
1096 #endif
1097                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[][][]", tm.TypeFullName, "#C4");
1098                 }
1099
1100                 [Test]
1101                 [ExpectedException (typeof (InvalidOperationException))]
1102                 public void TypeMapping_ICollection_Object_NoMatchingAddMethod ()
1103                 {
1104                         Map (typeof (ObjectCollectionNoMatchingAddMethod));
1105                 }
1106
1107                 [Test]
1108                 [ExpectedException (typeof (InvalidOperationException))]
1109                 public void TypeMapping_ICollection_Object_NoMatchingAddMethod_Array ()
1110                 {
1111                         Map (typeof (ObjectCollectionNoMatchingAddMethod[]));
1112                 }
1113
1114                 [Test]
1115                 [ExpectedException (typeof (InvalidOperationException))]
1116                 public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod ()
1117                 {
1118                         Map (typeof (SimpleClassCollectionNoMatchingAddMethod));
1119                 }
1120
1121                 [Test]
1122                 [ExpectedException (typeof (InvalidOperationException))]
1123                 public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod_Array ()
1124                 {
1125                         Map (typeof (SimpleClassCollectionNoMatchingAddMethod[]));
1126                 }
1127
1128                 [Test]
1129 #if NET_2_0
1130                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1131 #endif
1132                 public void TypeMapping_ICollection_SimpleClass ()
1133                 {
1134                         XmlTypeMapping tm = Map (typeof (SimpleClassCollection));
1135                         Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#1");
1136                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1137                         Assert.AreEqual ("SimpleClassCollection", tm.TypeName, "#3");
1138                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassCollection", tm.TypeFullName, "#4");
1139
1140                         tm = Map (typeof (SimpleClassCollection[]));
1141                         Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#A1");
1142                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1143 #if NET_2_0
1144                         Assert.AreEqual ("ArrayOfSimpleClassCollection", tm.TypeName, "#A3");
1145 #else
1146                         Assert.AreEqual ("SimpleClassCollection[]", tm.TypeName, "#A3");
1147 #endif
1148                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassCollection[]", tm.TypeFullName, "#A4");
1149
1150                         tm = Map (typeof (SimpleClassCollection[][]));
1151                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
1152                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1153 #if NET_2_0
1154                         Assert.AreEqual ("ArrayOfArrayOfSimpleClassCollection", tm.TypeName, "#B3");
1155 #else
1156                         Assert.AreEqual ("SimpleClassCollection[][]", tm.TypeName, "#B3");
1157 #endif
1158                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassCollection[][]", tm.TypeFullName, "#B4");
1159
1160                         tm = Map (typeof (SimpleClassCollection[][][]));
1161                         Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#C1");
1162                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
1163 #if NET_2_0
1164                         Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClassCollection", tm.TypeName, "#C3");
1165 #else
1166                         Assert.AreEqual ("SimpleClassCollection[][][]", tm.TypeName, "#C3");
1167 #endif
1168                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.SimpleClassCollection[][][]", tm.TypeFullName, "#C4");
1169                 }
1170
1171                 [Test]
1172 #if NET_2_0
1173                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1174 #endif
1175                 public void TypeMapping_ICollection_Object ()
1176                 {
1177                         XmlTypeMapping tm = Map (typeof (ObjectCollection));
1178                         Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
1179                         Assert.AreEqual (string.Empty, tm.Namespace, "#2");
1180                         Assert.AreEqual ("ObjectCollection", tm.TypeName, "#3");
1181                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectCollection", tm.TypeFullName, "#4");
1182
1183                         tm = Map (typeof (ObjectCollection[]));
1184                         Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
1185                         Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
1186 #if NET_2_0
1187                         Assert.AreEqual ("ArrayOfObjectCollection", tm.TypeName, "#A3");
1188 #else
1189                         Assert.AreEqual ("ObjectCollection[]", tm.TypeName, "#A3");
1190 #endif
1191                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectCollection[]", tm.TypeFullName, "#A4");
1192
1193                         tm = Map (typeof (ObjectCollection[][]));
1194                         Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
1195                         Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
1196 #if NET_2_0
1197                         Assert.AreEqual ("ArrayOfArrayOfObjectCollection", tm.TypeName, "#B3");
1198 #else
1199                         Assert.AreEqual ("ObjectCollection[][]", tm.TypeName, "#B3");
1200 #endif
1201                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectCollection[][]", tm.TypeFullName, "#B4");
1202
1203                         tm = Map (typeof (ObjectCollection[][][]));
1204                         Assert.AreEqual ("ArrayOfArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#C1");
1205                         Assert.AreEqual (string.Empty, tm.Namespace, "#C2");
1206 #if NET_2_0
1207                         Assert.AreEqual ("ArrayOfArrayOfArrayOfObjectCollection", tm.TypeName, "#C3");
1208 #else
1209                         Assert.AreEqual ("ObjectCollection[][][]", tm.TypeName, "#C3");
1210 #endif
1211                         Assert.AreEqual ("MonoTests.System.XmlSerialization.XmlReflectionImporterTests.ObjectCollection[][][]", tm.TypeFullName, "#C4");
1212                 }
1213
1214                 [Test]
1215                 [ExpectedException (typeof (InvalidOperationException))]
1216                 public void TypeMapping_ICollection_Object_NoIntIndexer ()
1217                 {
1218                         Map (typeof (ObjectCollectionNoIntIndexer));
1219                 }
1220
1221                 [Test]
1222                 [ExpectedException (typeof (InvalidOperationException))]
1223                 public void TypeMapping_ICollection_Object_NoIntIndexer_Array ()
1224                 {
1225                         Map (typeof (ObjectCollectionNoIntIndexer[]));
1226                 }
1227
1228                 [Test]
1229                 [ExpectedException (typeof (InvalidOperationException))]
1230                 public void TypeMapping_ICollection_SimpleClass_NoIntIndexer ()
1231                 {
1232                         Map (typeof (SimpleClassCollectionNoIntIndexer));
1233                 }
1234
1235                 [Test]
1236                 [ExpectedException (typeof (InvalidOperationException))]
1237                 public void TypeMapping_ICollection_SimpleClass_NoIntIndexer_Array ()
1238                 {
1239                         Map (typeof (SimpleClassCollectionNoIntIndexer[]));
1240                 }
1241
1242                 [Test]
1243                 public void TypeMapping_InvalidDefault ()
1244                 {
1245                         XmlAttributes attrs = new XmlAttributes (typeof (Field).GetMember ("Modifiers") [0]);
1246                         attrs.XmlDefaultValue = 2; // not a defined enum value
1247                         XmlAttributeOverrides overrides = new XmlAttributeOverrides ();
1248                         overrides.Add (typeof (Field), "Modifiers", attrs);
1249
1250                         try {
1251                                 Map (typeof (Field), overrides);
1252                                 Assert.Fail ("#A1");
1253                         } catch (InvalidOperationException ex) {
1254                                 // There was an error reflecting type MonoTests.System.Xml.TestClasses.Field
1255                                 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#A2");
1256                                 Assert.IsNotNull (ex.Message, "#A3");
1257                                 Assert.IsTrue (ex.Message.IndexOf (typeof (Field).FullName) != -1, "#A4");
1258                                 Assert.IsNotNull (ex.InnerException, "#A5");
1259
1260                                 // There was an error reflecting field 'Modifiers'
1261                                 Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#A6");
1262                                 Assert.IsNotNull (ex.InnerException.Message, "#A7");
1263                                 Assert.IsTrue (ex.InnerException.Message.IndexOf ("'Modifiers'") != -1, "#A8");
1264                                 Assert.IsNotNull (ex.InnerException.InnerException, "#A9");
1265
1266                                 // Value '2' cannot be converted to System.Int32
1267                                 Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.InnerException.GetType (), "#A10");
1268                                 Assert.IsNotNull (ex.InnerException.InnerException.Message, "#A11");
1269                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf ("'2'") != -1, "#A12");
1270                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf (typeof (int).FullName) != -1, "#A13");
1271                                 Assert.IsNull (ex.InnerException.InnerException.InnerException, "#A14");
1272                         }
1273
1274                         attrs.XmlDefaultValue = "2"; // not of the same type as the underlying enum type (System.Int32)
1275
1276                         try {
1277                                 Map (typeof (Field), overrides);
1278                                 Assert.Fail ("#B1");
1279                         } catch (InvalidOperationException ex) {
1280                                 // There was an error reflecting type MonoTests.System.Xml.TestClasses.Field
1281                                 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#B2");
1282                                 Assert.IsNotNull (ex.Message, "#B3");
1283                                 Assert.IsTrue (ex.Message.IndexOf (typeof (Field).FullName) != -1, "#B4");
1284                                 Assert.IsNotNull (ex.InnerException, "#B5");
1285
1286                                 // There was an error reflecting field 'Modifiers'
1287                                 Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#B6");
1288                                 Assert.IsNotNull (ex.InnerException.Message, "#B7");
1289                                 Assert.IsTrue (ex.InnerException.Message.IndexOf ("'Modifiers'") != -1, "#B8");
1290                                 Assert.IsNotNull (ex.InnerException.InnerException, "#B9");
1291
1292                                 // Enum underlying type and the object must be same type or object.
1293                                 // Type passed in was 'System.String'; the enum underlying type was
1294                                 // 'System.Int32'.
1295                                 Assert.AreEqual (typeof (ArgumentException), ex.InnerException.InnerException.GetType (), "#B10");
1296                                 Assert.IsNotNull (ex.InnerException.InnerException.Message, "#B11");
1297                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf (typeof (string).FullName) != -1, "#B12");
1298                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf (typeof (int).FullName) != -1, "#B13");
1299                                 Assert.IsNull (ex.InnerException.InnerException.InnerException, "#B14");
1300                         }
1301
1302                         attrs.XmlDefaultValue = EnumDefaultValueNF.e2; // other enum type
1303
1304                         try {
1305                                 Map (typeof (Field), overrides);
1306                                 Assert.Fail ("#C1");
1307                         } catch (InvalidOperationException ex) {
1308                                 // There was an error reflecting type MonoTests.System.Xml.TestClasses.Field
1309                                 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#C2");
1310                                 Assert.IsNotNull (ex.Message, "#C3");
1311                                 Assert.IsTrue (ex.Message.IndexOf (typeof (Field).FullName) != -1, "#C4");
1312                                 Assert.IsNotNull (ex.InnerException, "#C5");
1313
1314                                 // There was an error reflecting field 'Modifiers'
1315                                 Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#C6");
1316                                 Assert.IsNotNull (ex.InnerException.Message, "#C7");
1317                                 Assert.IsTrue (ex.InnerException.Message.IndexOf ("'Modifiers'") != -1, "#C8");
1318                                 Assert.IsNotNull (ex.InnerException.InnerException, "#C9");
1319
1320                                 // Object must be the same type as the enum. The type passed in
1321                                 // was MonoTests.System.Xml.TestClasses.EnumDefaultValueNF; the
1322                                 // enum type was MonoTests.System.Xml.TestClasses.MapModifiers
1323                                 Assert.AreEqual (typeof (ArgumentException), ex.InnerException.InnerException.GetType (), "#C10");
1324                                 Assert.IsNotNull (ex.InnerException.InnerException.Message, "#C11");
1325                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf (typeof (EnumDefaultValueNF).FullName) != -1, "#C12");
1326                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#C13");
1327                                 Assert.IsNull (ex.InnerException.InnerException.InnerException, "#C14");
1328                         }
1329
1330                         attrs.XmlDefaultValue = (MapModifiers) 20; // non-existing enum value
1331
1332                         try {
1333                                 Map (typeof (Field), overrides);
1334                                 Assert.Fail ("#D1");
1335                         } catch (InvalidOperationException ex) {
1336                                 // There was an error reflecting type MonoTests.System.Xml.TestClasses.Field
1337                                 Assert.AreEqual (typeof (InvalidOperationException), ex.GetType (), "#D2");
1338                                 Assert.IsNotNull (ex.Message, "#D3");
1339                                 Assert.IsTrue (ex.Message.IndexOf (typeof (Field).FullName) != -1, "#D4");
1340                                 Assert.IsNotNull (ex.InnerException, "#D5");
1341
1342                                 // There was an error reflecting field 'Modifiers'
1343                                 Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.GetType (), "#D6");
1344                                 Assert.IsNotNull (ex.InnerException.Message, "#D7");
1345                                 Assert.IsTrue (ex.InnerException.Message.IndexOf ("'Modifiers'") != -1, "#D8");
1346                                 Assert.IsNotNull (ex.InnerException.InnerException, "#D9");
1347
1348                                 // Value '20' cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
1349                                 Assert.AreEqual (typeof (InvalidOperationException), ex.InnerException.InnerException.GetType (), "#D10");
1350                                 Assert.IsNotNull (ex.InnerException.InnerException.Message, "#D11");
1351                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf ("'20'") != -1, "#D12");
1352                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#D13");
1353                                 Assert.IsNull (ex.InnerException.InnerException.InnerException, "#D14");
1354                         }
1355                 }
1356
1357                 [Test]
1358                 [ExpectedException (typeof (ArgumentNullException))]
1359                 public void TypeMapping_Null ()
1360                 {
1361                         Map ((Type) null);
1362                 }
1363
1364                 [Test]
1365                 [ExpectedException (typeof (NotSupportedException))]
1366                 public void TypeMapping_Void ()
1367                 {
1368                         Map (typeof (void));
1369                 }
1370
1371                 [Test]
1372                 public void TypeMapping_WrongChoices ()
1373                 {
1374                         try {
1375                                 Map (typeof (WrongChoices));
1376                                 Assert.Fail ("#1");
1377                         } catch (InvalidOperationException ex) {
1378                                 // There was an error reflecting type 'MonoTests.System.Xml.TestClasses.WrongChoices'
1379                                 Assert.IsNotNull (ex.Message, "#2");
1380                                 Assert.IsTrue (ex.Message.IndexOf ("'" + typeof (WrongChoices).FullName + "'") != -1, "#3");
1381                                 Assert.IsNotNull (ex.InnerException, "#4");
1382
1383                                 // There was an error reflecting field 'MyChoice'
1384                                 Assert.IsNotNull (ex.InnerException.Message, "#5");
1385                                 Assert.IsTrue (ex.InnerException.Message.IndexOf ("'MyChoice'") != -1, "#6");
1386                                 Assert.IsNotNull (ex.InnerException.InnerException, "#7");
1387
1388                                 // Type MonoTests.System.Xml.TestClasses.ItemChoiceType is missing 
1389                                 // enumeration value 'StrangeOne' for element 'StrangeOne' from
1390                                 // namespace ''.
1391                                 Assert.IsNotNull (ex.InnerException.InnerException.Message, "#8");
1392                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf (typeof (ItemChoiceType).FullName) != -1, "#9");
1393                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf ("'StrangeOne'") != -1, "#10");
1394                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf ("''") != -1, "#11");
1395                         }
1396                 }
1397
1398                 [Test] // bug #77591
1399                 public void TypeMapping_XmlText_PrimitiveTypes ()
1400                 {
1401                         XmlAttributeOverrides overrides = null;
1402                         XmlAttributes attrs = null;
1403
1404                         overrides = new XmlAttributeOverrides ();
1405                         attrs = new  XmlAttributes ();
1406                         attrs.XmlText = new XmlTextAttribute (typeof (int));
1407                         overrides.Add (typeof (Field), "Modifiers", attrs);
1408
1409                         try {
1410                                 Map (typeof (Field), overrides);
1411                                 Assert.Fail ("#A1");
1412                         } catch (InvalidOperationException ex) {
1413                                 // There was an error reflecting type 'MonoTests.System.Xml.TestClasses.Field'
1414                                 Assert.IsNotNull (ex.Message, "#A2");
1415                                 Assert.IsTrue (ex.Message.IndexOf ("'" + typeof (Field).FullName + "'") != -1, "#A3");
1416                                 Assert.IsNotNull (ex.InnerException, "#A4");
1417
1418                                 // There was an error reflecting field 'Modifiers'
1419                                 Assert.IsNotNull (ex.InnerException.Message, "#A5");
1420                                 Assert.IsTrue (ex.InnerException.Message.IndexOf ("'Modifiers'") != -1, "#A6");
1421                                 Assert.IsNotNull (ex.InnerException.InnerException, "#A7");
1422
1423                                 // The type for XmlText may not be specified for primitive types
1424                                 Assert.IsNotNull (ex.InnerException.InnerException.Message, "#A8");
1425                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf ("XmlText") != -1, "#A9");
1426                         }
1427
1428                         overrides = new XmlAttributeOverrides ();
1429                         attrs = new XmlAttributes ();
1430                         attrs.XmlText = new XmlTextAttribute (typeof (int));
1431                         overrides.Add (typeof (Field), "Street", attrs);
1432
1433                         try {
1434                                 Map (typeof (Field), overrides);
1435                                 Assert.Fail ("#B1");
1436                         } catch (InvalidOperationException ex) {
1437                                 // There was an error reflecting type 'MonoTests.System.Xml.TestClasses.Field'
1438                                 Assert.IsNotNull (ex.Message, "#B2");
1439                                 Assert.IsTrue (ex.Message.IndexOf ("'" + typeof (Field).FullName + "'") != -1, "#B3");
1440                                 Assert.IsNotNull (ex.InnerException, "#B4");
1441
1442                                 // There was an error reflecting field 'Street'
1443                                 Assert.IsNotNull (ex.InnerException.Message, "#B5");
1444                                 Assert.IsTrue (ex.InnerException.Message.IndexOf ("'Street'") != -1, "#B6");
1445                                 Assert.IsNotNull (ex.InnerException.InnerException, "#B7");
1446
1447                                 // The type for XmlText may not be specified for primitive types
1448                                 Assert.IsNotNull (ex.InnerException.InnerException.Message, "#B8");
1449                                 Assert.IsTrue (ex.InnerException.InnerException.Message.IndexOf ("XmlText") != -1, "#B9");
1450                         }
1451
1452                         overrides = new XmlAttributeOverrides ();
1453                         attrs = new XmlAttributes ();
1454                         attrs.XmlText = new XmlTextAttribute (typeof (MapModifiers));
1455                         overrides.Add (typeof (Field), "Modifiers", attrs);
1456                         Map (typeof (Field), overrides);
1457
1458                         overrides = new XmlAttributeOverrides ();
1459                         attrs = new XmlAttributes ();
1460                         attrs.XmlText = new XmlTextAttribute (typeof (string));
1461                         overrides.Add (typeof (Field), "Street", attrs);
1462                         Map (typeof (Field), overrides);
1463                 }
1464
1465                 [Test]
1466                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1467                 public void TestImportMembersMapping()
1468                 {
1469                         Type type = typeof(SimpleClass);
1470                         XmlAttributes attrs = new  XmlAttributes();
1471                         XmlAttributeOverrides overrides = new XmlAttributeOverrides();
1472                         overrides.Add(typeof(SimpleClass), attrs);
1473
1474                         XmlReflectionMember[] members = new XmlReflectionMember[0];
1475                         XmlMembersMapping mm;
1476                         try
1477                         {
1478                                 mm = MembersMap(type, overrides, members, true);
1479                                 Assert.Fail("Should not be able to fetch an empty XmlMembersMapping");
1480                         }
1481                         catch (Exception)
1482                         {
1483                         }
1484                         
1485                         XmlReflectionMember rm = new XmlReflectionMember();
1486                         rm.IsReturnValue = false;
1487                         rm.MemberName = "something";
1488                         rm.MemberType = typeof(string);
1489                         members = new XmlReflectionMember[1];
1490                         members[0] = rm;
1491
1492                         mm = MembersMap(type, overrides, members, false);
1493
1494                         Equals(mm.Count, 1);
1495
1496                         XmlMemberMapping smm = mm[0];
1497                         Assert.IsFalse (smm.Any, "#1");
1498                         Assert.AreEqual ("something", smm.ElementName, "#2");
1499                         Assert.AreEqual ("something", smm.MemberName, "#3");
1500                         Assert.IsNull (smm.Namespace, "#4");
1501                         Assert.AreEqual ("System.String", smm.TypeFullName, "#5");
1502                         Assert.AreEqual ("string", smm.TypeName, "#6");
1503 #if NET_2_0
1504                         Assert.AreEqual (XmlSchemaNamespace, smm.TypeNamespace, "#7");
1505 #else
1506                         Assert.IsNull (smm.TypeNamespace, "#7");
1507 #endif
1508
1509                         rm = new XmlReflectionMember();
1510                         rm.IsReturnValue = false;
1511                         rm.MemberName = "nothing";
1512                         rm.MemberType = typeof(string);
1513                         members = new XmlReflectionMember[1];
1514                         members[0] = rm;
1515
1516                         mm = MembersMap(type, overrides, members, false);
1517                         Assert.AreEqual (1, mm.Count, "#8");
1518                 }
1519
1520                 [Test]
1521                 public void TestIntTypeMappingWithXmlRootAttribute()
1522                 {
1523                         const string TheNamespace = "another:urn";
1524                         XmlRootAttribute root = new XmlRootAttribute("price");
1525                         root.Namespace = TheNamespace;
1526                         
1527                         XmlTypeMapping tm = Map(typeof(int), root);
1528                         Assert.AreEqual ("price", tm.ElementName, "#1");
1529                         Assert.AreEqual (TheNamespace, tm.Namespace, "#2");
1530                         Assert.AreEqual ("Int32", tm.TypeName, "#3");
1531                         Assert.AreEqual ("System.Int32", tm.TypeFullName, "#4");
1532                 }
1533                 
1534                 [Test]
1535                 [ExpectedException (typeof (InvalidOperationException))]
1536                 public void TestSerializeWrongChoice ()
1537                 {
1538                         new XmlSerializer (typeof(WrongChoices));
1539                 }
1540
1541                 [Test]
1542                 public void XmlArrayOnByteArray ()
1543                 {
1544                         new XmlSerializer (typeof (XmlArrayOnByteArrayType));
1545                 }
1546
1547 #if NET_2_0
1548
1549                 [Test]
1550                 public void ImportNullableInt ()
1551                 {
1552                         XmlReflectionImporter imp = new XmlReflectionImporter ();
1553                         XmlTypeMapping map = imp.ImportTypeMapping (typeof (int?));
1554                         XmlSchemas schemas = new XmlSchemas ();
1555                         XmlSchemaExporter exp = new XmlSchemaExporter (schemas);
1556                         exp.ExportTypeMapping (map);
1557                         XmlSchema schema = schemas [0];
1558                         XmlSchemaElement el = schema.Items [0] as XmlSchemaElement;
1559                         Assert.AreEqual ("int", el.Name, "#1");
1560                         Assert.AreEqual (new XmlQualifiedName ("int", XmlSchema.Namespace), el.SchemaTypeName, "#2");
1561                         Assert.AreEqual (true, el.IsNillable, "#3");
1562                 }
1563
1564                 [Test]
1565                 public void ImportNullableContainer ()
1566                 {
1567                         new XmlSerializer (typeof (NullableContainer));
1568                 }
1569
1570                 [Test]
1571                 public void ImportNullableContainer2 ()
1572                 {
1573                         XmlReflectionImporter imp = new XmlReflectionImporter ();
1574                         XmlTypeMapping map = imp.ImportTypeMapping (typeof (NullableContainer2));
1575                         XmlSchemas schemas = new XmlSchemas ();
1576                         XmlSchemaExporter exp = new XmlSchemaExporter (schemas);
1577                         exp.ExportTypeMapping (map);
1578
1579                         XmlSchema schema = schemas [0];
1580                         XmlSchemaComplexType el = schema.Items [1] as XmlSchemaComplexType;
1581
1582                         XmlSchemaSequence s = el.Particle as XmlSchemaSequence;
1583                         XmlSchemaElement el2 = s.Items [0] as XmlSchemaElement;
1584                         Assert.IsTrue (el2.IsNillable);
1585                 }
1586
1587                 [Test]
1588                 [ExpectedException (typeof (InvalidOperationException))]
1589                 public void ImportGenericTypeDefinition ()
1590                 {
1591                         new XmlSerializer (typeof (List<int>).GetGenericTypeDefinition ());
1592                 }
1593
1594                 [Test]
1595                 [ExpectedException (typeof (InvalidOperationException))]
1596                 public void XmlSchemaProviderMissingMethod ()
1597                 {
1598                         new XmlSerializer (typeof (XmlSchemaProviderMissingMethodType));
1599                 }
1600
1601                 [Test]
1602                 [ExpectedException (typeof (InvalidOperationException))]
1603                 public void XmlSchemaProviderMethodNonStatic ()
1604                 {
1605                         new XmlSerializer (typeof (XmlSchemaProviderNonStaticType));
1606                 }
1607
1608                 [Test]
1609                 [ExpectedException (typeof (InvalidOperationException))]
1610                 public void XmlSchemaProviderMethodIncorrectReturn ()
1611                 {
1612                         new XmlSerializer (typeof (XmlSchemaProviderIncorrectReturnType));
1613                 }
1614
1615                 [Test]
1616                 public void XmlSchemaProviderAndDefaultNamespace ()
1617                 {
1618                         XmlTypeMapping tm = new XmlReflectionImporter ("urn:bar").ImportTypeMapping (typeof (XmlSchemaProviderAndDefaultNamespaceType));
1619                         Assert.AreEqual ("foo", tm.ElementName, "#1");
1620                         Assert.AreEqual ("foo", tm.XsdTypeName, "#2");
1621                         Assert.AreEqual ("urn:bar", tm.Namespace, "#3");
1622                         Assert.AreEqual ("urn:foo", tm.XsdTypeNamespace);
1623                 }
1624
1625                 [Test]
1626                 public void ImportGenericICollectionWrapped ()
1627                 {
1628                         new XmlSerializer (typeof (MyCollection));
1629                 }
1630 #endif
1631
1632                 public class Employee : IXmlSerializable
1633                 {
1634                         private string _firstName;
1635                         private string _lastName;
1636                         private string _address;
1637
1638                         public XmlSchema GetSchema ()
1639                         {
1640                                 return null;
1641                         }
1642
1643                         public void WriteXml (XmlWriter writer)
1644                         {
1645                                 writer.WriteStartElement ("employee", "urn:devx-com");
1646                                 writer.WriteAttributeString ("firstName", _firstName);
1647                                 writer.WriteAttributeString ("lastName", _lastName);
1648                                 writer.WriteAttributeString ("address", _address);
1649                                 writer.WriteEndElement ();
1650                         }
1651
1652                         public void ReadXml (XmlReader reader)
1653                         {
1654                                 XmlNodeType type = reader.MoveToContent ();
1655                                 if (type == XmlNodeType.Element && reader.LocalName == "employee") {
1656                                         _firstName = reader["firstName"];
1657                                         _lastName = reader["lastName"];
1658                                         _address = reader["address"];
1659                                 }
1660                         }
1661                 }
1662
1663                 public class NestedStruct
1664                 {
1665                         public TimeSpan Period = TimeSpan.MaxValue;
1666                 }
1667
1668                 public class ObjectEnumerable : IEnumerable
1669                 {
1670                         public void Add (int value)
1671                         {
1672                         }
1673
1674                         public void Add (object value)
1675                         {
1676                         }
1677
1678                         public IEnumerator GetEnumerator ()
1679                         {
1680                                 return new ArrayList ().GetEnumerator ();
1681                         }
1682                 }
1683
1684                 public class SimpleClassEnumerable : IEnumerable
1685                 {
1686                         public void Add (int value)
1687                         {
1688                         }
1689
1690                         public void Add (object value)
1691                         {
1692                         }
1693
1694                         IEnumerator IEnumerable.GetEnumerator ()
1695                         {
1696                                 return GetEnumerator ();
1697                         }
1698
1699                         public SimpleClassEnumerator GetEnumerator ()
1700                         {
1701                                 return new SimpleClassEnumerator (new ArrayList ());
1702                         }
1703                 }
1704
1705                 public class SimpleClassEnumerablePrivateGetEnumerator : IEnumerable
1706                 {
1707                         public void Add (object value)
1708                         {
1709                         }
1710
1711                         IEnumerator IEnumerable.GetEnumerator ()
1712                         {
1713                                 return new ArrayList ().GetEnumerator ();
1714                         }
1715                 }
1716
1717                 public class SimpleClassEnumerablePrivateCurrent : IEnumerable
1718                 {
1719                         public void Add (object value)
1720                         {
1721                         }
1722
1723                         IEnumerator IEnumerable.GetEnumerator ()
1724                         {
1725                                 return GetEnumerator ();
1726                         }
1727
1728                         public NoCurrentEnumerator GetEnumerator ()
1729                         {
1730                                 return new NoCurrentEnumerator (new ArrayList ());
1731                         }
1732                 }
1733
1734                 // GetEnumerator().Current returns object, but there's no corresponding
1735                 // Add (System.Object) method
1736                 public class ObjectEnumerableNoMatchingAddMethod : IEnumerable
1737                 {
1738                         public void Add (int value)
1739                         {
1740                         }
1741
1742                         public IEnumerator GetEnumerator ()
1743                         {
1744                                 return new ArrayList ().GetEnumerator ();
1745                         }
1746                 }
1747
1748                 // GetEnumerator().Current returns SimpleClass, but there's no 
1749                 // corresponding Add (SimpleClass) method
1750                 public class SimpleClassCollectionNoMatchingAddMethod : ICollection
1751                 {
1752                         public SimpleClass this[int index]
1753                         {
1754                                 get
1755                                 {
1756                                         return (SimpleClass) _list[index];
1757                                 }
1758                         }
1759
1760                         public int Count
1761                         {
1762                                 get { return _list.Count; }
1763                         }
1764
1765                         public bool IsSynchronized
1766                         {
1767                                 get { return _list.IsSynchronized; }
1768                         }
1769
1770                         public object SyncRoot
1771                         {
1772                                 get { return _list.SyncRoot; }
1773                         }
1774
1775                         public void CopyTo (Array array, int index)
1776                         {
1777                                 _list.CopyTo (array, index);
1778                         }
1779
1780                         IEnumerator IEnumerable.GetEnumerator ()
1781                         {
1782                                 return GetEnumerator ();
1783                         }
1784
1785                         public SimpleClassEnumerator GetEnumerator ()
1786                         {
1787                                 return new SimpleClassEnumerator (_list);
1788                         }
1789
1790                         private ArrayList _list = new ArrayList ();
1791                 }
1792
1793                 // GetEnumerator().Current returns object, but there's no corresponding
1794                 // Add (System.Object) method
1795                 public class ObjectCollectionNoMatchingAddMethod : ICollection
1796                 {
1797                         public object this[int index]
1798                         {
1799                                 get
1800                                 {
1801                                         return _list[index];
1802                                 }
1803                         }
1804
1805                         public int Count
1806                         {
1807                                 get { return _list.Count; }
1808                         }
1809
1810                         public bool IsSynchronized
1811                         {
1812                                 get { return _list.IsSynchronized; }
1813                         }
1814
1815                         public object SyncRoot
1816                         {
1817                                 get { return _list.SyncRoot; }
1818                         }
1819
1820                         public void CopyTo (Array array, int index)
1821                         {
1822                                 _list.CopyTo (array, index);
1823                         }
1824
1825                         IEnumerator IEnumerable.GetEnumerator ()
1826                         {
1827                                 return GetEnumerator ();
1828                         }
1829
1830                         public IEnumerator GetEnumerator ()
1831                         {
1832                                 return _list.GetEnumerator ();
1833                         }
1834
1835                         private ArrayList _list = new ArrayList ();
1836                 }
1837
1838                 // Does not have int indexer.
1839                 public class SimpleClassCollectionNoIntIndexer : ICollection
1840                 {
1841                         public SimpleClass this[string name]
1842                         {
1843                                 get
1844                                 {
1845                                         return new SimpleClass ();
1846                                 }
1847                         }
1848
1849                         public int Count
1850                         {
1851                                 get { return _list.Count; }
1852                         }
1853
1854                         public bool IsSynchronized
1855                         {
1856                                 get { return _list.IsSynchronized; }
1857                         }
1858
1859                         public object SyncRoot
1860                         {
1861                                 get { return _list.SyncRoot; }
1862                         }
1863
1864                         public void CopyTo (Array array, int index)
1865                         {
1866                                 _list.CopyTo (array, index);
1867                         }
1868
1869                         IEnumerator IEnumerable.GetEnumerator ()
1870                         {
1871                                 return GetEnumerator ();
1872                         }
1873
1874                         public SimpleClassEnumerator GetEnumerator ()
1875                         {
1876                                 return new SimpleClassEnumerator (_list);
1877                         }
1878
1879                         public void Add (SimpleClass value)
1880                         {
1881                                 _list.Add (value);
1882                         }
1883
1884                         private ArrayList _list = new ArrayList ();
1885                 }
1886
1887                 // Does not have int indexer.
1888                 public class ObjectCollectionNoIntIndexer : ICollection
1889                 {
1890                         public object this[string name]
1891                         {
1892                                 get
1893                                 {
1894                                         return new SimpleClass ();
1895                                 }
1896                         }
1897
1898                         public int Count
1899                         {
1900                                 get { return _list.Count; }
1901                         }
1902
1903                         public bool IsSynchronized
1904                         {
1905                                 get { return _list.IsSynchronized; }
1906                         }
1907
1908                         public object SyncRoot
1909                         {
1910                                 get { return _list.SyncRoot; }
1911                         }
1912
1913                         public void CopyTo (Array array, int index)
1914                         {
1915                                 _list.CopyTo (array, index);
1916                         }
1917
1918                         public IEnumerator GetEnumerator ()
1919                         {
1920                                 return _list.GetEnumerator ();
1921                         }
1922
1923                         public void Add (object value)
1924                         {
1925                                 _list.Add (value);
1926                         }
1927
1928                         private ArrayList _list = new ArrayList ();
1929                 }
1930
1931                 public class SimpleClassCollection : ICollection
1932                 {
1933                         public SimpleClass this[int index]
1934                         {
1935                                 get
1936                                 {
1937                                         return (SimpleClass) _list[index];
1938                                 }
1939                         }
1940
1941                         public int Count
1942                         {
1943                                 get { return _list.Count; }
1944                         }
1945
1946                         public bool IsSynchronized
1947                         {
1948                                 get { return _list.IsSynchronized; }
1949                         }
1950
1951                         public object SyncRoot
1952                         {
1953                                 get { return _list.SyncRoot; }
1954                         }
1955
1956                         public void CopyTo (Array array, int index)
1957                         {
1958                                 _list.CopyTo (array, index);
1959                         }
1960
1961                         IEnumerator IEnumerable.GetEnumerator ()
1962                         {
1963                                 return GetEnumerator ();
1964                         }
1965
1966                         public SimpleClassEnumerator GetEnumerator ()
1967                         {
1968                                 return new SimpleClassEnumerator (_list);
1969                         }
1970
1971                         public void Add (SimpleClass value)
1972                         {
1973                                 _list.Add (value);
1974                         }
1975
1976                         private ArrayList _list = new ArrayList ();
1977                 }
1978
1979                 public class ObjectCollection : ICollection
1980                 {
1981                         public object this[int name]
1982                         {
1983                                 get
1984                                 {
1985                                         return new SimpleClass ();
1986                                 }
1987                         }
1988
1989                         public int Count
1990                         {
1991                                 get { return _list.Count; }
1992                         }
1993
1994                         public bool IsSynchronized
1995                         {
1996                                 get { return _list.IsSynchronized; }
1997                         }
1998
1999                         public object SyncRoot
2000                         {
2001                                 get { return _list.SyncRoot; }
2002                         }
2003
2004                         public void CopyTo (Array array, int index)
2005                         {
2006                                 _list.CopyTo (array, index);
2007                         }
2008
2009                         public IEnumerator GetEnumerator ()
2010                         {
2011                                 return _list.GetEnumerator ();
2012                         }
2013
2014                         public void Add (object value)
2015                         {
2016                                 _list.Add (value);
2017                         }
2018
2019                         private ArrayList _list = new ArrayList ();
2020                 }
2021
2022                 public class SimpleClassEnumerator : IEnumerator
2023                 {
2024                         internal SimpleClassEnumerator (ArrayList arguments)
2025                         {
2026                                 IEnumerable temp = (IEnumerable) (arguments);
2027                                 _baseEnumerator = temp.GetEnumerator ();
2028                         }
2029                         public SimpleClass Current
2030                         {
2031                                 get { return (SimpleClass) _baseEnumerator.Current; }
2032                         }
2033
2034                         object IEnumerator.Current
2035                         {
2036                                 get { return _baseEnumerator.Current; }
2037                         }
2038
2039                         public bool MoveNext ()
2040                         {
2041                                 return _baseEnumerator.MoveNext ();
2042                         }
2043
2044                         bool IEnumerator.MoveNext ()
2045                         {
2046                                 return _baseEnumerator.MoveNext ();
2047                         }
2048
2049                         public void Reset ()
2050                         {
2051                                 _baseEnumerator.Reset ();
2052                         }
2053
2054                         void IEnumerator.Reset ()
2055                         {
2056                                 _baseEnumerator.Reset ();
2057                         }
2058
2059                         private IEnumerator _baseEnumerator;
2060                 }
2061
2062                 public class NoCurrentEnumerator : IEnumerator
2063                 {
2064                         internal NoCurrentEnumerator (ArrayList arguments)
2065                         {
2066                                 IEnumerable temp = (IEnumerable) (arguments);
2067                                 _baseEnumerator = temp.GetEnumerator ();
2068                         }
2069
2070                         object IEnumerator.Current
2071                         {
2072                                 get { return _baseEnumerator.Current; }
2073                         }
2074
2075                         public bool MoveNext ()
2076                         {
2077                                 return _baseEnumerator.MoveNext ();
2078                         }
2079
2080                         bool IEnumerator.MoveNext ()
2081                         {
2082                                 return _baseEnumerator.MoveNext ();
2083                         }
2084
2085                         public void Reset ()
2086                         {
2087                                 _baseEnumerator.Reset ();
2088                         }
2089
2090                         void IEnumerator.Reset ()
2091                         {
2092                                 _baseEnumerator.Reset ();
2093                         }
2094
2095                         private IEnumerator _baseEnumerator;
2096                 }
2097
2098                 public class XmlArrayOnByteArrayType
2099                 {
2100                         [XmlArray]
2101                         [XmlArrayItem ("Byte", IsNullable =false)]
2102                         public byte [] Args;
2103                 }
2104
2105 #if NET_2_0
2106                 public class NullableContainer
2107                 {
2108                         [XmlElement (IsNullable = true)]
2109                         public int? NilInt;
2110                 }
2111
2112                 public class NullableContainer2
2113                 {
2114                         int? value;
2115
2116                         public int? NullableInt {
2117                                 get { return value; }
2118                                 set { this.value = value; }
2119                         }
2120                 }
2121
2122                 [XmlSchemaProvider ("GetXsdType")]
2123                 public class XmlSchemaProviderMissingMethodType : IXmlSerializable
2124                 {
2125                         public void ReadXml (XmlReader reader)
2126                         {
2127                         }
2128
2129                         public void WriteXml (XmlWriter writer)
2130                         {
2131                         }
2132
2133                         public XmlSchema GetSchema ()
2134                         {
2135                                 return null;
2136                         }
2137                 }
2138
2139                 [XmlSchemaProvider ("GetXsdType")]
2140                 public class XmlSchemaProviderNonStaticType : IXmlSerializable
2141                 {
2142                         public void ReadXml (XmlReader reader)
2143                         {
2144                         }
2145
2146                         public void WriteXml (XmlWriter writer)
2147                         {
2148                         }
2149
2150                         public XmlSchema GetSchema ()
2151                         {
2152                                 return null;
2153                         }
2154
2155                         public object GetXsdType ()
2156                         {
2157                                 return null;
2158                         }
2159                 }
2160
2161                 [XmlSchemaProvider ("GetXsdType")]
2162                 public class XmlSchemaProviderIncorrectReturnType : IXmlSerializable
2163                 {
2164                         public void ReadXml (XmlReader reader)
2165                         {
2166                         }
2167
2168                         public void WriteXml (XmlWriter writer)
2169                         {
2170                         }
2171
2172                         public XmlSchema GetSchema ()
2173                         {
2174                                 return null;
2175                         }
2176
2177                         public static object GetXsdType ()
2178                         {
2179                                 return null;
2180                         }
2181                 }
2182
2183                 [XmlSchemaProvider ("GetXsd")]
2184                 public class XmlSchemaProviderAndDefaultNamespaceType : IXmlSerializable
2185                 {
2186                         public static XmlQualifiedName GetXsd (XmlSchemaSet xss)
2187                         {
2188                                 XmlSchema xs = new XmlSchema ();
2189                                 xs.TargetNamespace = "urn:foo";
2190                                 XmlSchemaComplexType ct = new XmlSchemaComplexType ();
2191                                 ct.Name = "foo";
2192                                 xs.Items.Add (ct);
2193                                 xss.Add (xs);
2194                                 return new XmlQualifiedName ("foo", "urn:foo");
2195                         }
2196
2197                         public void WriteXml (XmlWriter write)
2198                         {
2199                         }
2200
2201                         public void ReadXml (XmlReader reader)
2202                         {
2203                         }
2204
2205                         public XmlSchema GetSchema ()
2206                         {
2207                                 return null;
2208                         }
2209                 }
2210
2211                 public class MyCollection : ICollection<string>
2212                 {
2213                         public int Count { get { return 0; } }
2214
2215                         public bool IsReadOnly { get { return false; } }
2216
2217                         public void Add (string s)
2218                         {
2219                         }
2220
2221                         public void Clear ()
2222                         {
2223                         }
2224
2225                         public bool Contains (string item)
2226                         {
2227                                 return false;
2228                         }
2229
2230                         public void CopyTo (string [] array, int arrayIndex)
2231                         {
2232                         }
2233
2234                         public IEnumerator<string> GetEnumerator ()
2235                         {
2236                                 throw new Exception ();
2237                         }
2238
2239                         IEnumerator IEnumerable.GetEnumerator ()
2240                         {
2241                                 return GetEnumerator ();
2242                         }
2243
2244                         public bool Remove (string item)
2245                         {
2246                                 return false;
2247                         }
2248                 }
2249 #endif
2250         }
2251 }
2252