New test.
[mono.git] / mcs / class / System.XML / Test / System.Xml.Serialization / XmlSchemaExporterTests.cs
1 //
2 // System.Xml.Serialization.XmlSchemaExporterTests
3 //
4 // Author:
5 //   Gert Driesen (drieseng@users.sourceforge.net)
6 //
7 // (C) 2005 Novell
8 // 
9
10 using System;
11 using System.Collections;
12 using System.Globalization;
13 using System.IO;
14 using System.Xml;
15 using System.Xml.Schema;
16 using System.Xml.Serialization;
17
18 using NUnit.Framework;
19
20 using MonoTests.System.Xml.TestClasses;
21
22 namespace MonoTests.System.XmlSerialization
23 {
24         [TestFixture]
25         public class XmlSchemaExporterTests
26         {
27                 private XmlSchemas Export (Type type)
28                 {
29                         return Export (type, string.Empty);
30                 }
31
32                 private XmlSchemas Export (Type type, string defaultNamespace)
33                 {
34                         XmlReflectionImporter ri = new XmlReflectionImporter (defaultNamespace);
35                         XmlSchemas schemas = new XmlSchemas ();
36                         XmlSchemaExporter sx = new XmlSchemaExporter (schemas);
37                         XmlTypeMapping tm = ri.ImportTypeMapping (type);
38                         sx.ExportTypeMapping (tm);
39                         return schemas;
40                 }
41
42                 private XmlSchemas Export (Type type, XmlAttributeOverrides overrides)
43                 {
44                         return Export (type, overrides, string.Empty);
45                 }
46
47                 private XmlSchemas Export (Type type, XmlAttributeOverrides overrides, string defaultNamespace)
48                 {
49                         XmlReflectionImporter ri = new XmlReflectionImporter (overrides, defaultNamespace);
50                         XmlSchemas schemas = new XmlSchemas ();
51                         XmlSchemaExporter sx = new XmlSchemaExporter (schemas);
52                         XmlTypeMapping tm = ri.ImportTypeMapping (type);
53                         sx.ExportTypeMapping (tm);
54                         return schemas;
55                 }
56
57                 [Test]
58                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
59                 public void ExportStruct ()
60                 {
61                         XmlSchemas schemas = Export (typeof (TimeSpan), "NSTimeSpan");
62                         Assert.AreEqual (1, schemas.Count, "#1");
63
64                         StringWriter sw = new StringWriter ();
65                         schemas[0].Write (sw);
66
67                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
68                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
69                                 "<xs:schema xmlns:tns=\"NSTimeSpan\" elementFormDefault=\"qualified\" targetNamespace=\"NSTimeSpan\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
70                                 "  <xs:element name=\"TimeSpan\" type=\"tns:TimeSpan\" />{0}" +
71                                 "  <xs:complexType name=\"TimeSpan\" />{0}" +
72                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
73
74                         schemas = Export (typeof (TimeSpan));
75                         Assert.AreEqual (1, schemas.Count, "#3");
76
77                         sw.GetStringBuilder ().Length = 0;
78                         schemas[0].Write (sw);
79
80                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
81                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
82                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
83                                 "  <xs:element name=\"TimeSpan\" type=\"TimeSpan\" />{0}" +
84                                 "  <xs:complexType name=\"TimeSpan\" />{0}" +
85                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
86                 }
87
88                 [Test]
89                 [Category ("NotDotNet")] // Mono bug ##77117
90                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
91                 public void ExportStruct_Array ()
92                 {
93                         XmlSchemas schemas = Export (typeof (TimeSpan[]), "NSTimeSpanArray");
94                         Assert.AreEqual (1, schemas.Count, "#1");
95
96                         StringWriter sw = new StringWriter ();
97                         schemas[0].Write (sw);
98
99                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
100                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
101                                 "<xs:schema xmlns:tns=\"NSTimeSpanArray\" elementFormDefault=\"qualified\" targetNamespace=\"NSTimeSpanArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
102                                 "  <xs:element name=\"ArrayOfTimeSpan\" type=\"tns:ArrayOfTimeSpan\" />{0}" +
103                                 "  <xs:complexType name=\"ArrayOfTimeSpan\">{0}" +
104                                 "    <xs:sequence>{0}" +
105                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"TimeSpan\" nillable=\"true\" type=\"tns:TimeSpan\" />{0}" +
106                                 "    </xs:sequence>{0}" +
107                                 "  </xs:complexType>{0}" +
108                                 "  <xs:complexType name=\"TimeSpan\" />{0}" +
109                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
110
111                         schemas = Export (typeof (TimeSpan[]));
112                         Assert.AreEqual (1, schemas.Count, "#3");
113
114                         sw.GetStringBuilder ().Length = 0;
115                         schemas[0].Write (sw);
116
117                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
118                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
119                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
120                                 "  <xs:element name=\"ArrayOfTimeSpan\" type=\"ArrayOfTimeSpan\" />{0}" +
121                                 "  <xs:complexType name=\"ArrayOfTimeSpan\">{0}" +
122                                 "    <xs:sequence>{0}" +
123                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"TimeSpan\" nillable=\"true\" type=\"TimeSpan\" />{0}" +
124                                 "    </xs:sequence>{0}" +
125                                 "  </xs:complexType>{0}" +
126                                 "  <xs:complexType name=\"TimeSpan\" />{0}" +
127                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
128                 }
129
130                 [Test]
131                 [Category ("NotDotNet")] // Mono bug ##77117
132                 public void ExportClass_SimpleClass ()
133                 {
134                         XmlAttributeOverrides overrides = new XmlAttributeOverrides ();
135                         XmlAttributes attr = new XmlAttributes ();
136                         XmlElementAttribute element = new XmlElementAttribute ();
137                         element.ElementName = "saying";
138                         element.IsNullable = true;
139                         attr.XmlElements.Add (element);
140                         overrides.Add (typeof (SimpleClass), "something", attr);
141
142                         XmlSchemas schemas = Export (typeof (SimpleClass), overrides, "NSSimpleClass");
143                         Assert.AreEqual (1, schemas.Count, "#1");
144
145                         StringWriter sw = new StringWriter ();
146                         schemas[0].Write (sw);
147
148                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
149                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
150                                 "<xs:schema xmlns:tns=\"NSSimpleClass\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
151                                 "  <xs:element name=\"SimpleClass\" type=\"tns:SimpleClass\" />{0}" +
152                                 "  <xs:complexType name=\"SimpleClass\">{0}" +
153                                 "    <xs:sequence>{0}" +
154                                 "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
155                                 "    </xs:sequence>{0}" +
156                                 "  </xs:complexType>{0}" +
157                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
158
159                         schemas = Export (typeof (SimpleClass), overrides);
160                         Assert.AreEqual (1, schemas.Count, "#3");
161
162                         sw.GetStringBuilder ().Length = 0;
163                         schemas[0].Write (sw);
164
165                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
166                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
167                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
168                                 "  <xs:element name=\"SimpleClass\" type=\"SimpleClass\" />{0}" +
169                                 "  <xs:complexType name=\"SimpleClass\">{0}" +
170                                 "    <xs:sequence>{0}" +
171                                 "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
172                                 "    </xs:sequence>{0}" +
173                                 "  </xs:complexType>{0}" +
174                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
175                 }
176
177                 [Test]
178                 [Category ("NotDotNet")] // Mono bug ##77117
179                 public void ExportClass_StringCollection ()
180                 {
181                         XmlSchemas schemas = Export (typeof (StringCollection), "NSStringCollection");
182                         Assert.AreEqual (1, schemas.Count, "#1");
183
184                         StringWriter sw = new StringWriter ();
185                         schemas[0].Write (sw);
186
187                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
188                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
189                                 "<xs:schema xmlns:tns=\"NSStringCollection\" elementFormDefault=\"qualified\" targetNamespace=\"NSStringCollection\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
190                                 "  <xs:element name=\"ArrayOfString\" type=\"tns:ArrayOfString\" />{0}" +
191                                 "  <xs:complexType name=\"ArrayOfString\">{0}" +
192                                 "    <xs:sequence>{0}" +
193                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"string\" nillable=\"true\" type=\"xs:string\" />{0}" +
194                                 "    </xs:sequence>{0}" +
195                                 "  </xs:complexType>{0}" +
196                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
197
198                         schemas = Export (typeof (StringCollection));
199                         Assert.AreEqual (1, schemas.Count, "#3");
200
201                         sw.GetStringBuilder ().Length = 0;
202                         schemas[0].Write (sw);
203
204                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
205                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
206                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
207                                 "  <xs:element name=\"ArrayOfString\" type=\"ArrayOfString\" />{0}" +
208                                 "  <xs:complexType name=\"ArrayOfString\">{0}" +
209                                 "    <xs:sequence>{0}" +
210                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"string\" nillable=\"true\" type=\"xs:string\" />{0}" +
211                                 "    </xs:sequence>{0}" +
212                                 "  </xs:complexType>{0}" +
213                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
214                 }
215
216                 [Test]
217                 [Category ("NotDotNet")] // Mono bug ##77117
218                 public void ExportClass_StringCollectionContainer ()
219                 {
220                         XmlSchemas schemas = Export (typeof (StringCollectionContainer), "NSStringCollectionContainer");
221                         Assert.AreEqual (1, schemas.Count, "#1");
222
223                         StringWriter sw = new StringWriter ();
224                         schemas[0].Write (sw);
225
226                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
227                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
228                                 "<xs:schema xmlns:tns=\"NSStringCollectionContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSStringCollectionContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
229                                 "  <xs:element name=\"StringCollectionContainer\" type=\"tns:StringCollectionContainer\" />{0}" +
230                                 "  <xs:complexType name=\"StringCollectionContainer\">{0}" +
231                                 "    <xs:sequence>{0}" +
232                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Messages\" type=\"tns:ArrayOfString\" />{0}" +
233                                 "    </xs:sequence>{0}" +
234                                 "  </xs:complexType>{0}" +
235                                 "  <xs:complexType name=\"ArrayOfString\">{0}" +
236                                 "    <xs:sequence>{0}" +
237                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"string\" nillable=\"true\" type=\"xs:string\" />{0}" +
238                                 "    </xs:sequence>{0}" +
239                                 "  </xs:complexType>{0}" +
240                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
241
242                         schemas = Export (typeof (StringCollectionContainer));
243                         Assert.AreEqual (1, schemas.Count, "#3");
244
245                         sw.GetStringBuilder ().Length = 0;
246                         schemas[0].Write (sw);
247
248                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
249                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
250                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
251                                 "  <xs:element name=\"StringCollectionContainer\" type=\"StringCollectionContainer\" />{0}" +
252                                 "  <xs:complexType name=\"StringCollectionContainer\">{0}" +
253                                 "    <xs:sequence>{0}" +
254                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Messages\" type=\"ArrayOfString\" />{0}" +
255                                 "    </xs:sequence>{0}" +
256                                 "  </xs:complexType>{0}" +
257                                 "  <xs:complexType name=\"ArrayOfString\">{0}" +
258                                 "    <xs:sequence>{0}" +
259                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"string\" nillable=\"true\" type=\"xs:string\" />{0}" +
260                                 "    </xs:sequence>{0}" +
261                                 "  </xs:complexType>{0}" +
262                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
263                 }
264
265                 [Test]
266                 [Category ("NotDotNet")] // Mono bug ##77117
267                 public void ExportClass_ArrayContainer ()
268                 {
269                         XmlSchemas schemas = Export (typeof (ArrayContainer), "NSArrayContainer");
270                         Assert.AreEqual (1, schemas.Count, "#1");
271
272                         StringWriter sw = new StringWriter ();
273                         schemas[0].Write (sw);
274
275                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
276                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
277                                 "<xs:schema xmlns:tns=\"NSArrayContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSArrayContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
278                                 "  <xs:element name=\"ArrayContainer\" type=\"tns:ArrayContainer\" />{0}" +
279                                 "  <xs:complexType name=\"ArrayContainer\">{0}" +
280                                 "    <xs:sequence>{0}" +
281                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"items\" type=\"tns:ArrayOfAnyType\" />{0}" +
282                                 "    </xs:sequence>{0}" +
283                                 "  </xs:complexType>{0}" +
284                                 "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
285                                 "    <xs:sequence>{0}" +
286                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
287                                 "    </xs:sequence>{0}" +
288                                 "  </xs:complexType>{0}" +
289                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
290
291                         schemas = Export (typeof (ArrayContainer));
292                         Assert.AreEqual (1, schemas.Count, "#3");
293
294                         sw.GetStringBuilder ().Length = 0;
295                         schemas[0].Write (sw);
296
297                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
298                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
299                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
300                                 "  <xs:element name=\"ArrayContainer\" type=\"ArrayContainer\" />{0}" +
301                                 "  <xs:complexType name=\"ArrayContainer\">{0}" +
302                                 "    <xs:sequence>{0}" +
303                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"items\" type=\"ArrayOfAnyType\" />{0}" +
304                                 "    </xs:sequence>{0}" +
305                                 "  </xs:complexType>{0}" +
306                                 "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
307                                 "    <xs:sequence>{0}" +
308                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
309                                 "    </xs:sequence>{0}" +
310                                 "  </xs:complexType>{0}" +
311                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
312                 }
313
314                 [Test]
315                 [Category ("NotDotNet")] // Mono bug ##77117
316                 public void ExportClass_ClassArrayContainer ()
317                 {
318                         XmlSchemas schemas = Export (typeof (ClassArrayContainer), "NSClassArrayContainer");
319                         Assert.AreEqual (1, schemas.Count, "#1");
320
321                         StringWriter sw = new StringWriter ();
322                         schemas[0].Write (sw);
323
324                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
325                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
326                                 "<xs:schema xmlns:tns=\"NSClassArrayContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSClassArrayContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
327                                 "  <xs:element name=\"ClassArrayContainer\" type=\"tns:ClassArrayContainer\" />{0}" +
328                                 "  <xs:complexType name=\"ClassArrayContainer\">{0}" +
329                                 "    <xs:sequence>{0}" +
330                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"items\" type=\"tns:ArrayOfSimpleClass\" />{0}" +
331                                 "    </xs:sequence>{0}" +
332                                 "  </xs:complexType>{0}" +
333                                 "  <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
334                                 "    <xs:sequence>{0}" +
335                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"SimpleClass\" nillable=\"true\" type=\"tns:SimpleClass\" />{0}" +
336                                 "    </xs:sequence>{0}" +
337                                 "  </xs:complexType>{0}" +
338                                 "  <xs:complexType name=\"SimpleClass\">{0}" +
339                                 "    <xs:sequence>{0}" +
340                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"something\" type=\"xs:string\" />{0}" +
341                                 "    </xs:sequence>{0}" +
342                                 "  </xs:complexType>{0}" +
343                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
344
345                         schemas = Export (typeof (ClassArrayContainer));
346                         Assert.AreEqual (1, schemas.Count, "#3");
347
348                         sw.GetStringBuilder ().Length = 0;
349                         schemas[0].Write (sw);
350
351                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
352                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
353                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
354                                 "  <xs:element name=\"ClassArrayContainer\" type=\"ClassArrayContainer\" />{0}" +
355                                 "  <xs:complexType name=\"ClassArrayContainer\">{0}" +
356                                 "    <xs:sequence>{0}" +
357                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"items\" type=\"ArrayOfSimpleClass\" />{0}" +
358                                 "    </xs:sequence>{0}" +
359                                 "  </xs:complexType>{0}" +
360                                 "  <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
361                                 "    <xs:sequence>{0}" +
362                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"SimpleClass\" nillable=\"true\" type=\"SimpleClass\" />{0}" +
363                                 "    </xs:sequence>{0}" +
364                                 "  </xs:complexType>{0}" +
365                                 "  <xs:complexType name=\"SimpleClass\">{0}" +
366                                 "    <xs:sequence>{0}" +
367                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"something\" type=\"xs:string\" />{0}" +
368                                 "    </xs:sequence>{0}" +
369                                 "  </xs:complexType>{0}" +
370                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
371                 }
372
373                 [Test]
374                 [Category ("NotDotNet")] // Mono bug ##77117
375                 public void ExportClass_SimpleClassWithXmlAttributes ()
376                 {
377                         XmlSchemas schemas = Export (typeof (SimpleClassWithXmlAttributes), "NSSimpleClassWithXmlAttributes");
378                         Assert.AreEqual (1, schemas.Count, "#1");
379
380                         StringWriter sw = new StringWriter ();
381                         schemas[0].Write (sw);
382
383                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
384                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
385                                 "<xs:schema xmlns:tns=\"NSSimpleClassWithXmlAttributes\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClassWithXmlAttributes\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
386                                 "  <xs:element name=\"simple\" type=\"tns:SimpleClassWithXmlAttributes\" />{0}" +
387                                 "  <xs:complexType name=\"SimpleClassWithXmlAttributes\">{0}" +
388                                 "    <xs:attribute name=\"member\" type=\"xs:string\" />{0}" +
389                                 "  </xs:complexType>{0}" +
390                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
391
392                         schemas = Export (typeof (SimpleClassWithXmlAttributes));
393                         Assert.AreEqual (1, schemas.Count, "#3");
394
395                         sw.GetStringBuilder ().Length = 0;
396                         schemas[0].Write (sw);
397
398                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
399                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
400                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
401                                 "  <xs:element name=\"simple\" type=\"SimpleClassWithXmlAttributes\" />{0}" +
402                                 "  <xs:complexType name=\"SimpleClassWithXmlAttributes\">{0}" +
403                                 "    <xs:attribute name=\"member\" type=\"xs:string\" />{0}" +
404                                 "  </xs:complexType>{0}" +
405                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
406                 }
407
408                 [Test]
409                 [Category ("NotDotNet")] // Mono does not translate default values to corresponding enum fields
410                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
411                 public void ExportClass_Field ()
412                 {
413                         XmlSchemas schemas = Export (typeof (Field), "NSField");
414                         Assert.AreEqual (1, schemas.Count, "#1");
415
416                         StringWriter sw = new StringWriter ();
417                         schemas[0].Write (sw);
418
419                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
420                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
421                                 "<xs:schema xmlns:tns=\"NSField\" elementFormDefault=\"qualified\" targetNamespace=\"NSField\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
422                                 "  <xs:element name=\"field\" type=\"tns:Field\" />{0}" +
423                                 "  <xs:complexType name=\"Field\">{0}" +
424                                 "    <xs:attribute name=\"modifiers\" type=\"tns:MapModifiers\" use=\"required\" />{0}" +
425                                 "    <xs:attribute form=\"unqualified\" name=\"modifiers2\" type=\"tns:MapModifiers\" use=\"required\" />{0}" +
426                                 "    <xs:attribute default=\"0\" name=\"modifiers3\" type=\"tns:MapModifiers\" />{0}" +
427                                 "    <xs:attribute default=\"0\" form=\"unqualified\" name=\"modifiers4\" type=\"tns:MapModifiers\" />{0}" +
428                                 "    <xs:attribute name=\"names\">{0}" +
429                                 "      <xs:simpleType>{0}" +
430                                 "        <xs:list itemType=\"xs:string\" />{0}" +
431                                 "      </xs:simpleType>{0}" +
432                                 "    </xs:attribute>{0}" +
433                                 "    <xs:attribute name=\"street\" type=\"xs:string\" />{0}" +
434                                 "  </xs:complexType>{0}" +
435                                 "  <xs:simpleType name=\"MapModifiers\">{0}" +
436                                 "    <xs:list>{0}" +
437                                 "      <xs:simpleType>{0}" +
438                                 "        <xs:restriction base=\"xs:string\">{0}" +
439                                 "          <xs:enumeration value=\"public\" />{0}" +
440                                 "          <xs:enumeration value=\"protected\" />{0}" +
441                                 "        </xs:restriction>{0}" +
442                                 "      </xs:simpleType>{0}" +
443                                 "    </xs:list>{0}" +
444                                 "  </xs:simpleType>{0}" +
445                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
446
447                         schemas = Export (typeof (Field));
448                         Assert.AreEqual (1, schemas.Count, "#3");
449
450                         sw.GetStringBuilder ().Length = 0;
451                         schemas[0].Write (sw);
452
453                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
454                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
455                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
456                                 "  <xs:element name=\"field\" type=\"Field\" />{0}" +
457                                 "  <xs:complexType name=\"Field\">{0}" +
458                                 "    <xs:attribute name=\"modifiers\" type=\"MapModifiers\" use=\"required\" />{0}" +
459                                 "    <xs:attribute form=\"unqualified\" name=\"modifiers2\" type=\"MapModifiers\" use=\"required\" />{0}" +
460                                 "    <xs:attribute default=\"0\" name=\"modifiers3\" type=\"MapModifiers\" />{0}" +
461                                 "    <xs:attribute default=\"0\" form=\"unqualified\" name=\"modifiers4\" type=\"MapModifiers\" />{0}" +
462                                 "    <xs:attribute name=\"names\">{0}" +
463                                 "      <xs:simpleType>{0}" +
464                                 "        <xs:list itemType=\"xs:string\" />{0}" +
465                                 "      </xs:simpleType>{0}" +
466                                 "    </xs:attribute>{0}" +
467                                 "    <xs:attribute name=\"street\" type=\"xs:string\" />{0}" +
468                                 "  </xs:complexType>{0}" +
469                                 "  <xs:simpleType name=\"MapModifiers\">{0}" +
470                                 "    <xs:list>{0}" +
471                                 "      <xs:simpleType>{0}" +
472                                 "        <xs:restriction base=\"xs:string\">{0}" +
473                                 "          <xs:enumeration value=\"public\" />{0}" +
474                                 "          <xs:enumeration value=\"protected\" />{0}" +
475                                 "        </xs:restriction>{0}" +
476                                 "      </xs:simpleType>{0}" +
477                                 "    </xs:list>{0}" +
478                                 "  </xs:simpleType>{0}" +
479                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
480                 }
481
482                 [Test]
483                 [Category ("NotDotNet")] // Mono bug ##77117
484                 public void ExportClass_MyList ()
485                 {
486                         XmlSchemas schemas = Export (typeof (MyList), "NSMyList");
487                         Assert.AreEqual (1, schemas.Count, "#1");
488
489                         StringWriter sw = new StringWriter ();
490                         schemas[0].Write (sw);
491
492                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
493                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
494                                 "<xs:schema xmlns:tns=\"NSMyList\" elementFormDefault=\"qualified\" targetNamespace=\"NSMyList\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
495                                 "  <xs:element name=\"ArrayOfAnyType\" type=\"tns:ArrayOfAnyType\" />{0}" +
496                                 "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
497                                 "    <xs:sequence>{0}" +
498                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
499                                 "    </xs:sequence>{0}" +
500                                 "  </xs:complexType>{0}" +
501                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
502
503                         schemas = Export (typeof (MyList));
504                         Assert.AreEqual (1, schemas.Count, "#3");
505
506                         sw.GetStringBuilder ().Length = 0;
507                         schemas[0].Write (sw);
508
509                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
510                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
511                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
512                                 "  <xs:element name=\"ArrayOfAnyType\" type=\"ArrayOfAnyType\" />{0}" +
513                                 "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
514                                 "    <xs:sequence>{0}" +
515                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
516                                 "    </xs:sequence>{0}" +
517                                 "  </xs:complexType>{0}" +
518                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
519                 }
520
521                 [Test]
522                 [Category ("NotDotNet")] // Mono bug ##77117
523                 public void ExportClass_Container ()
524                 {
525                         XmlSchemas schemas = Export (typeof (Container), "NSContainer");
526                         Assert.AreEqual (1, schemas.Count, "#1");
527
528                         StringWriter sw = new StringWriter ();
529                         schemas[0].Write (sw);
530
531                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
532                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
533                                 "<xs:schema xmlns:tns=\"NSContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
534                                 "  <xs:element name=\"Container\" type=\"tns:Container\" />{0}" +
535                                 "  <xs:complexType name=\"Container\">{0}" +
536                                 "    <xs:sequence>{0}" +
537                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Items\" type=\"tns:ArrayOfAnyType\" />{0}" +
538                                 "    </xs:sequence>{0}" +
539                                 "  </xs:complexType>{0}" +
540                                 "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
541                                 "    <xs:sequence>{0}" +
542                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
543                                 "    </xs:sequence>{0}" +
544                                 "  </xs:complexType>{0}" +
545                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
546
547                         schemas = Export (typeof (Container));
548                         Assert.AreEqual (1, schemas.Count, "#3");
549
550                         sw.GetStringBuilder ().Length = 0;
551                         schemas[0].Write (sw);
552
553                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
554                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
555                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
556                                 "  <xs:element name=\"Container\" type=\"Container\" />{0}" +
557                                 "  <xs:complexType name=\"Container\">{0}" +
558                                 "    <xs:sequence>{0}" +
559                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Items\" type=\"ArrayOfAnyType\" />{0}" +
560                                 "    </xs:sequence>{0}" +
561                                 "  </xs:complexType>{0}" +
562                                 "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
563                                 "    <xs:sequence>{0}" +
564                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
565                                 "    </xs:sequence>{0}" +
566                                 "  </xs:complexType>{0}" +
567                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
568                 }
569
570                 [Test]
571                 [Category ("NotDotNet")] // Mono bug ##77117
572                 public void ExportClass_Container2 ()
573                 {
574                         XmlSchemas schemas = Export (typeof (Container2), "NSContainer2");
575                         Assert.AreEqual (1, schemas.Count, "#1");
576
577                         StringWriter sw = new StringWriter ();
578                         schemas[0].Write (sw);
579
580                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
581                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
582                                 "<xs:schema xmlns:tns=\"NSContainer2\" elementFormDefault=\"qualified\" targetNamespace=\"NSContainer2\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
583                                 "  <xs:element name=\"Container2\" type=\"tns:Container2\" />{0}" +
584                                 "  <xs:complexType name=\"Container2\">{0}" +
585                                 "    <xs:sequence>{0}" +
586                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Items\" type=\"tns:ArrayOfAnyType\" />{0}" +
587                                 "    </xs:sequence>{0}" +
588                                 "  </xs:complexType>{0}" +
589                                 "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
590                                 "    <xs:sequence>{0}" +
591                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
592                                 "    </xs:sequence>{0}" +
593                                 "  </xs:complexType>{0}" +
594                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
595
596                         schemas = Export (typeof (Container2));
597                         Assert.AreEqual (1, schemas.Count, "#3");
598
599                         sw.GetStringBuilder ().Length = 0;
600                         schemas[0].Write (sw);
601
602                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
603                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
604                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
605                                 "  <xs:element name=\"Container2\" type=\"Container2\" />{0}" +
606                                 "  <xs:complexType name=\"Container2\">{0}" +
607                                 "    <xs:sequence>{0}" +
608                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Items\" type=\"ArrayOfAnyType\" />{0}" +
609                                 "    </xs:sequence>{0}" +
610                                 "  </xs:complexType>{0}" +
611                                 "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
612                                 "    <xs:sequence>{0}" +
613                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
614                                 "    </xs:sequence>{0}" +
615                                 "  </xs:complexType>{0}" +
616                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
617                 }
618
619                 [Test]
620                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
621                 [ExpectedException (typeof (InvalidOperationException))] // Cannot use wildcards at the top level of a schema.
622                 public void ExportClass_MyElem ()
623                 {
624                         Export (typeof (MyElem), "NSMyElem");
625                 }
626
627                 [Test]
628                 [Category ("NotDotNet")] // Mono bug ##77117
629                 public void ExportClass_CDataContainer ()
630                 {
631                         XmlSchemas schemas = Export (typeof (CDataContainer), "NSCDataContainer");
632                         Assert.AreEqual (1, schemas.Count, "#1");
633
634                         StringWriter sw = new StringWriter ();
635                         schemas[0].Write (sw);
636
637                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
638                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
639                                 "<xs:schema xmlns:tns=\"NSCDataContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSCDataContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
640                                 "  <xs:element name=\"CDataContainer\" type=\"tns:CDataContainer\" />{0}" +
641                                 "  <xs:complexType name=\"CDataContainer\">{0}" +
642                                 "    <xs:sequence>{0}" +
643                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"cdata\">{0}" +
644                                 "        <xs:complexType mixed=\"true\">{0}" +
645                                 "          <xs:sequence>{0}" +
646                                 "            <xs:any />{0}" +
647                                 "          </xs:sequence>{0}" +
648                                 "        </xs:complexType>{0}" +
649                                 "      </xs:element>{0}" +
650                                 "    </xs:sequence>{0}" +
651                                 "  </xs:complexType>{0}" +
652                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
653
654                         schemas = Export (typeof (CDataContainer));
655                         Assert.AreEqual (1, schemas.Count, "#3");
656
657                         sw.GetStringBuilder ().Length = 0;
658                         schemas[0].Write (sw);
659
660                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
661                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
662                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
663                                 "  <xs:element name=\"CDataContainer\" type=\"CDataContainer\" />{0}" +
664                                 "  <xs:complexType name=\"CDataContainer\">{0}" +
665                                 "    <xs:sequence>{0}" +
666                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"cdata\">{0}" +
667                                 "        <xs:complexType mixed=\"true\">{0}" +
668                                 "          <xs:sequence>{0}" +
669                                 "            <xs:any />{0}" +
670                                 "          </xs:sequence>{0}" +
671                                 "        </xs:complexType>{0}" +
672                                 "      </xs:element>{0}" +
673                                 "    </xs:sequence>{0}" +
674                                 "  </xs:complexType>{0}" +
675                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
676                 }
677
678                 [Test]
679                 [Category ("NotDotNet")] // Mono bug ##77117
680                 public void ExportClass_NodeContainer ()
681                 {
682                         XmlSchemas schemas = Export (typeof (NodeContainer), "NSNodeContainer");
683                         Assert.AreEqual (1, schemas.Count, "#1");
684
685                         StringWriter sw = new StringWriter ();
686                         schemas[0].Write (sw);
687
688                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
689                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
690                                 "<xs:schema xmlns:tns=\"NSNodeContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSNodeContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
691                                 "  <xs:element name=\"NodeContainer\" type=\"tns:NodeContainer\" />{0}" +
692                                 "  <xs:complexType name=\"NodeContainer\">{0}" +
693                                 "    <xs:sequence>{0}" +
694                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"node\">{0}" +
695                                 "        <xs:complexType mixed=\"true\">{0}" +
696                                 "          <xs:sequence>{0}" +
697                                 "            <xs:any />{0}" +
698                                 "          </xs:sequence>{0}" +
699                                 "        </xs:complexType>{0}" +
700                                 "      </xs:element>{0}" +
701                                 "    </xs:sequence>{0}" +
702                                 "  </xs:complexType>{0}" +
703                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
704
705                         schemas = Export (typeof (NodeContainer));
706                         Assert.AreEqual (1, schemas.Count, "#3");
707
708                         sw.GetStringBuilder ().Length = 0;
709                         schemas[0].Write (sw);
710
711                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
712                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
713                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
714                                 "  <xs:element name=\"NodeContainer\" type=\"NodeContainer\" />{0}" +
715                                 "  <xs:complexType name=\"NodeContainer\">{0}" +
716                                 "    <xs:sequence>{0}" +
717                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"node\">{0}" +
718                                 "        <xs:complexType mixed=\"true\">{0}" +
719                                 "          <xs:sequence>{0}" +
720                                 "            <xs:any />{0}" +
721                                 "          </xs:sequence>{0}" +
722                                 "        </xs:complexType>{0}" +
723                                 "      </xs:element>{0}" +
724                                 "    </xs:sequence>{0}" +
725                                 "  </xs:complexType>{0}" +
726                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
727                 }
728
729                 [Test]
730                 [Category ("NotWorking")] // Mono does not generate the <xs:choice> node
731                 [Category ("NotDotNet")] // Mono bug ##77117 and MS.NET randomly modifies the order of the elements!
732                 public void ExportClass_Choices ()
733                 {
734                         XmlSchemas schemas = Export (typeof (Choices), "NSChoices");
735                         Assert.AreEqual (1, schemas.Count, "#1");
736
737                         StringWriter sw = new StringWriter ();
738                         schemas[0].Write (sw);
739
740                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
741                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
742                                 "<xs:schema xmlns:tns=\"NSChoices\" elementFormDefault=\"qualified\" targetNamespace=\"NSChoices\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
743                                 "  <xs:element name=\"Choices\" type=\"tns:Choices\" />{0}" +
744                                 "  <xs:complexType name=\"Choices\">{0}" +
745                                 "    <xs:sequence>{0}" +
746                                 "      <xs:choice minOccurs=\"1\" maxOccurs=\"1\">{0}" +
747                                 "        <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"ChoiceOne\" type=\"xs:string\" />{0}" +
748                                 "        <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"ChoiceTwo\" type=\"xs:string\" />{0}" +
749                                 "        <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"ChoiceZero\" type=\"xs:string\" />{0}" +
750                                 "      </xs:choice>{0}" +
751                                 "    </xs:sequence>{0}" +
752                                 "  </xs:complexType>{0}" +
753                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
754
755                         schemas = Export (typeof (Choices));
756                         Assert.AreEqual (1, schemas.Count, "#3");
757
758                         sw.GetStringBuilder ().Length = 0;
759                         schemas[0].Write (sw);
760
761                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
762                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
763                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
764                                 "  <xs:element name=\"Choices\" type=\"Choices\" />{0}" +
765                                 "  <xs:complexType name=\"Choices\">{0}" +
766                                 "    <xs:sequence>{0}" +
767                                 "      <xs:choice minOccurs=\"1\" maxOccurs=\"1\">{0}" +
768                                 "        <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"ChoiceOne\" type=\"xs:string\" />{0}" +
769                                 "        <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"ChoiceTwo\" type=\"xs:string\" />{0}" +
770                                 "        <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"ChoiceZero\" type=\"xs:string\" />{0}" +
771                                 "      </xs:choice>{0}" +
772                                 "    </xs:sequence>{0}" +
773                                 "  </xs:complexType>{0}" +
774                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
775                 }
776
777                 [Test]
778                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
779 #if ONLY_1_1
780                 [Category ("NotDotNet")] // MS.NET 1.x does not escape spaces in a type name, bug is fixed in .NET 2.0
781 #else
782                 [Category ("NotDotNet")] // Mono bug ##77117
783 #endif
784                 public void ExportClass_TestSpace ()
785                 {
786                         XmlSchemas schemas = Export (typeof (TestSpace), "NSTestSpace");
787                         Assert.AreEqual (1, schemas.Count, "#1");
788
789                         StringWriter sw = new StringWriter ();
790                         schemas[0].Write (sw);
791
792                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
793                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
794                                 "<xs:schema xmlns:tns=\"NSTestSpace\" elementFormDefault=\"qualified\" targetNamespace=\"NSTestSpace\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
795                                 "  <xs:element name=\"Type_x0020_with_x0020_space\" type=\"tns:Type_x0020_with_x0020_space\" />{0}" +
796                                 "  <xs:complexType name=\"Type_x0020_with_x0020_space\">{0}" +
797                                 "    <xs:sequence>{0}" +
798                                 "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Element_x0020_with_x0020_space\" type=\"xs:int\" />{0}" +
799                                 "    </xs:sequence>{0}" +
800                                 "    <xs:attribute name=\"Attribute_x0020_with_x0020_space\" type=\"xs:int\" use=\"required\" />{0}" +
801                                 "  </xs:complexType>{0}" +
802                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
803
804                         schemas = Export (typeof (TestSpace));
805                         Assert.AreEqual (1, schemas.Count, "#3");
806
807                         sw.GetStringBuilder ().Length = 0;
808                         schemas[0].Write (sw);
809
810                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
811                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
812                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
813                                 "  <xs:element name=\"Type_x0020_with_x0020_space\" type=\"Type_x0020_with_x0020_space\" />{0}" +
814                                 "  <xs:complexType name=\"Type_x0020_with_x0020_space\">{0}" +
815                                 "    <xs:sequence>{0}" +
816                                 "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Element_x0020_with_x0020_space\" type=\"xs:int\" />{0}" +
817                                 "    </xs:sequence>{0}" +
818                                 "    <xs:attribute name=\"Attribute_x0020_with_x0020_space\" type=\"xs:int\" use=\"required\" />{0}" +
819                                 "  </xs:complexType>{0}" +
820                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
821                 }
822
823                 [Test]
824                 [Category ("NotDotNet")] // Mono bug ##77117
825                 public void ExportClass_ReadOnlyProperties ()
826                 {
827                         XmlSchemas schemas = Export (typeof (ReadOnlyProperties), "NSReadOnlyProperties");
828                         Assert.AreEqual (1, schemas.Count, "#1");
829
830                         StringWriter sw = new StringWriter ();
831                         schemas[0].Write (sw);
832
833                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
834                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
835                                 "<xs:schema xmlns:tns=\"NSReadOnlyProperties\" elementFormDefault=\"qualified\" targetNamespace=\"NSReadOnlyProperties\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
836                                 "  <xs:element name=\"ReadOnlyProperties\" type=\"tns:ReadOnlyProperties\" />{0}" +
837                                 "  <xs:complexType name=\"ReadOnlyProperties\" />{0}" +
838                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
839
840                         schemas = Export (typeof (ReadOnlyProperties));
841                         Assert.AreEqual (1, schemas.Count, "#3");
842
843                         sw.GetStringBuilder ().Length = 0;
844                         schemas[0].Write (sw);
845
846                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
847                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
848                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
849                                 "  <xs:element name=\"ReadOnlyProperties\" type=\"ReadOnlyProperties\" />{0}" +
850                                 "  <xs:complexType name=\"ReadOnlyProperties\" />{0}" +
851                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
852                 }
853
854                 [Test]
855                 [Category ("NotDotNet")] // Mono bug ##77117
856                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
857                 public void ExportClass_ListDefaults ()
858                 {
859                         XmlSchemas schemas = Export (typeof (ListDefaults), "NSListDefaults");
860                         Assert.AreEqual (1, schemas.Count, "#1");
861
862                         StringWriter sw = new StringWriter ();
863                         schemas[0].Write (sw);
864
865                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
866                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
867                                 "<xs:schema xmlns:tns=\"NSListDefaults\" elementFormDefault=\"qualified\" targetNamespace=\"NSListDefaults\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
868                                 "  <xs:element name=\"root\" type=\"tns:ListDefaults\" />{0}" +
869                                 "  <xs:complexType name=\"ListDefaults\">{0}" +
870                                 "    <xs:sequence>{0}" +
871                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"list2\" type=\"tns:ArrayOfAnyType\" />{0}" +
872                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"list3\" type=\"tns:ArrayOfAnyType\" />{0}" +
873                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"list4\" type=\"tns:ArrayOfString\" />{0}" +
874                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"e\" type=\"tns:SimpleClass\" />{0}" +
875                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"ed\" type=\"tns:SimpleClass\" />{0}" +
876                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"str\" type=\"xs:string\" />{0}" +
877                                 "    </xs:sequence>{0}" +
878                                 "  </xs:complexType>{0}" +
879                                 "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
880                                 "    <xs:sequence>{0}" +
881                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
882                                 "    </xs:sequence>{0}" +
883                                 "  </xs:complexType>{0}" +
884                                 "  <xs:complexType name=\"ArrayOfString\">{0}" +
885                                 "    <xs:sequence>{0}" +
886                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"string\" nillable=\"true\" type=\"xs:string\" />{0}" +
887                                 "    </xs:sequence>{0}" +
888                                 "  </xs:complexType>{0}" +
889                                 "  <xs:complexType name=\"SimpleClass\">{0}" +
890                                 "    <xs:sequence>{0}" +
891                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"something\" type=\"xs:string\" />{0}" +
892                                 "    </xs:sequence>{0}" +
893                                 "  </xs:complexType>{0}" +
894                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
895
896                         schemas = Export (typeof (ListDefaults));
897                         Assert.AreEqual (1, schemas.Count, "#3");
898
899                         sw.GetStringBuilder ().Length = 0;
900                         schemas[0].Write (sw);
901
902                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
903                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
904                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
905                                 "  <xs:element name=\"root\" type=\"ListDefaults\" />{0}" +
906                                 "  <xs:complexType name=\"ListDefaults\">{0}" +
907                                 "    <xs:sequence>{0}" +
908                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"list2\" type=\"ArrayOfAnyType\" />{0}" +
909                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"list3\" type=\"ArrayOfAnyType\" />{0}" +
910                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"list4\" type=\"ArrayOfString\" />{0}" +
911                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"e\" type=\"SimpleClass\" />{0}" +
912                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"ed\" type=\"SimpleClass\" />{0}" +
913                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"str\" type=\"xs:string\" />{0}" +
914                                 "    </xs:sequence>{0}" +
915                                 "  </xs:complexType>{0}" +
916                                 "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
917                                 "    <xs:sequence>{0}" +
918                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
919                                 "    </xs:sequence>{0}" +
920                                 "  </xs:complexType>{0}" +
921                                 "  <xs:complexType name=\"ArrayOfString\">{0}" +
922                                 "    <xs:sequence>{0}" +
923                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"string\" nillable=\"true\" type=\"xs:string\" />{0}" +
924                                 "    </xs:sequence>{0}" +
925                                 "  </xs:complexType>{0}" +
926                                 "  <xs:complexType name=\"SimpleClass\">{0}" +
927                                 "    <xs:sequence>{0}" +
928                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"something\" type=\"xs:string\" />{0}" +
929                                 "    </xs:sequence>{0}" +
930                                 "  </xs:complexType>{0}" +
931                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
932                 }
933
934                 [Test]
935                 [Category ("NotDotNet")] // Mono bug ##77117
936                 public void ExportClass_ClsPerson ()
937                 {
938                         XmlSchemas schemas = Export (typeof (clsPerson), "NSClsPerson");
939                         Assert.AreEqual (1, schemas.Count, "#1");
940
941                         StringWriter sw = new StringWriter ();
942                         schemas[0].Write (sw);
943
944                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
945                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
946                                 "<xs:schema xmlns:tns=\"NSClsPerson\" elementFormDefault=\"qualified\" targetNamespace=\"NSClsPerson\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
947                                 "  <xs:element name=\"clsPerson\" type=\"tns:clsPerson\" />{0}" +
948                                 "  <xs:complexType name=\"clsPerson\">{0}" +
949                                 "    <xs:sequence>{0}" +
950                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"EmailAccounts\" type=\"tns:ArrayOfAnyType\" />{0}" +
951                                 "    </xs:sequence>{0}" +
952                                 "  </xs:complexType>{0}" +
953                                 "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
954                                 "    <xs:sequence>{0}" +
955                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
956                                 "    </xs:sequence>{0}" +
957                                 "  </xs:complexType>{0}" +
958                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
959
960                         schemas = Export (typeof (clsPerson));
961                         Assert.AreEqual (1, schemas.Count, "#3");
962
963                         sw.GetStringBuilder ().Length = 0;
964                         schemas[0].Write (sw);
965
966                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
967                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
968                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
969                                 "  <xs:element name=\"clsPerson\" type=\"clsPerson\" />{0}" +
970                                 "  <xs:complexType name=\"clsPerson\">{0}" +
971                                 "    <xs:sequence>{0}" +
972                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"EmailAccounts\" type=\"ArrayOfAnyType\" />{0}" +
973                                 "    </xs:sequence>{0}" +
974                                 "  </xs:complexType>{0}" +
975                                 "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
976                                 "    <xs:sequence>{0}" +
977                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
978                                 "    </xs:sequence>{0}" +
979                                 "  </xs:complexType>{0}" +
980                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
981                 }
982
983                 [Test]
984                 [Category ("NotDotNet")] // Mono bug ##77117
985                 public void ExportClass_ArrayClass ()
986                 {
987                         XmlSchemas schemas = Export (typeof (ArrayClass), "NSArrayClass");
988                         Assert.AreEqual (1, schemas.Count, "#1");
989
990                         StringWriter sw = new StringWriter ();
991                         schemas[0].Write (sw);
992
993                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
994                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
995                                 "<xs:schema xmlns:tns=\"NSArrayClass\" elementFormDefault=\"qualified\" targetNamespace=\"NSArrayClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
996                                 "  <xs:element name=\"ArrayClass\" type=\"tns:ArrayClass\" />{0}" +
997                                 "  <xs:complexType name=\"ArrayClass\">{0}" +
998                                 "    <xs:sequence>{0}" +
999                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"names\" />{0}" +
1000                                 "    </xs:sequence>{0}" +
1001                                 "  </xs:complexType>{0}" +
1002                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
1003
1004                         schemas = Export (typeof (ArrayClass));
1005                         Assert.AreEqual (1, schemas.Count, "#3");
1006
1007                         sw.GetStringBuilder ().Length = 0;
1008                         schemas[0].Write (sw);
1009
1010                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1011                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1012                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1013                                 "  <xs:element name=\"ArrayClass\" type=\"ArrayClass\" />{0}" +
1014                                 "  <xs:complexType name=\"ArrayClass\">{0}" +
1015                                 "    <xs:sequence>{0}" +
1016                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"names\" />{0}" +
1017                                 "    </xs:sequence>{0}" +
1018                                 "  </xs:complexType>{0}" +
1019                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
1020                 }
1021
1022                 [Test]
1023                 [Category ("NotDotNet")] // Mono bug ##77117
1024                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1025                 public void ExportClass_StructContainer ()
1026                 {
1027                         XmlSchemas schemas = Export (typeof (StructContainer), "NSStructContainer");
1028                         Assert.AreEqual (1, schemas.Count, "#1");
1029
1030                         StringWriter sw = new StringWriter ();
1031                         schemas[0].Write (sw);
1032
1033                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1034                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1035                                 "<xs:schema xmlns:tns=\"NSStructContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSStructContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1036                                 "  <xs:element name=\"StructContainer\" type=\"tns:StructContainer\" />{0}" +
1037                                 "  <xs:complexType name=\"StructContainer\">{0}" +
1038                                 "    <xs:sequence>{0}" +
1039                                 "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Value\" type=\"tns:EnumDefaultValue\" />{0}" +
1040                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Times\" type=\"tns:ArrayOfTimeSpan\" />{0}" +
1041                                 "    </xs:sequence>{0}" +
1042                                 "  </xs:complexType>{0}" +
1043                                 "  <xs:simpleType name=\"EnumDefaultValue\">{0}" +
1044                                 "    <xs:list>{0}" +
1045                                 "      <xs:simpleType>{0}" +
1046                                 "        <xs:restriction base=\"xs:string\">{0}" +
1047                                 "          <xs:enumeration value=\"e1\" />{0}" +
1048                                 "          <xs:enumeration value=\"e2\" />{0}" +
1049                                 "          <xs:enumeration value=\"e3\" />{0}" +
1050                                 "        </xs:restriction>{0}" +
1051                                 "      </xs:simpleType>{0}" +
1052                                 "    </xs:list>{0}" +
1053                                 "  </xs:simpleType>{0}" +
1054                                 "  <xs:complexType name=\"ArrayOfTimeSpan\">{0}" +
1055                                 "    <xs:sequence>{0}" +
1056                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"TimeSpan\" nillable=\"true\" type=\"tns:TimeSpan\" />{0}" +
1057                                 "    </xs:sequence>{0}" +
1058                                 "  </xs:complexType>{0}" +
1059                                 "  <xs:complexType name=\"TimeSpan\" />{0}" +
1060                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
1061
1062                         schemas = Export (typeof (StructContainer));
1063                         Assert.AreEqual (1, schemas.Count, "#3");
1064
1065                         sw.GetStringBuilder ().Length = 0;
1066                         schemas[0].Write (sw);
1067
1068                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1069                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1070                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1071                                 "  <xs:element name=\"StructContainer\" type=\"StructContainer\" />{0}" +
1072                                 "  <xs:complexType name=\"StructContainer\">{0}" +
1073                                 "    <xs:sequence>{0}" +
1074                                 "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"Value\" type=\"EnumDefaultValue\" />{0}" +
1075                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Times\" type=\"ArrayOfTimeSpan\" />{0}" +
1076                                 "    </xs:sequence>{0}" +
1077                                 "  </xs:complexType>{0}" +
1078                                 "  <xs:simpleType name=\"EnumDefaultValue\">{0}" +
1079                                 "    <xs:list>{0}" +
1080                                 "      <xs:simpleType>{0}" +
1081                                 "        <xs:restriction base=\"xs:string\">{0}" +
1082                                 "          <xs:enumeration value=\"e1\" />{0}" +
1083                                 "          <xs:enumeration value=\"e2\" />{0}" +
1084                                 "          <xs:enumeration value=\"e3\" />{0}" +
1085                                 "        </xs:restriction>{0}" +
1086                                 "      </xs:simpleType>{0}" +
1087                                 "    </xs:list>{0}" +
1088                                 "  </xs:simpleType>{0}" +
1089                                 "  <xs:complexType name=\"ArrayOfTimeSpan\">{0}" +
1090                                 "    <xs:sequence>{0}" +
1091                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"TimeSpan\" nillable=\"true\" type=\"TimeSpan\" />{0}" +
1092                                 "    </xs:sequence>{0}" +
1093                                 "  </xs:complexType>{0}" +
1094                                 "  <xs:complexType name=\"TimeSpan\" />{0}" +
1095                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
1096                 }
1097
1098                 [Test]
1099                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1100                 [ExpectedException (typeof (InvalidOperationException))] // Cannot use wildcards at the top level of a schema.
1101                 public void ExportClass_XmlElement ()
1102                 {
1103                         XmlSchemas schemas = Export (typeof (XmlElement), "NS1");
1104                 }
1105
1106                 [Test]
1107                 [Category ("NotDotNet")] // Mono bug ##77117
1108                 public void ExportClass_Array ()
1109                 {
1110                         XmlAttributeOverrides overrides = new XmlAttributeOverrides ();
1111                         XmlAttributes attr = new XmlAttributes ();
1112                         XmlElementAttribute element = new XmlElementAttribute ();
1113                         element.ElementName = "saying";
1114                         element.IsNullable = true;
1115                         attr.XmlElements.Add (element);
1116                         overrides.Add (typeof (SimpleClass), "something", attr);
1117
1118                         XmlSchemas schemas = Export (typeof (SimpleClass[]), overrides, "NSSimpleClassArray");
1119                         Assert.AreEqual (1, schemas.Count, "#1");
1120
1121                         StringWriter sw = new StringWriter ();
1122                         schemas[0].Write (sw);
1123
1124                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1125                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1126                                 "<xs:schema xmlns:tns=\"NSSimpleClassArray\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1127                                 "  <xs:element name=\"ArrayOfSimpleClass\" type=\"tns:ArrayOfSimpleClass\" />{0}" +
1128                                 "  <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
1129                                 "    <xs:sequence>{0}" +
1130                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"SimpleClass\" nillable=\"true\" type=\"tns:SimpleClass\" />{0}" +
1131                                 "    </xs:sequence>{0}" +
1132                                 "  </xs:complexType>{0}" +
1133                                 "  <xs:complexType name=\"SimpleClass\">{0}" +
1134                                 "    <xs:sequence>{0}" +
1135                                 "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
1136                                 "    </xs:sequence>{0}" +
1137                                 "  </xs:complexType>{0}" +
1138                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
1139
1140                         schemas = Export (typeof (SimpleClass[]), overrides);
1141                         Assert.AreEqual (1, schemas.Count, "#3");
1142
1143                         sw.GetStringBuilder ().Length = 0;
1144                         schemas[0].Write (sw);
1145
1146                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1147                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1148                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1149                                 "  <xs:element name=\"ArrayOfSimpleClass\" type=\"ArrayOfSimpleClass\" />{0}" +
1150                                 "  <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
1151                                 "    <xs:sequence>{0}" +
1152                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"SimpleClass\" nillable=\"true\" type=\"SimpleClass\" />{0}" +
1153                                 "    </xs:sequence>{0}" +
1154                                 "  </xs:complexType>{0}" +
1155                                 "  <xs:complexType name=\"SimpleClass\">{0}" +
1156                                 "    <xs:sequence>{0}" +
1157                                 "      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
1158                                 "    </xs:sequence>{0}" +
1159                                 "  </xs:complexType>{0}" +
1160                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
1161                 }
1162
1163                 [Test]
1164                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1165                 public void ExportEnum ()
1166                 {
1167                         XmlSchemas schemas = Export (typeof (EnumDefaultValue), "NSEnumDefaultValue");
1168                         Assert.AreEqual (1, schemas.Count, "#1");
1169
1170                         StringWriter sw = new StringWriter ();
1171                         schemas[0].Write (sw);
1172
1173                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1174                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1175                                 "<xs:schema xmlns:tns=\"NSEnumDefaultValue\" elementFormDefault=\"qualified\" targetNamespace=\"NSEnumDefaultValue\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1176                                 "  <xs:element name=\"EnumDefaultValue\" type=\"tns:EnumDefaultValue\" />{0}" +
1177                                 "  <xs:simpleType name=\"EnumDefaultValue\">{0}" +
1178                                 "    <xs:list>{0}" +
1179                                 "      <xs:simpleType>{0}" +
1180                                 "        <xs:restriction base=\"xs:string\">{0}" +
1181                                 "          <xs:enumeration value=\"e1\" />{0}" +
1182                                 "          <xs:enumeration value=\"e2\" />{0}" +
1183                                 "          <xs:enumeration value=\"e3\" />{0}" +
1184                                 "        </xs:restriction>{0}" +
1185                                 "      </xs:simpleType>{0}" +
1186                                 "    </xs:list>{0}" +
1187                                 "  </xs:simpleType>{0}" +
1188                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
1189
1190                         schemas = Export (typeof (EnumDefaultValueNF), "NSEnumDefaultValueNF");
1191                         Assert.AreEqual (1, schemas.Count, "#3");
1192
1193                         sw.GetStringBuilder ().Length = 0; 
1194                         schemas[0].Write (sw);
1195
1196                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1197                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1198                                 "<xs:schema xmlns:tns=\"NSEnumDefaultValueNF\" elementFormDefault=\"qualified\" targetNamespace=\"NSEnumDefaultValueNF\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1199                                 "  <xs:element name=\"EnumDefaultValueNF\" type=\"tns:EnumDefaultValueNF\" />{0}" +
1200                                 "  <xs:simpleType name=\"EnumDefaultValueNF\">{0}" +
1201                                 "    <xs:restriction base=\"xs:string\">{0}" +
1202                                 "      <xs:enumeration value=\"e1\" />{0}" +
1203                                 "      <xs:enumeration value=\"e2\" />{0}" +
1204                                 "      <xs:enumeration value=\"e3\" />{0}" +
1205                                 "    </xs:restriction>{0}" +
1206                                 "  </xs:simpleType>{0}" +
1207                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
1208
1209                         schemas = Export (typeof (EnumDefaultValue));
1210                         Assert.AreEqual (1, schemas.Count, "#5");
1211
1212                         sw.GetStringBuilder ().Length = 0;
1213                         schemas[0].Write (sw);
1214
1215                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1216                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1217                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1218                                 "  <xs:element name=\"EnumDefaultValue\" type=\"EnumDefaultValue\" />{0}" +
1219                                 "  <xs:simpleType name=\"EnumDefaultValue\">{0}" +
1220                                 "    <xs:list>{0}" +
1221                                 "      <xs:simpleType>{0}" +
1222                                 "        <xs:restriction base=\"xs:string\">{0}" +
1223                                 "          <xs:enumeration value=\"e1\" />{0}" +
1224                                 "          <xs:enumeration value=\"e2\" />{0}" +
1225                                 "          <xs:enumeration value=\"e3\" />{0}" +
1226                                 "        </xs:restriction>{0}" +
1227                                 "      </xs:simpleType>{0}" +
1228                                 "    </xs:list>{0}" +
1229                                 "  </xs:simpleType>{0}" +
1230                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#6");
1231
1232                         schemas = Export (typeof (EnumDefaultValueNF));
1233                         Assert.AreEqual (1, schemas.Count, "#7");
1234
1235                         sw.GetStringBuilder ().Length = 0;
1236                         schemas[0].Write (sw);
1237
1238                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1239                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1240                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1241                                 "  <xs:element name=\"EnumDefaultValueNF\" type=\"EnumDefaultValueNF\" />{0}" +
1242                                 "  <xs:simpleType name=\"EnumDefaultValueNF\">{0}" +
1243                                 "    <xs:restriction base=\"xs:string\">{0}" +
1244                                 "      <xs:enumeration value=\"e1\" />{0}" +
1245                                 "      <xs:enumeration value=\"e2\" />{0}" +
1246                                 "      <xs:enumeration value=\"e3\" />{0}" +
1247                                 "    </xs:restriction>{0}" +
1248                                 "  </xs:simpleType>{0}" +
1249                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#8");
1250                 }
1251
1252                 [Test]
1253                 [Category ("NotDotNet")] // Mono bug ##77117
1254                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1255                 public void ExportXmlSerializable ()
1256                 {
1257                         XmlSchemas schemas = Export (typeof (Employee), "NSEmployee");
1258                         Assert.AreEqual (1, schemas.Count, "#1");
1259
1260                         StringWriter sw = new StringWriter ();
1261                         schemas[0].Write (sw);
1262
1263                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1264                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1265                                 "<xs:schema xmlns:tns=\"NSEmployee\" elementFormDefault=\"qualified\" targetNamespace=\"NSEmployee\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1266                                 "  <xs:import namespace=\"http://www.w3.org/2001/XMLSchema\" />{0}" +
1267                                 "  <xs:element name=\"Employee\">{0}" +
1268                                 "    <xs:complexType>{0}" +
1269                                 "      <xs:sequence>{0}" +
1270                                 "        <xs:element ref=\"xs:schema\" />{0}" +
1271                                 "        <xs:any />{0}" +
1272                                 "      </xs:sequence>{0}" +
1273                                 "    </xs:complexType>{0}" +
1274                                 "  </xs:element>{0}" +
1275                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
1276
1277                         schemas = Export (typeof (Employee));
1278                         Assert.AreEqual (1, schemas.Count, "#3");
1279
1280                         sw.GetStringBuilder ().Length = 0;
1281                         schemas[0].Write (sw);
1282
1283                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1284                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1285                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1286                                 "  <xs:import namespace=\"http://www.w3.org/2001/XMLSchema\" />{0}" +
1287                                 "  <xs:element name=\"Employee\">{0}" +
1288                                 "    <xs:complexType>{0}" +
1289                                 "      <xs:sequence>{0}" +
1290                                 "        <xs:element ref=\"xs:schema\" />{0}" +
1291                                 "        <xs:any />{0}" +
1292                                 "      </xs:sequence>{0}" +
1293                                 "    </xs:complexType>{0}" +
1294                                 "  </xs:element>{0}" +
1295                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
1296                 }
1297
1298                 [Test]
1299                 [Category ("NotDotNet")] // Mono bug ##77117
1300                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1301                 public void ExportXmlSerializable_Schema ()
1302                 {
1303                         XmlSchemas schemas = Export (typeof (EmployeeSchema), "NSEmployeeSchema");
1304                         Assert.AreEqual (2, schemas.Count, "#1");
1305
1306                         StringWriter sw = new StringWriter ();
1307                         schemas[0].Write (sw);
1308
1309                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1310                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1311                                 "<xs:schema xmlns:tns=\"NSEmployeeSchema\" elementFormDefault=\"qualified\" targetNamespace=\"NSEmployeeSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1312 #if ONLY_1_1
1313                                 "  <xs:import namespace=\"urn:types-devx-com\" />{0}" +
1314 #endif
1315                                 "  <xs:element name=\"EmployeeSchema\">{0}" +
1316                                 "    <xs:complexType>{0}" +
1317                                 "      <xs:sequence>{0}" +
1318                                 "        <xs:any namespace=\"urn:types-devx-com\" />{0}" +
1319                                 "      </xs:sequence>{0}" +
1320                                 "    </xs:complexType>{0}" +
1321                                 "  </xs:element>{0}" +
1322                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
1323
1324                         sw.GetStringBuilder ().Length = 0;
1325                         schemas[1].Write (sw);
1326
1327                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1328                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1329                                 "<xs:schema xmlns:tns=\"urn:types-devx-com\" targetNamespace=\"urn:types-devx-com\" id=\"EmployeeSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1330                                 "  <xs:complexType name=\"employeeRoot\">{0}" +
1331                                 "    <xs:attribute name=\"firstName\" />{0}" +
1332                                 "    <xs:attribute name=\"lastName\" />{0}" +
1333                                 "    <xs:attribute name=\"address\" />{0}" +
1334                                 "  </xs:complexType>{0}" +
1335                                 "  <xs:element name=\"employee\" type=\"tns:employeeRoot\" />{0}" +
1336                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#3");
1337
1338                         schemas = Export (typeof (EmployeeSchema));
1339                         Assert.AreEqual (2, schemas.Count, "#4");
1340
1341                         sw.GetStringBuilder ().Length = 0;
1342                         schemas[0].Write (sw);
1343
1344                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1345                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1346                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1347 #if ONLY_1_1
1348                                 "  <xs:import namespace=\"urn:types-devx-com\" />{0}" +
1349 #endif
1350                                 "  <xs:element name=\"EmployeeSchema\">{0}" +
1351                                 "    <xs:complexType>{0}" +
1352                                 "      <xs:sequence>{0}" +
1353                                 "        <xs:any namespace=\"urn:types-devx-com\" />{0}" +
1354                                 "      </xs:sequence>{0}" +
1355                                 "    </xs:complexType>{0}" +
1356                                 "  </xs:element>{0}" +
1357                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#5");
1358
1359                         sw.GetStringBuilder ().Length = 0;
1360                         schemas[1].Write (sw);
1361
1362                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1363                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1364                                 "<xs:schema xmlns:tns=\"urn:types-devx-com\" targetNamespace=\"urn:types-devx-com\" id=\"EmployeeSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1365                                 "  <xs:complexType name=\"employeeRoot\">{0}" +
1366                                 "    <xs:attribute name=\"firstName\" />{0}" +
1367                                 "    <xs:attribute name=\"lastName\" />{0}" +
1368                                 "    <xs:attribute name=\"address\" />{0}" +
1369                                 "  </xs:complexType>{0}" +
1370                                 "  <xs:element name=\"employee\" type=\"tns:employeeRoot\" />{0}" +
1371                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#6");
1372
1373                         schemas = Export (typeof (PrimitiveSchema), "NSPrimitiveSchema");
1374                         Assert.AreEqual (2, schemas.Count, "#7");
1375
1376                         sw.GetStringBuilder ().Length = 0;
1377                         schemas[0].Write (sw);
1378
1379                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1380                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1381                                 "<xs:schema xmlns:tns=\"NSPrimitiveSchema\" elementFormDefault=\"qualified\" targetNamespace=\"NSPrimitiveSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1382                                 "  <xs:element name=\"PrimitiveSchema\">{0}" +
1383                                 "    <xs:complexType>{0}" +
1384                                 "      <xs:sequence>{0}" +
1385                                 "        <xs:any namespace=\"\" />{0}" +
1386                                 "      </xs:sequence>{0}" +
1387                                 "    </xs:complexType>{0}" +
1388                                 "  </xs:element>{0}" +
1389                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#8");
1390
1391                         sw.GetStringBuilder ().Length = 0;
1392                         schemas[1].Write (sw);
1393
1394                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1395                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1396                                 "<xs:schema id=\"LuckyNumberSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1397                                 "  <xs:element name=\"LuckyNumber\" type=\"xs:int\" />{0}" +
1398                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#9");
1399                 }
1400
1401                 [Test]
1402                 [ExpectedException (typeof (InvalidOperationException))] // Schema Id is missing
1403                 public void ExportXmlSerializable_MissingID ()
1404                 {
1405                         Export (typeof (MissingIDSchema));
1406                 }
1407
1408                 [ExpectedException (typeof (InvalidOperationException))]
1409                 public void ExportXmlSerializable_DuplicateNamespace ()
1410                 {
1411                         try {
1412                                 Export (typeof (PrimitiveSchema));
1413                                 Assert.Fail ("#1");
1414                         } catch (InvalidOperationException) {
1415                                 // The namespace, , is a duplicate.
1416                         }
1417
1418                         try {
1419                                 Export (typeof (XmlSerializableContainer));
1420                                 Assert.Fail ("#2");
1421                         } catch (InvalidOperationException) {
1422                                 // The namespace, , is a duplicate.
1423                         }
1424                 }
1425
1426                 [Test]
1427                 [Category ("NotDotNet")] // Mono bug ##77117
1428                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1429 #if NET_2_0
1430                 [Category ("NotWorking")] // support for XmlSchemaProvider is not implemented
1431 #endif
1432                 public void ExportXmlSerializable_SchemaProvider ()
1433                 {
1434                         XmlSchemas schemas = Export (typeof (EmployeeSchemaProvider), "NSEmployeeSchemaProvider");
1435                         Assert.AreEqual (1, schemas.Count, "#1");
1436
1437                         StringWriter sw = new StringWriter ();
1438                         schemas[0].Write (sw);
1439
1440                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1441                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1442                                 "<xs:schema xmlns:tns=\"NSEmployeeSchemaProvider\" elementFormDefault=\"qualified\" targetNamespace=\"NSEmployeeSchemaProvider\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1443 #if NET_2_0
1444                                 "  <xs:import namespace=\"urn:types-devx-com\" />{0}" +
1445                                 "  <xs:element name=\"employeeRoot\" nillable=\"true\" xmlns:q1=\"urn:types-devx-com\" type=\"q1:employeeRoot\" />{0}" +
1446 #else
1447                                 "  <xs:import namespace=\"http://www.w3.org/2001/XMLSchema\" />{0}" +
1448                                 "  <xs:element name=\"EmployeeSchemaProvider\">{0}" +
1449                                 "    <xs:complexType>{0}" +
1450                                 "      <xs:sequence>{0}" +
1451                                 "        <xs:element ref=\"xs:schema\" />{0}" +
1452                                 "        <xs:any />{0}" +
1453                                 "      </xs:sequence>{0}" +
1454                                 "    </xs:complexType>{0}" +
1455                                 "  </xs:element>{0}" +
1456 #endif
1457                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
1458
1459                         schemas = Export (typeof (EmployeeSchemaProvider));
1460                         Assert.AreEqual (1, schemas.Count, "#3");
1461
1462                         sw.GetStringBuilder ().Length = 0;
1463                         schemas[0].Write (sw);
1464
1465                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1466                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1467                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1468 #if NET_2_0
1469                                 "  <xs:import namespace=\"urn:types-devx-com\" />{0}" +
1470                                 "  <xs:element name=\"employeeRoot\" nillable=\"true\" xmlns:q1=\"urn:types-devx-com\" type=\"q1:employeeRoot\" />{0}" +
1471 #else
1472                                 "  <xs:import namespace=\"http://www.w3.org/2001/XMLSchema\" />{0}" +
1473                                 "  <xs:element name=\"EmployeeSchemaProvider\">{0}" +
1474                                 "    <xs:complexType>{0}" +
1475                                 "      <xs:sequence>{0}" +
1476                                 "        <xs:element ref=\"xs:schema\" />{0}" +
1477                                 "        <xs:any />{0}" +
1478                                 "      </xs:sequence>{0}" +
1479                                 "    </xs:complexType>{0}" +
1480                                 "  </xs:element>{0}" +
1481 #endif
1482                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
1483
1484                         schemas = Export (typeof (PrimitiveSchemaProvider), "NSPrimitiveSchemaProvider");
1485                         Assert.AreEqual (1, schemas.Count, "#5");
1486
1487                         sw.GetStringBuilder ().Length = 0;
1488                         schemas[0].Write (sw);
1489
1490                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1491                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1492                                 "<xs:schema xmlns:tns=\"NSPrimitiveSchemaProvider\" elementFormDefault=\"qualified\" targetNamespace=\"NSPrimitiveSchemaProvider\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1493 #if NET_2_0
1494                                 "  <xs:import />{0}" +
1495                                 "  <xs:element name=\"int\" nillable=\"true\" type=\"xs:int\" />{0}" +
1496 #else
1497                                 "  <xs:import namespace=\"http://www.w3.org/2001/XMLSchema\" />{0}" +
1498                                 "  <xs:element name=\"PrimitiveSchemaProvider\">{0}" +
1499                                 "    <xs:complexType>{0}" +
1500                                 "      <xs:sequence>{0}" +
1501                                 "        <xs:element ref=\"xs:schema\" />{0}" +
1502                                 "        <xs:any />{0}" +
1503                                 "      </xs:sequence>{0}" +
1504                                 "    </xs:complexType>{0}" +
1505                                 "  </xs:element>{0}" +
1506 #endif
1507                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#6");
1508
1509                         schemas = Export (typeof (PrimitiveSchemaProvider));
1510                         Assert.AreEqual (1, schemas.Count, "#7");
1511
1512                         sw.GetStringBuilder ().Length = 0;
1513                         schemas[0].Write (sw);
1514
1515                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1516                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1517                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1518 #if NET_2_0
1519                                 "  <xs:element name=\"int\" nillable=\"true\" type=\"xs:int\" />{0}" +
1520 #else
1521                                 "  <xs:import namespace=\"http://www.w3.org/2001/XMLSchema\" />{0}" +
1522                                 "  <xs:element name=\"PrimitiveSchemaProvider\">{0}" +
1523                                 "    <xs:complexType>{0}" +
1524                                 "      <xs:sequence>{0}" +
1525                                 "        <xs:element ref=\"xs:schema\" />{0}" +
1526                                 "        <xs:any />{0}" +
1527                                 "      </xs:sequence>{0}" +
1528                                 "    </xs:complexType>{0}" +
1529                                 "  </xs:element>{0}" +
1530 #endif
1531                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#8");
1532                 }
1533
1534                 [Test]
1535                 [Category ("NotDotNet")] // Mono bug ##77117
1536                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1537 #if NET_2_0
1538                 [Category ("NotWorking")] // support for XmlSchemaProvider is not implemented
1539 #endif
1540                 public void ExportXmlSerializable_Container ()
1541                 {
1542                         XmlSchemas schemas = Export (typeof (XmlSerializableContainer), "NSXmlSerializableContainer");
1543                         Assert.AreEqual (3, schemas.Count, "#1");
1544
1545                         StringWriter sw = new StringWriter ();
1546                         schemas[0].Write (sw);
1547
1548                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1549                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1550                                 "<xs:schema xmlns:tns=\"NSXmlSerializableContainer\" elementFormDefault=\"qualified\" targetNamespace=\"NSXmlSerializableContainer\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1551                                 "  <xs:import namespace=\"http://www.w3.org/2001/XMLSchema\" />{0}" +
1552                                 "  <xs:import namespace=\"urn:types-devx-com\" />{0}" +
1553 #if NET_2_0
1554                                 "  <xs:import />{0}" +
1555 #endif
1556                                 "  <xs:element name=\"XmlSerializableContainer\" type=\"tns:XmlSerializableContainer\" />{0}" +
1557                                 "  <xs:complexType name=\"XmlSerializableContainer\">{0}" +
1558                                 "    <xs:sequence>{0}" +
1559                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"Slave\">{0}" +
1560                                 "        <xs:complexType>{0}" +
1561                                 "          <xs:sequence>{0}" +
1562                                 "            <xs:element ref=\"xs:schema\" />{0}" +
1563                                 "            <xs:any />{0}" +
1564                                 "          </xs:sequence>{0}" +
1565                                 "        </xs:complexType>{0}" +
1566                                 "      </xs:element>{0}" +
1567                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"SlaveSchema\">{0}" +
1568                                 "        <xs:complexType>{0}" +
1569                                 "          <xs:sequence>{0}" +
1570                                 "            <xs:any namespace=\"urn:types-devx-com\" />{0}" +
1571                                 "          </xs:sequence>{0}" +
1572                                 "        </xs:complexType>{0}" +
1573                                 "      </xs:element>{0}" +
1574 #if NET_2_0
1575                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"SlaveSchemaProvider\" xmlns:q1=\"urn:types-devx-com\" type=\"q1:employeeRoot\" />{0}" +
1576 #else
1577                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"SlaveSchemaProvider\">{0}" +
1578                                 "        <xs:complexType>{0}" +
1579                                 "          <xs:sequence>{0}" +
1580                                 "            <xs:element ref=\"xs:schema\" />{0}" +
1581                                 "            <xs:any />{0}" +
1582                                 "          </xs:sequence>{0}" +
1583                                 "        </xs:complexType>{0}" +
1584                                 "      </xs:element>{0}" +
1585 #endif
1586                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"NativeSchema\">{0}" +
1587                                 "        <xs:complexType>{0}" +
1588                                 "          <xs:sequence>{0}" +
1589                                 "            <xs:any namespace=\"\" />{0}" +
1590                                 "          </xs:sequence>{0}" +
1591                                 "        </xs:complexType>{0}" +
1592                                 "      </xs:element>{0}" +
1593 #if NET_2_0
1594                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"NativeSchemaProvider\" type=\"xs:int\" />{0}" +
1595                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q2=\"urn:types-devx-com\" ref=\"q2:SlaveNamespace\" />{0}" +
1596                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q3=\"urn:types-devx-com\" ref=\"q3:SlaveSchemaNamespace\" />{0}" +
1597                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q4=\"urn:types-devx-com\" ref=\"q4:SlaveSchemaProviderNamespace\" />{0}" +
1598                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q5=\"urn:types-devx-com\" ref=\"q5:NativeSchemaNamespace\" />{0}" +
1599                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q6=\"urn:types-devx-com\" ref=\"q6:NativeSchemaProviderNamespace\" />{0}" +
1600                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q7=\"urn:types-devx-com\" ref=\"q7:SlaveNSOnly\" />{0}" +
1601                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q8=\"urn:types-devx-com\" ref=\"q8:SlaveSchemaNSOnly\" />{0}" +
1602                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q9=\"urn:types-devx-com\" ref=\"q9:SlaveSchemaProviderNSOnly\" />{0}" +
1603                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q10=\"urn:types-devx-com\" ref=\"q10:NativeSchemaNSOnly\" />{0}" +
1604                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q11=\"urn:types-devx-com\" ref=\"q11:NativeSchemaProviderNSOnly\" />{0}" +
1605 #else
1606                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" name=\"NativeSchemaProvider\">{0}" +
1607                                 "        <xs:complexType>{0}" +
1608                                 "          <xs:sequence>{0}" +
1609                                 "            <xs:element ref=\"xs:schema\" />{0}" +
1610                                 "            <xs:any />{0}" +
1611                                 "          </xs:sequence>{0}" +
1612                                 "        </xs:complexType>{0}" +
1613                                 "      </xs:element>{0}" +
1614                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q1=\"urn:types-devx-com\" ref=\"q1:SlaveNamespace\" />{0}" +
1615                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q2=\"urn:types-devx-com\" ref=\"q2:SlaveSchemaNamespace\" />{0}" +
1616                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q3=\"urn:types-devx-com\" ref=\"q3:SlaveSchemaProviderNamespace\" />{0}" +
1617                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q4=\"urn:types-devx-com\" ref=\"q4:NativeSchemaNamespace\" />{0}" +
1618                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q5=\"urn:types-devx-com\" ref=\"q5:NativeSchemaProviderNamespace\" />{0}" +
1619                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q6=\"urn:types-devx-com\" ref=\"q6:SlaveNSOnly\" />{0}" +
1620                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q7=\"urn:types-devx-com\" ref=\"q7:SlaveSchemaNSOnly\" />{0}" +
1621                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q8=\"urn:types-devx-com\" ref=\"q8:SlaveSchemaProviderNSOnly\" />{0}" +
1622                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q9=\"urn:types-devx-com\" ref=\"q9:NativeSchemaNSOnly\" />{0}" +
1623                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"1\" xmlns:q10=\"urn:types-devx-com\" ref=\"q10:NativeSchemaProviderNSOnly\" />{0}" +
1624 #endif
1625                                 "    </xs:sequence>{0}" +
1626                                 "  </xs:complexType>{0}" +
1627                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
1628
1629                         sw.GetStringBuilder ().Length = 0;
1630                         schemas[1].Write (sw);
1631
1632                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1633                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1634                                 "<xs:schema xmlns:tns=\"urn:types-devx-com\" targetNamespace=\"urn:types-devx-com\" id=\"EmployeeSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1635                                 "  <xs:import namespace=\"http://www.w3.org/2001/XMLSchema\" />{0}" +
1636 #if NET_2_0
1637                                 "  <xs:import />{0}" +
1638 #endif
1639                                 "  <xs:complexType name=\"employeeRoot\">{0}" +
1640                                 "    <xs:attribute name=\"firstName\" />{0}" +
1641                                 "    <xs:attribute name=\"lastName\" />{0}" +
1642                                 "    <xs:attribute name=\"address\" />{0}" +
1643                                 "  </xs:complexType>{0}" +
1644                                 "  <xs:element name=\"employee\" type=\"tns:employeeRoot\" />{0}" +
1645                                 "  <xs:element name=\"SlaveNamespace\">{0}" +
1646                                 "    <xs:complexType>{0}" +
1647                                 "      <xs:sequence>{0}" +
1648                                 "        <xs:element ref=\"xs:schema\" />{0}" +
1649                                 "        <xs:any />{0}" +
1650                                 "      </xs:sequence>{0}" +
1651                                 "    </xs:complexType>{0}" +
1652                                 "  </xs:element>{0}" +
1653                                 "  <xs:element name=\"SlaveSchemaNamespace\">{0}" +
1654                                 "    <xs:complexType>{0}" +
1655                                 "      <xs:sequence>{0}" +
1656                                 "        <xs:any namespace=\"urn:types-devx-com\" />{0}" +
1657                                 "      </xs:sequence>{0}" +
1658                                 "    </xs:complexType>{0}" +
1659                                 "  </xs:element>{0}" +
1660 #if NET_2_0
1661                                 "  <xs:element name=\"SlaveSchemaProviderNamespace\" type=\"tns:employeeRoot\" />{0}" +
1662 #else
1663                                 "  <xs:element name=\"SlaveSchemaProviderNamespace\">{0}" +
1664                                 "    <xs:complexType>{0}" +
1665                                 "      <xs:sequence>{0}" +
1666                                 "        <xs:element ref=\"xs:schema\" />{0}" +
1667                                 "        <xs:any />{0}" +
1668                                 "      </xs:sequence>{0}" +
1669                                 "    </xs:complexType>{0}" +
1670                                 "  </xs:element>{0}" +
1671 #endif
1672                                 "  <xs:element name=\"NativeSchemaNamespace\">{0}" +
1673                                 "    <xs:complexType>{0}" +
1674                                 "      <xs:sequence>{0}" +
1675                                 "        <xs:any namespace=\"\" />{0}" +
1676                                 "      </xs:sequence>{0}" +
1677                                 "    </xs:complexType>{0}" +
1678                                 "  </xs:element>{0}" +
1679 #if NET_2_0
1680                                 "  <xs:element name=\"NativeSchemaProviderNamespace\" type=\"xs:int\" />{0}" +
1681 #else
1682                                 "  <xs:element name=\"NativeSchemaProviderNamespace\">{0}" +
1683                                 "    <xs:complexType>{0}" +
1684                                 "      <xs:sequence>{0}" +
1685                                 "        <xs:element ref=\"xs:schema\" />{0}" +
1686                                 "        <xs:any />{0}" +
1687                                 "      </xs:sequence>{0}" +
1688                                 "    </xs:complexType>{0}" +
1689                                 "  </xs:element>{0}" +
1690 #endif
1691                                 "  <xs:element name=\"SlaveNSOnly\">{0}" +
1692                                 "    <xs:complexType>{0}" +
1693                                 "      <xs:sequence>{0}" +
1694                                 "        <xs:element ref=\"xs:schema\" />{0}" +
1695                                 "        <xs:any />{0}" +
1696                                 "      </xs:sequence>{0}" +
1697                                 "    </xs:complexType>{0}" +
1698                                 "  </xs:element>{0}" +
1699                                 "  <xs:element name=\"SlaveSchemaNSOnly\">{0}" +
1700                                 "    <xs:complexType>{0}" +
1701                                 "      <xs:sequence>{0}" +
1702                                 "        <xs:any namespace=\"urn:types-devx-com\" />{0}" +
1703                                 "      </xs:sequence>{0}" +
1704                                 "    </xs:complexType>{0}" +
1705                                 "  </xs:element>{0}" +
1706 #if NET_2_0
1707                                  "  <xs:element name=\"SlaveSchemaProviderNSOnly\" type=\"tns:employeeRoot\" />{0}" +
1708 #else
1709                                 "  <xs:element name=\"SlaveSchemaProviderNSOnly\">{0}" +
1710                                 "    <xs:complexType>{0}" +
1711                                 "      <xs:sequence>{0}" +
1712                                 "        <xs:element ref=\"xs:schema\" />{0}" +
1713                                 "        <xs:any />{0}" +
1714                                 "      </xs:sequence>{0}" +
1715                                 "    </xs:complexType>{0}" +
1716                                 "  </xs:element>{0}" +
1717 #endif
1718                                 "  <xs:element name=\"NativeSchemaNSOnly\">{0}" +
1719                                 "    <xs:complexType>{0}" +
1720                                 "      <xs:sequence>{0}" +
1721                                 "        <xs:any namespace=\"\" />{0}" +
1722                                 "      </xs:sequence>{0}" +
1723                                 "    </xs:complexType>{0}" +
1724                                 "  </xs:element>{0}" +
1725 #if NET_2_0
1726                                 "  <xs:element name=\"NativeSchemaProviderNSOnly\" type=\"xs:int\" />{0}" +
1727 #else
1728                                 "  <xs:element name=\"NativeSchemaProviderNSOnly\">{0}" +
1729                                 "    <xs:complexType>{0}" +
1730                                 "      <xs:sequence>{0}" +
1731                                 "        <xs:element ref=\"xs:schema\" />{0}" +
1732                                 "        <xs:any />{0}" +
1733                                 "      </xs:sequence>{0}" +
1734                                 "    </xs:complexType>{0}" +
1735                                 "  </xs:element>{0}" +
1736 #endif
1737                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#3");
1738
1739                         sw.GetStringBuilder ().Length = 0;
1740                         schemas[2].Write (sw);
1741
1742                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1743                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1744                                 "<xs:schema id=\"LuckyNumberSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1745                                 "  <xs:element name=\"LuckyNumber\" type=\"xs:int\" />{0}" +
1746                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
1747                 }
1748
1749                 [Test]
1750                 [Category ("NotDotNet")] // Mono bug ##77117
1751                 public void ExportXsdPrimitive ()
1752                 {
1753                         ArrayList types = new ArrayList ();
1754                         types.Add (new TypeDescription (typeof (byte), true, "unsignedByte", "Byte"));
1755                         types.Add (new TypeDescription (typeof (sbyte), true, "byte", "Byte"));
1756                         types.Add (new TypeDescription (typeof (bool), true, "boolean", "Boolean"));
1757                         types.Add (new TypeDescription (typeof (short), true, "short", "Short"));
1758                         types.Add (new TypeDescription (typeof (int), true, "int", "Int"));
1759                         types.Add (new TypeDescription (typeof (long), true, "long", "Long"));
1760                         types.Add (new TypeDescription (typeof (float), true, "float", "Float"));
1761                         types.Add (new TypeDescription (typeof (double), true, "double", "Double"));
1762                         types.Add (new TypeDescription (typeof (decimal), true, "decimal", "Decimal"));
1763                         types.Add (new TypeDescription (typeof (ushort), true, "unsignedShort", "UnsignedShort"));
1764                         types.Add (new TypeDescription (typeof (uint), true, "unsignedInt", "UnsignedInt"));
1765                         types.Add (new TypeDescription (typeof (ulong), true, "unsignedLong", "UnsignedLong"));
1766                         types.Add (new TypeDescription (typeof (DateTime), true, "dateTime", "DateTime"));
1767 #if NET_2_0
1768                         types.Add (new TypeDescription (typeof (XmlQualifiedName), true, "QName", "QName", true));
1769 #else
1770                         types.Add (new TypeDescription (typeof (XmlQualifiedName), true, "QName", "QName"));
1771 #endif
1772                         types.Add (new TypeDescription (typeof (string), true, "string", "String", true));
1773
1774                         foreach (TypeDescription typeDesc in types) {
1775                                 XmlSchemas schemas = Export (typeDesc.Type, typeDesc.Type.Name);
1776                                 Assert.AreEqual (1, schemas.Count, typeDesc.Type.FullName + "#1");
1777
1778                                 StringWriter sw = new StringWriter ();
1779                                 schemas[0].Write (sw);
1780
1781                                 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1782                                         "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1783                                         "<xs:schema xmlns:tns=\"{1}\" elementFormDefault=\"qualified\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1784                                         "  <xs:element name=\"{2}\" {3}type=\"xs:{2}\" />{0}" +
1785                                         "</xs:schema>", Environment.NewLine, typeDesc.Type.Name, typeDesc.XmlType, ""),
1786                                         sw.ToString (), typeDesc.Type.FullName + "#2");
1787
1788                                 schemas = Export (typeDesc.Type);
1789                                 Assert.AreEqual (1, schemas.Count, typeDesc.Type.FullName + "#3");
1790
1791                                 sw.GetStringBuilder ().Length = 0;
1792                                 schemas[0].Write (sw);
1793
1794                                 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1795                                         "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1796                                         "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1797                                         "  <xs:element name=\"{1}\" {2}type=\"xs:{1}\" />{0}" +
1798                                         "</xs:schema>", Environment.NewLine, typeDesc.XmlType, ""),
1799                                         sw.ToString (), typeDesc.Type.FullName + "#4");
1800                         }
1801                 }
1802
1803                 [Test]
1804                 [Category ("NotDotNet")] // Mono bug ##77117
1805                 [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
1806                 public void ExportXsdPrimitive_Object ()
1807                 {
1808                         XmlSchemas schemas = Export (typeof (object), "NSAnyType");
1809                         Assert.AreEqual (1, schemas.Count, "#1");
1810
1811                         StringWriter sw = new StringWriter ();
1812                         schemas[0].Write (sw);
1813
1814                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1815                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1816                                 "<xs:schema xmlns:tns=\"NSAnyType\" elementFormDefault=\"qualified\" targetNamespace=\"NSAnyType\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1817                                 "  <xs:element name=\"anyType\" />{0}" +
1818                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
1819
1820                         schemas = Export (typeof (object));
1821                         Assert.AreEqual (1, schemas.Count, "#3");
1822
1823                         sw.GetStringBuilder ().Length = 0;
1824                         schemas[0].Write (sw);
1825
1826                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1827                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1828                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1829                                 "  <xs:element name=\"anyType\" />{0}" +
1830                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
1831                 }
1832
1833                 [Test]
1834                 [Category ("NotDotNet")] // Mono bug ##77117
1835                 public void ExportXsdPrimitive_ByteArray ()
1836                 {
1837                         XmlSchemas schemas = Export (typeof (byte[]), "NSByteArray");
1838                         Assert.AreEqual (1, schemas.Count, "#1");
1839
1840                         StringWriter sw = new StringWriter ();
1841                         schemas[0].Write (sw);
1842
1843                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1844                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1845                                 "<xs:schema xmlns:tns=\"NSByteArray\" elementFormDefault=\"qualified\" targetNamespace=\"NSByteArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1846                                 "  <xs:element name=\"base64Binary\" type=\"xs:base64Binary\" />{0}" +
1847                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
1848
1849                         schemas = Export (typeof (byte[]));
1850                         Assert.AreEqual (1, schemas.Count, "#3");
1851
1852                         sw.GetStringBuilder ().Length = 0;
1853                         schemas[0].Write (sw);
1854
1855                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1856                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1857                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1858                                 "  <xs:element name=\"base64Binary\" type=\"xs:base64Binary\" />{0}" +
1859                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
1860                 }
1861
1862                 [Test]
1863 #if NET_2_0
1864                 [Category ("NotWorking")] // in 2.0 profile, QName must be nillable
1865 #endif
1866                 [Category ("NotDotNet")] // Mono bug ##77117
1867                 public void ExportXsdPrimitive_Arrays ()
1868                 {
1869                         ArrayList types = new ArrayList ();
1870                         types.Add (new TypeDescription (typeof (sbyte[]), true, "byte", "Byte"));
1871                         types.Add (new TypeDescription (typeof (bool[]), true, "boolean", "Boolean"));
1872                         types.Add (new TypeDescription (typeof (short[]), true, "short", "Short"));
1873                         types.Add (new TypeDescription (typeof (int[]), true, "int", "Int"));
1874                         types.Add (new TypeDescription (typeof (long[]), true, "long", "Long"));
1875                         types.Add (new TypeDescription (typeof (float[]), true, "float", "Float"));
1876                         types.Add (new TypeDescription (typeof (double[]), true, "double", "Double"));
1877                         types.Add (new TypeDescription (typeof (decimal[]), true, "decimal", "Decimal"));
1878                         types.Add (new TypeDescription (typeof (ushort[]), true, "unsignedShort", "UnsignedShort"));
1879                         types.Add (new TypeDescription (typeof (uint[]), true, "unsignedInt", "UnsignedInt"));
1880                         types.Add (new TypeDescription (typeof (ulong[]), true, "unsignedLong", "UnsignedLong"));
1881                         types.Add (new TypeDescription (typeof (DateTime[]), true, "dateTime", "DateTime"));
1882 #if NET_2_0
1883                         types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName", true));
1884 #else
1885                         types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName"));
1886 #endif
1887                         types.Add (new TypeDescription (typeof (string[]), true, "string", "String", true));
1888
1889                         foreach (TypeDescription typeDesc in types) {
1890                                 XmlSchemas schemas = Export (typeDesc.Type, typeDesc.Type.Name);
1891                                 Assert.AreEqual (1, schemas.Count, typeDesc.Type.FullName + "#1");
1892
1893                                 StringWriter sw = new StringWriter ();
1894                                 schemas[0].Write (sw);
1895
1896                                 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1897                                         "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1898                                         "<xs:schema xmlns:tns=\"{1}\" elementFormDefault=\"qualified\" targetNamespace=\"{1}\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1899                                         "  <xs:element name=\"ArrayOf{2}\" type=\"tns:ArrayOf{2}\" />{0}" +
1900                                         "  <xs:complexType name=\"ArrayOf{2}\">{0}" +
1901                                         "    <xs:sequence>{0}" +
1902                                         "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"{3}\" {5}type=\"{4}:{3}\" />{0}" +
1903                                         "    </xs:sequence>{0}" +
1904                                         "  </xs:complexType>{0}" +
1905                                         "</xs:schema>", Environment.NewLine, typeDesc.Type.Name, typeDesc.ArrayType, typeDesc.XmlType, 
1906                                         typeDesc.XsdType ? "xs" : "tns", typeDesc.IsNillable ? "nillable=\"true\" " : ""),
1907                                         sw.ToString (), typeDesc.Type.FullName + "#2");
1908
1909                                 schemas = Export (typeDesc.Type);
1910                                 Assert.AreEqual (1, schemas.Count, typeDesc.Type.FullName + "#3");
1911
1912                                 sw.GetStringBuilder ().Length = 0;
1913                                 schemas[0].Write (sw);
1914
1915                                 Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1916                                         "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1917                                         "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1918                                         "  <xs:element name=\"ArrayOf{1}\" type=\"ArrayOf{1}\" />{0}" +
1919                                         "  <xs:complexType name=\"ArrayOf{1}\">{0}" +
1920                                         "    <xs:sequence>{0}" +
1921                                         "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"{2}\" {4}type=\"{3}:{2}\" />{0}" +
1922                                         "    </xs:sequence>{0}" +
1923                                         "  </xs:complexType>{0}" +
1924                                         "</xs:schema>", Environment.NewLine, typeDesc.ArrayType, typeDesc.XmlType,
1925                                         typeDesc.XsdType ? "xs" : "tns", typeDesc.IsNillable ? "nillable=\"true\" " : ""),
1926                                         sw.ToString (), typeDesc.Type.FullName + "#4");
1927                         }
1928                 }
1929
1930                 [Test]
1931                 [Category ("NotDotNet")] // Mono bug ##77117
1932                 public void ExportXsdPrimitive_Object_Arrays ()
1933                 {
1934                         XmlSchemas schemas = Export (typeof (object[]), "NSArrayOfAnyType");
1935                         Assert.AreEqual (1, schemas.Count, "#1");
1936
1937                         StringWriter sw = new StringWriter ();
1938                         schemas[0].Write (sw);
1939
1940                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1941                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1942                                 "<xs:schema xmlns:tns=\"NSArrayOfAnyType\" elementFormDefault=\"qualified\" targetNamespace=\"NSArrayOfAnyType\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1943                                 "  <xs:element name=\"ArrayOfAnyType\" type=\"tns:ArrayOfAnyType\" />{0}" +
1944                                 "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
1945                                 "    <xs:sequence>{0}" +
1946                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
1947                                 "    </xs:sequence>{0}" +
1948                                 "  </xs:complexType>{0}" +
1949                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
1950
1951                         schemas = Export (typeof (object[]));
1952                         Assert.AreEqual (1, schemas.Count, "#3");
1953
1954                         sw.GetStringBuilder ().Length = 0;
1955                         schemas[0].Write (sw);
1956
1957                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1958                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1959                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1960                                 "  <xs:element name=\"ArrayOfAnyType\" type=\"ArrayOfAnyType\" />{0}" +
1961                                 "  <xs:complexType name=\"ArrayOfAnyType\">{0}" +
1962                                 "    <xs:sequence>{0}" +
1963                                 "      <xs:element minOccurs=\"0\" maxOccurs=\"unbounded\" name=\"anyType\" nillable=\"true\" />{0}" +
1964                                 "    </xs:sequence>{0}" +
1965                                 "  </xs:complexType>{0}" +
1966                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#4");
1967                 }
1968
1969                 [Test]
1970                 public void ExportNonXsdPrimitive_Guid ()
1971                 {
1972                         XmlSchemas schemas = Export (typeof (Guid), "NSPrimGuid");
1973                         Assert.AreEqual (2, schemas.Count, "#1");
1974
1975                         StringWriter sw = new StringWriter ();
1976                         schemas[0].Write (sw);
1977
1978                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1979                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1980                                 "<xs:schema xmlns:tns=\"NSPrimGuid\" elementFormDefault=\"qualified\" targetNamespace=\"NSPrimGuid\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1981                                 "  <xs:import namespace=\"http://microsoft.com/wsdl/types/\" />{0}" +
1982                                 "  <xs:element name=\"guid\" xmlns:q1=\"http://microsoft.com/wsdl/types/\" type=\"q1:guid\" />{0}" +
1983                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
1984
1985                         sw.GetStringBuilder ().Length = 0;
1986                         schemas[1].Write (sw);
1987
1988                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
1989                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
1990                                 "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" elementFormDefault=\"qualified\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
1991                                 "  <xs:simpleType name=\"guid\">{0}" +
1992                                 "    <xs:restriction base=\"xs:string\">{0}" +
1993                                 "      <xs:pattern value=\"[0-9a-fA-F]{{8}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{12}}\" />{0}" +
1994                                 "    </xs:restriction>{0}" +
1995                                 "  </xs:simpleType>{0}" +
1996                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#3");
1997
1998                         schemas = Export (typeof (Guid));
1999                         Assert.AreEqual (2, schemas.Count, "#4");
2000
2001                         sw.GetStringBuilder ().Length = 0;
2002                         schemas[0].Write (sw);
2003
2004                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2005                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
2006                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
2007                                 "  <xs:import namespace=\"http://microsoft.com/wsdl/types/\" />{0}" +
2008                                 "  <xs:element name=\"guid\" xmlns:q1=\"http://microsoft.com/wsdl/types/\" type=\"q1:guid\" />{0}" +
2009                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#5");
2010
2011                         sw.GetStringBuilder ().Length = 0;
2012                         schemas[1].Write (sw);
2013
2014                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2015                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
2016                                 "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" elementFormDefault=\"qualified\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
2017                                 "  <xs:simpleType name=\"guid\">{0}" +
2018                                 "    <xs:restriction base=\"xs:string\">{0}" +
2019                                 "      <xs:pattern value=\"[0-9a-fA-F]{{8}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{4}}-[0-9a-fA-F]{{12}}\" />{0}" +
2020                                 "    </xs:restriction>{0}" +
2021                                 "  </xs:simpleType>{0}" +
2022                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#6");
2023                 }
2024
2025                 [Test]
2026                 public void ExportNonXsdPrimitive_Char ()
2027                 {
2028                         XmlSchemas schemas = Export (typeof (char), "NSPrimChar");
2029                         Assert.AreEqual (2, schemas.Count, "#1");
2030
2031                         StringWriter sw = new StringWriter ();
2032                         schemas[0].Write (sw);
2033
2034                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2035                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
2036                                 "<xs:schema xmlns:tns=\"NSPrimChar\" elementFormDefault=\"qualified\" targetNamespace=\"NSPrimChar\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
2037                                 "  <xs:import namespace=\"http://microsoft.com/wsdl/types/\" />{0}" +
2038                                 "  <xs:element name=\"char\" xmlns:q1=\"http://microsoft.com/wsdl/types/\" type=\"q1:char\" />{0}" +
2039                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
2040
2041                         sw.GetStringBuilder ().Length = 0;
2042                         schemas[1].Write (sw);
2043
2044                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2045                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
2046                                 "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" elementFormDefault=\"qualified\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
2047                                 "  <xs:simpleType name=\"char\">{0}" +
2048                                 "    <xs:restriction base=\"xs:unsignedShort\" />{0}" +
2049                                 "  </xs:simpleType>{0}" +
2050                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#3");
2051
2052                         schemas = Export (typeof (char));
2053                         Assert.AreEqual (2, schemas.Count, "#4");
2054
2055                         sw.GetStringBuilder ().Length = 0;
2056                         schemas[0].Write (sw);
2057
2058                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2059                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
2060                                 "<xs:schema elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
2061                                 "  <xs:import namespace=\"http://microsoft.com/wsdl/types/\" />{0}" +
2062                                 "  <xs:element name=\"char\" xmlns:q1=\"http://microsoft.com/wsdl/types/\" type=\"q1:char\" />{0}" +
2063                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#5");
2064
2065                         sw.GetStringBuilder ().Length = 0;
2066                         schemas[1].Write (sw);
2067
2068                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
2069                                 "<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
2070                                 "<xs:schema xmlns:tns=\"http://microsoft.com/wsdl/types/\" elementFormDefault=\"qualified\" targetNamespace=\"http://microsoft.com/wsdl/types/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
2071                                 "  <xs:simpleType name=\"char\">{0}" +
2072                                 "    <xs:restriction base=\"xs:unsignedShort\" />{0}" +
2073                                 "  </xs:simpleType>{0}" +
2074                                 "</xs:schema>", Environment.NewLine), sw.ToString (), "#6");
2075                 }
2076
2077                 public class Employee : IXmlSerializable
2078                 {
2079                         private string _firstName;
2080                         private string _lastName;
2081                         private string _address;
2082
2083                         public virtual XmlSchema GetSchema ()
2084                         {
2085                                 return null;
2086                         }
2087
2088                         public void WriteXml (XmlWriter writer)
2089                         {
2090                                 writer.WriteStartElement ("employee", "urn:devx-com");
2091                                 writer.WriteAttributeString ("firstName", _firstName);
2092                                 writer.WriteAttributeString ("lastName", _lastName);
2093                                 writer.WriteAttributeString ("address", _address);
2094                                 writer.WriteEndElement ();
2095                         }
2096
2097                         public void ReadXml (XmlReader reader)
2098                         {
2099                                 XmlNodeType type = reader.MoveToContent ();
2100                                 if (type == XmlNodeType.Element && reader.LocalName == "employee") {
2101                                         _firstName = reader["firstName"];
2102                                         _lastName = reader["lastName"];
2103                                         _address = reader["address"];
2104                                 }
2105                         }
2106                 }
2107
2108                 public class EmployeeSchema : IXmlSerializable
2109                 {
2110                         private string _firstName;
2111                         private string _lastName;
2112                         private string _address;
2113
2114                         public virtual XmlSchema GetSchema ()
2115                         {
2116                                 return CreateSchema ();
2117                         }
2118
2119                         public void WriteXml (XmlWriter writer)
2120                         {
2121                                 writer.WriteStartElement ("employee", "urn:devx-com");
2122                                 writer.WriteAttributeString ("firstName", _firstName);
2123                                 writer.WriteAttributeString ("lastName", _lastName);
2124                                 writer.WriteAttributeString ("address", _address);
2125                                 writer.WriteEndElement ();
2126                         }
2127
2128                         public void ReadXml (XmlReader reader)
2129                         {
2130                                 XmlNodeType type = reader.MoveToContent ();
2131                                 if (type == XmlNodeType.Element && reader.LocalName == "employee") {
2132                                         _firstName = reader["firstName"];
2133                                         _lastName = reader["lastName"];
2134                                         _address = reader["address"];
2135                                 }
2136                         }
2137
2138                         protected static XmlSchema CreateSchema ()
2139                         {
2140                                 XmlSchema schema = new XmlSchema ();
2141                                 schema.Id = "EmployeeSchema";
2142                                 schema.TargetNamespace = "urn:types-devx-com";
2143
2144                                 XmlSchemaComplexType type = new XmlSchemaComplexType ();
2145                                 type.Name = "employeeRoot";
2146                                 XmlSchemaAttribute firstNameAttr = new XmlSchemaAttribute ();
2147                                 firstNameAttr.Name = "firstName";
2148                                 type.Attributes.Add (firstNameAttr);
2149
2150                                 XmlSchemaAttribute lastNameAttr = new XmlSchemaAttribute ();
2151                                 lastNameAttr.Name = "lastName";
2152                                 type.Attributes.Add (lastNameAttr);
2153
2154                                 XmlSchemaAttribute addressAttr = new XmlSchemaAttribute ();
2155                                 addressAttr.Name = "address";
2156                                 type.Attributes.Add (addressAttr);
2157
2158                                 XmlSchemaElement employeeElement = new XmlSchemaElement ();
2159                                 employeeElement.Name = "employee";
2160                                 XmlQualifiedName name = new XmlQualifiedName ("employeeRoot", "urn:types-devx-com");
2161                                 employeeElement.SchemaTypeName = name;
2162
2163                                 schema.Items.Add (type);
2164                                 schema.Items.Add (employeeElement);
2165                                 return schema;
2166                         }
2167                 }
2168
2169                 public class PrimitiveSchema : IXmlSerializable
2170                 {
2171                         private string _firstName;
2172                         private string _lastName;
2173                         private string _address;
2174
2175                         public virtual XmlSchema GetSchema ()
2176                         {
2177                                 XmlSchema schema = new XmlSchema ();
2178                                 schema.Id = "LuckyNumberSchema";
2179                                 XmlSchemaElement luckyNumberElement = new XmlSchemaElement ();
2180                                 luckyNumberElement.Name = "LuckyNumber";
2181                                 luckyNumberElement.SchemaTypeName = new XmlQualifiedName ("int", "http://www.w3.org/2001/XMLSchema");
2182                                 schema.Items.Add (luckyNumberElement);
2183                                 return schema;
2184                         }
2185
2186                         public void WriteXml (XmlWriter writer)
2187                         {
2188                                 writer.WriteStartElement ("employee", "urn:devx-com");
2189                                 writer.WriteAttributeString ("firstName", _firstName);
2190                                 writer.WriteAttributeString ("lastName", _lastName);
2191                                 writer.WriteAttributeString ("address", _address);
2192                                 writer.WriteEndElement ();
2193                         }
2194
2195                         public void ReadXml (XmlReader reader)
2196                         {
2197                                 XmlNodeType type = reader.MoveToContent ();
2198                                 if (type == XmlNodeType.Element && reader.LocalName == "employee") {
2199                                         _firstName = reader["firstName"];
2200                                         _lastName = reader["lastName"];
2201                                         _address = reader["address"];
2202                                 }
2203                         }
2204                 }
2205
2206                 public class MissingIDSchema : IXmlSerializable
2207                 {
2208                         private string _firstName;
2209                         private string _lastName;
2210                         private string _address;
2211
2212                         public virtual XmlSchema GetSchema ()
2213                         {
2214                                 XmlSchema schema = new XmlSchema ();
2215                                 XmlSchemaElement luckyNumberElement = new XmlSchemaElement ();
2216                                 luckyNumberElement.Name = "LuckyNumber";
2217                                 luckyNumberElement.SchemaTypeName = new XmlQualifiedName ("int", "http://www.w3.org/2001/XMLSchema");
2218                                 return schema;
2219                         }
2220
2221                         public void WriteXml (XmlWriter writer)
2222                         {
2223                                 writer.WriteStartElement ("employee", "urn:devx-com");
2224                                 writer.WriteAttributeString ("firstName", _firstName);
2225                                 writer.WriteAttributeString ("lastName", _lastName);
2226                                 writer.WriteAttributeString ("address", _address);
2227                                 writer.WriteEndElement ();
2228                         }
2229
2230                         public void ReadXml (XmlReader reader)
2231                         {
2232                                 XmlNodeType type = reader.MoveToContent ();
2233                                 if (type == XmlNodeType.Element && reader.LocalName == "employee") {
2234                                         _firstName = reader["firstName"];
2235                                         _lastName = reader["lastName"];
2236                                         _address = reader["address"];
2237                                 }
2238                         }
2239                 }
2240
2241 #if NET_2_0
2242                 [XmlSchemaProvider ("CreateEmployeeSchema")]
2243 #endif
2244                 public class EmployeeSchemaProvider : EmployeeSchema
2245                 {
2246 #if NET_2_0
2247                         public static XmlQualifiedName CreateEmployeeSchema (XmlSchemaSet schemaSet)
2248                         {
2249                                 schemaSet.Add (CreateSchema ());
2250                                 return new XmlQualifiedName ("employeeRoot", "urn:types-devx-com");
2251                         }
2252 #else
2253                         public override XmlSchema GetSchema ()
2254                         {
2255                                 return null;
2256                         }
2257 #endif
2258                 }
2259
2260 #if NET_2_0
2261                 [XmlSchemaProvider ("CreateLuckyNumberSchema")]
2262 #endif
2263                 public class PrimitiveSchemaProvider : IXmlSerializable
2264                 {
2265 #if NET_2_0
2266                         public static XmlQualifiedName CreateLuckyNumberSchema (XmlSchemaSet schemaSet)
2267                         {
2268                                 XmlSchema schema = new XmlSchema ();
2269
2270                                 XmlSchemaElement luckyNumberElement = new XmlSchemaElement ();
2271                                 luckyNumberElement.Name = "LuckyNumber";
2272
2273                                 XmlQualifiedName typeName = new XmlQualifiedName("int", "http://www.w3.org/2001/XMLSchema");
2274                                 luckyNumberElement.SchemaTypeName = typeName;
2275                                 schema.Items.Add (luckyNumberElement);
2276
2277                                 schemaSet.Add (schema);
2278                                 return typeName;
2279                         }
2280 #endif
2281
2282                         public XmlSchema GetSchema ()
2283                         {
2284                                 return null;
2285                         }
2286
2287                         public void WriteXml (XmlWriter writer)
2288                         {
2289                                 writer.WriteElementString ("LuckyNumber", "7");
2290                         }
2291
2292                         public void ReadXml (XmlReader reader)
2293                         {
2294                                 XmlNodeType type = reader.MoveToContent ();
2295                                 if (type == XmlNodeType.Element && reader.LocalName == "LuckyNumber") {
2296                                 }
2297                         }
2298                 }
2299
2300                 private class TypeDescription
2301                 {
2302                         public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType) : this (type, xsdType, xmlType, arrayType, false)
2303                         {
2304                         }
2305
2306                         public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType, bool isNillable)
2307                         {
2308                                 _type = type;
2309                                 _xsdType = xsdType;
2310                                 _xmlType = xmlType;
2311                                 _arrayType = arrayType;
2312                                 _isNillable = isNillable;
2313                         }
2314
2315                         public Type Type {
2316                                 get { return _type; }
2317                         }
2318
2319                         public string XmlType {
2320                                 get { return _xmlType; }
2321                         }
2322
2323                         public string ArrayType {
2324                                 get { return _arrayType; }
2325                         }
2326
2327                         public bool XsdType {
2328                                 get { return _xsdType; }
2329                         }
2330
2331                         public bool IsNillable {
2332                                 get { return _isNillable; }
2333                         }
2334
2335                         private Type _type;
2336                         private bool _xsdType;
2337                         private string _xmlType;
2338                         private string _arrayType;
2339                         private bool _isNillable;
2340                 }
2341
2342                 public class StructContainer
2343                 {
2344                         public EnumDefaultValue Value;
2345                         public TimeSpan[] Times;
2346                 }
2347
2348                 public class XmlSerializableContainer
2349                 {
2350                         public Employee Slave;
2351                         public EmployeeSchema SlaveSchema;
2352                         public EmployeeSchemaProvider SlaveSchemaProvider;
2353                         public PrimitiveSchema NativeSchema;
2354                         public PrimitiveSchemaProvider NativeSchemaProvider;
2355
2356                         [XmlElement ("SlaveNamespace", Namespace = "urn:types-devx-com")]
2357                         public Employee SlaveNS;
2358                         [XmlElement ("SlaveSchemaNamespace", Namespace = "urn:types-devx-com")]
2359                         public EmployeeSchema SlaveSchemaNS;
2360                         [XmlElement ("SlaveSchemaProviderNamespace", Namespace = "urn:types-devx-com")]
2361                         public EmployeeSchemaProvider SlaveSchemaProviderNS;
2362                         [XmlElement ("NativeSchemaNamespace", Namespace = "urn:types-devx-com")]
2363                         public PrimitiveSchema NativeSchemaNS;
2364                         [XmlElement ("NativeSchemaProviderNamespace", Namespace = "urn:types-devx-com")]
2365                         public PrimitiveSchemaProvider NativeSchemaProviderNS;
2366
2367
2368                         [XmlElement (Namespace = "urn:types-devx-com")]
2369                         public Employee SlaveNSOnly;
2370                         [XmlElement (Namespace = "urn:types-devx-com")]
2371                         public EmployeeSchema SlaveSchemaNSOnly;
2372                         [XmlElement (Namespace = "urn:types-devx-com")]
2373                         public EmployeeSchemaProvider SlaveSchemaProviderNSOnly;
2374                         [XmlElement (Namespace = "urn:types-devx-com")]
2375                         public PrimitiveSchema NativeSchemaNSOnly;
2376                         [XmlElement (Namespace = "urn:types-devx-com")]
2377                         public PrimitiveSchemaProvider NativeSchemaProviderNSOnly;
2378                 }
2379         }
2380 }