[runtime] Fix corlib out of date error with disabled COM
[mono.git] / mcs / class / System.XML / Test / System.Xml.Serialization / XmlCodeExporterTests.cs
1 //
2 // System.Xml.Serialization.XmlCodeExporterTests
3 //
4 // Author:
5 //   Gert Driesen (drieseng@users.sourceforge.net)
6 //
7 // (C) Gert Driesen (drieseng@users.sourceforge.net)
8 // (C) 2006 Novell
9 // 
10
11 #if !MOBILE
12
13 using System;
14 using System.CodeDom;
15 using System.CodeDom.Compiler;
16 using System.Collections;
17 using System.Globalization;
18 using System.IO;
19 using System.Reflection;
20 using System.Xml;
21 using System.Xml.Schema;
22 using System.Xml.Serialization;
23
24 using Microsoft.CSharp;
25
26 using NUnit.Framework;
27
28 using MonoTests.System.Xml.TestClasses;
29
30 namespace MonoTests.System.XmlSerialization
31 {
32         [TestFixture]
33         public class XmlCodeExporterTests
34         {
35                 [Test]
36                 public void ExportTypeMapping_ArrayClass ()
37                 {
38                         CodeNamespace codeNamespace = ExportCode (typeof (ArrayClass));
39                         Assert.IsNotNull (codeNamespace, "#1");
40
41                         StringWriter sw = new StringWriter ();
42                         CodeDomProvider provider = new CSharpCodeProvider ();
43                         ICodeGenerator generator = provider.CreateGenerator ();
44                         generator.GenerateCodeFromNamespace (codeNamespace, sw, new CodeGeneratorOptions ());
45
46                         Assert.AreEqual (string.Format(CultureInfo.InvariantCulture,
47                                 "{0}{0}" +
48                                 "/// <remarks/>{0}" +
49                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
50                                 "[System.SerializableAttribute()]{0}" +
51                                 "[System.Diagnostics.DebuggerStepThroughAttribute()]{0}" +
52                                 "[System.ComponentModel.DesignerCategoryAttribute(\"code\")]{0}" +
53                                 "[System.Xml.Serialization.XmlRootAttribute(Namespace=\"\", IsNullable=true)]{0}" +
54                                 "public partial class ArrayClass {{{0}" +
55                                 "    {0}" +
56                                 "    private object namesField;{0}" +
57                                 "    {0}" +
58                                 "    /// <remarks/>{0}" +
59                                 "    public object names {{{0}" +
60                                 "        get {{{0}" +
61                                 "            return this.namesField;{0}" +
62                                 "        }}{0}" +
63                                 "        set {{{0}" +
64                                 "            this.namesField = value;{0}" +
65                                 "        }}{0}" +
66                                 "    }}{0}" +
67                                 "}}{0}", Environment.NewLine), sw.ToString (), "#2");
68
69
70                         codeNamespace = ExportCode (typeof (ArrayClass[]));
71                         Assert.IsNotNull (codeNamespace, "#3");
72
73                         sw.GetStringBuilder ().Length = 0;
74                         generator.GenerateCodeFromNamespace (codeNamespace, sw, new CodeGeneratorOptions ());
75
76                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
77                                 "{0}{0}" +
78                                 "/// <remarks/>{0}" +
79                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
80                                 "[System.SerializableAttribute()]{0}" +
81                                 "[System.Diagnostics.DebuggerStepThroughAttribute()]{0}" +
82                                 "[System.ComponentModel.DesignerCategoryAttribute(\"code\")]{0}" +
83                                 "public partial class ArrayClass {{{0}" +
84                                 "    {0}" +
85                                 "    private object namesField;{0}" +
86                                 "    {0}" +
87                                 "    /// <remarks/>{0}" +
88                                 "    public object names {{{0}" +
89                                 "        get {{{0}" +
90                                 "            return this.namesField;{0}" +
91                                 "        }}{0}" +
92                                 "        set {{{0}" +
93                                 "            this.namesField = value;{0}" +
94                                 "        }}{0}" +
95                                 "    }}{0}" +
96                                 "}}{0}", Environment.NewLine), sw.ToString (), "#4");
97                 }
98
99                 [Test]
100                 public void ExportTypeMapping_ArrayContainer ()
101                 {
102                         CodeNamespace codeNamespace = ExportCode (typeof (ArrayContainer));
103                         Assert.IsNotNull (codeNamespace, "#1");
104
105                         StringWriter sw = new StringWriter ();
106                         CodeDomProvider provider = new CSharpCodeProvider ();
107                         ICodeGenerator generator = provider.CreateGenerator ();
108                         generator.GenerateCodeFromNamespace (codeNamespace, sw, new CodeGeneratorOptions ());
109
110                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
111                                 "{0}{0}" +
112                                 "/// <remarks/>{0}" +
113                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
114                                 "[System.SerializableAttribute()]{0}" +
115                                 "[System.Diagnostics.DebuggerStepThroughAttribute()]{0}" +
116                                 "[System.ComponentModel.DesignerCategoryAttribute(\"code\")]{0}" +
117                                 "[System.Xml.Serialization.XmlRootAttribute(Namespace=\"\", IsNullable=true)]{0}" +
118                                 "public partial class ArrayContainer {{{0}" +
119                                 "    {0}" +
120                                 "    private object[] itemsField;{0}" +
121                                 "    {0}" +
122                                 "    /// <remarks/>{0}" +
123                                 "    public object[] items {{{0}" +
124                                 "        get {{{0}" +
125                                 "            return this.itemsField;{0}" +
126                                 "        }}{0}" +
127                                 "        set {{{0}" +
128                                 "            this.itemsField = value;{0}" +
129                                 "        }}{0}" +
130                                 "    }}{0}" +
131                                 "}}{0}", Environment.NewLine), sw.ToString (), "#2");
132                 }
133
134                 [Test]
135                 public void ExportTypeMapping_CDataContainer ()
136                 {
137                         CodeNamespace codeNamespace = ExportCode (typeof (CDataContainer));
138                         Assert.IsNotNull (codeNamespace, "#1");
139
140                         StringWriter sw = new StringWriter ();
141                         CodeDomProvider provider = new CSharpCodeProvider ();
142                         ICodeGenerator generator = provider.CreateGenerator ();
143                         generator.GenerateCodeFromNamespace (codeNamespace, sw, new CodeGeneratorOptions ());
144
145                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
146                                 "{0}{0}" +
147                                 "/// <remarks/>{0}" +
148                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
149                                 "[System.SerializableAttribute()]{0}" +
150                                 "[System.Diagnostics.DebuggerStepThroughAttribute()]{0}" +
151                                 "[System.ComponentModel.DesignerCategoryAttribute(\"code\")]{0}" +
152                                 "[System.Xml.Serialization.XmlRootAttribute(Namespace=\"\", IsNullable=true)]{0}" +
153                                 "public partial class CDataContainer {{{0}" +
154                                 "    {0}" +
155                                 "    private System.Xml.XmlCDataSection cdataField;{0}" +
156                                 "    {0}" +
157                                 "    /// <remarks/>{0}" +
158                                 "    public System.Xml.XmlCDataSection cdata {{{0}" +
159                                 "        get {{{0}" +
160                                 "            return this.cdataField;{0}" +
161                                 "        }}{0}" +
162                                 "        set {{{0}" +
163                                 "            this.cdataField = value;{0}" +
164                                 "        }}{0}" +
165                                 "    }}{0}" +
166                                 "}}{0}", Environment.NewLine), sw.ToString (), "#2");
167                 }
168
169                 [Test]
170                 [Category ("NotWorking")] // order of XmlElementAttribute's does not match that of MSFT
171                 [Category ("NotDotNet")] // Mono bug ##77117 and MS.NET randomly modifies the order of the elements!
172                 public void ExportTypeMapping_Choices ()
173                 {
174                         CodeNamespace codeNamespace = ExportCode (typeof (Choices));
175                         Assert.IsNotNull (codeNamespace, "#1");
176
177                         StringWriter sw = new StringWriter ();
178                         CodeDomProvider provider = new CSharpCodeProvider ();
179                         ICodeGenerator generator = provider.CreateGenerator ();
180                         generator.GenerateCodeFromNamespace (codeNamespace, sw, new CodeGeneratorOptions ());
181
182                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
183                                 "{0}{0}" +
184                                 "/// <remarks/>{0}" +
185                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
186                                 "[System.SerializableAttribute()]{0}" +
187                                 "[System.Diagnostics.DebuggerStepThroughAttribute()]{0}" +
188                                 "[System.ComponentModel.DesignerCategoryAttribute(\"code\")]{0}" +
189                                 "[System.Xml.Serialization.XmlRootAttribute(Namespace=\"\", IsNullable=true)]{0}" +
190                                 "public partial class Choices {{{0}" +
191                                 "    {0}" +
192                                 "    private string myChoiceField;{0}" +
193                                 "    {0}" +
194                                 "    /// <remarks/>{0}" +
195                                 "    [System.Xml.Serialization.XmlElementAttribute(\"ChoiceZero\", typeof(string))]{0}" +
196                                 "    [System.Xml.Serialization.XmlElementAttribute(\"ChoiceOne\", typeof(string))]{0}" +
197                                 "    [System.Xml.Serialization.XmlElementAttribute(\"ChoiceTwo\", typeof(string))]{0}" +
198                                 "    [System.Xml.Serialization.XmlChoiceIdentifierAttribute(\"ItemType\")]{0}" +
199                                 "    public string MyChoice {{{0}" +
200                                 "        get {{{0}" +
201                                 "            return this.myChoiceField;{0}" +
202                                 "        }}{0}" +
203                                 "        set {{{0}" +
204                                 "            this.myChoiceField = value;{0}" +
205                                 "        }}{0}" +
206                                 "    }}{0}" +
207                                 "}}{0}", Environment.NewLine), sw.ToString (), "#2");
208                 }
209
210                 [Test]
211                 [Category ("NotWorking")] // TODO: order of DefaultValueAttribute, ...
212                 public void ExportTypeMapping_Field ()
213                 {
214                         CodeNamespace codeNamespace = ExportCode (typeof (Field));
215                         Assert.IsNotNull (codeNamespace, "#1");
216
217                         StringWriter sw = new StringWriter ();
218                         CodeDomProvider provider = new CSharpCodeProvider ();
219                         ICodeGenerator generator = provider.CreateGenerator ();
220                         generator.GenerateCodeFromNamespace (codeNamespace, sw, new CodeGeneratorOptions ());
221
222                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
223                                 "{0}{0}" +
224                                 "/// <remarks/>{0}" +
225                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
226                                 "[System.SerializableAttribute()]{0}" +
227                                 "[System.Diagnostics.DebuggerStepThroughAttribute()]{0}" +
228                                 "[System.ComponentModel.DesignerCategoryAttribute(\"code\")]{0}" +
229                                 "[System.Xml.Serialization.XmlRootAttribute(\"field\", Namespace=\"\", IsNullable=true)]{0}" +
230                                 "public partial class Field {{{0}" +
231                                 "    {0}" +
232                                 "    private MonoTests.System.Xml.TestClasses.FlagEnum flags1Field;{0}" +
233                                 "    {0}" +
234                                 "    private MonoTests.System.Xml.TestClasses.FlagEnum flags2Field;{0}" +
235                                 "    {0}" +
236                                 "    private MonoTests.System.Xml.TestClasses.FlagEnum flags3Field;{0}" +
237                                 "    {0}" +
238                                 "    private MonoTests.System.Xml.TestClasses.FlagEnum flags4Field;{0}" +
239                                 "    {0}" +
240                                 "    private MonoTests.System.Xml.TestClasses.MapModifiers modifiersField;{0}" +
241                                 "    {0}" +
242                                 "    private MonoTests.System.Xml.TestClasses.MapModifiers modifiers2Field;{0}" +
243                                 "    {0}" +
244                                 "    private MonoTests.System.Xml.TestClasses.MapModifiers modifiers3Field;{0}" +
245                                 "    {0}" +
246                                 "    private MonoTests.System.Xml.TestClasses.MapModifiers modifiers4Field;{0}" +
247                                 "    {0}" +
248                                 "    private MonoTests.System.Xml.TestClasses.MapModifiers modifiers5Field;{0}" +
249                                 "    {0}" +
250                                 "    private string[] namesField;{0}" +
251                                 "    {0}" +
252                                 "    private string streetField;{0}" +
253                                 "    {0}" +
254                                 "    public Field() {{{0}" +
255                                 "        this.flags1Field = MonoTests.System.Xml.TestClasses.FlagEnum.e1;{0}" +
256                                 "        this.flags2Field = MonoTests.System.Xml.TestClasses.FlagEnum.e1;{0}" +
257                                 "        this.flags3Field = (MonoTests.System.Xml.TestClasses.FlagEnum.e1 | MonoTests.System.Xml.TestClasses.FlagEnum.e2);{0}" +
258                                 "        this.modifiers3Field = MonoTests.System.Xml.TestClasses.MapModifiers.Public;{0}" +
259                                 "        this.modifiers4Field = MonoTests.System.Xml.TestClasses.MapModifiers.Protected;{0}" +
260                                 "        this.modifiers5Field = MonoTests.System.Xml.TestClasses.MapModifiers.Public;{0}" +
261                                 "    }}{0}" +
262                                 "    {0}" +
263                                 "    /// <remarks/>{0}" +
264                                 "    [System.Xml.Serialization.XmlAttributeAttribute(\"flag1\")]{0}" +
265                                 "    public MonoTests.System.Xml.TestClasses.FlagEnum Flags1 {{{0}" +
266                                 "        get {{{0}" +
267                                 "            return this.flags1Field;{0}" +
268                                 "        }}{0}" +
269                                 "        set {{{0}" +
270                                 "            this.flags1Field = value;{0}" +
271                                 "        }}{0}" +
272                                 "    }}{0}" +
273                                 "    {0}" +
274                                 "    /// <remarks/>{0}" +
275                                 "    [System.Xml.Serialization.XmlAttributeAttribute(\"flag2\")]{0}" +
276                                 "    public MonoTests.System.Xml.TestClasses.FlagEnum Flags2 {{{0}" +
277                                 "        get {{{0}" +
278                                 "            return this.flags2Field;{0}" +
279                                 "        }}{0}" +
280                                 "        set {{{0}" +
281                                 "            this.flags2Field = value;{0}" +
282                                 "        }}{0}" +
283                                 "    }}{0}" +
284                                 "    {0}" +
285                                 "    /// <remarks/>{0}" +
286                                 "    [System.Xml.Serialization.XmlAttributeAttribute(\"flag3\", Form=System.Xml.Schema.XmlSchemaForm.Qualified)]{0}" +
287                                 "    public MonoTests.System.Xml.TestClasses.FlagEnum Flags3 {{{0}" +
288                                 "        get {{{0}" +
289                                 "            return this.flags3Field;{0}" +
290                                 "        }}{0}" +
291                                 "        set {{{0}" +
292                                 "            this.flags3Field = value;{0}" +
293                                 "        }}{0}" +
294                                 "    }}{0}" +
295                                 "    {0}" +
296                                 "    /// <remarks/>{0}" +
297                                 "    [System.Xml.Serialization.XmlAttributeAttribute(\"flag4\")]{0}" +
298                                 "    public MonoTests.System.Xml.TestClasses.FlagEnum Flags4 {{{0}" +
299                                 "        get {{{0}" +
300                                 "            return this.flags4Field;{0}" +
301                                 "        }}{0}" +
302                                 "        set {{{0}" +
303                                 "            this.flags4Field = value;{0}" +
304                                 "        }}{0}" +
305                                 "    }}{0}" +
306                                 "    {0}" +
307                                 "    /// <remarks/>{0}" +
308                                 "    [System.Xml.Serialization.XmlAttributeAttribute(\"modifiers\")]{0}" +
309                                 "    public MonoTests.System.Xml.TestClasses.MapModifiers Modifiers {{{0}" +
310                                 "        get {{{0}" +
311                                 "            return this.modifiersField;{0}" +
312                                 "        }}{0}" +
313                                 "        set {{{0}" +
314                                 "            this.modifiersField = value;{0}" +
315                                 "        }}{0}" +
316                                 "    }}{0}" +
317                                 "    {0}" +
318                                 "    /// <remarks/>{0}" +
319                                 "    [System.Xml.Serialization.XmlAttributeAttribute(\"modifiers2\")]{0}" +
320                                 "    public MonoTests.System.Xml.TestClasses.MapModifiers Modifiers2 {{{0}" +
321                                 "        get {{{0}" +
322                                 "            return this.modifiers2Field;{0}" +
323                                 "        }}{0}" +
324                                 "        set {{{0}" +
325                                 "            this.modifiers2Field = value;{0}" +
326                                 "        }}{0}" +
327                                 "    }}{0}" +
328                                 "    {0}" +
329                                 "    /// <remarks/>{0}" +
330                                 "    [System.Xml.Serialization.XmlAttributeAttribute(\"modifiers3\")]{0}" +
331                                 "    public MonoTests.System.Xml.TestClasses.MapModifiers Modifiers3 {{{0}" +
332                                 "        get {{{0}" +
333                                 "            return this.modifiers3Field;{0}" +
334                                 "        }}{0}" +
335                                 "        set {{{0}" +
336                                 "            this.modifiers3Field = value;{0}" +
337                                 "        }}{0}" +
338                                 "    }}{0}" +
339                                 "    {0}" +
340                                 "    /// <remarks/>{0}" +
341                                 "    [System.Xml.Serialization.XmlAttributeAttribute(\"modifiers4\")]{0}" +
342                                 "    public MonoTests.System.Xml.TestClasses.MapModifiers Modifiers4 {{{0}" +
343                                 "        get {{{0}" +
344                                 "            return this.modifiers4Field;{0}" +
345                                 "        }}{0}" +
346                                 "        set {{{0}" +
347                                 "            this.modifiers4Field = value;{0}" +
348                                 "        }}{0}" +
349                                 "    }}{0}" +
350                                 "    {0}" +
351                                 "    /// <remarks/>{0}" +
352                                 "    [System.Xml.Serialization.XmlAttributeAttribute(\"modifiers5\", Form=System.Xml.Schema.XmlSchemaForm.Qualified)]{0}" +
353                                 "    public MonoTests.System.Xml.TestClasses.MapModifiers Modifiers5 {{{0}" +
354                                 "        get {{{0}" +
355                                 "            return this.modifiers5Field;{0}" +
356                                 "        }}{0}" +
357                                 "        set {{{0}" +
358                                 "            this.modifiers5Field = value;{0}" +
359                                 "        }}{0}" +
360                                 "    }}{0}" +
361                                 "    {0}" +
362                                 "    /// <remarks/>{0}" +
363                                 "    [System.Xml.Serialization.XmlAttributeAttribute(\"names\")]{0}" +
364                                 "    public string[] Names {{{0}" +
365                                 "        get {{{0}" +
366                                 "            return this.namesField;{0}" +
367                                 "        }}{0}" +
368                                 "        set {{{0}" +
369                                 "            this.namesField = value;{0}" +
370                                 "        }}{0}" +
371                                 "    }}{0}" +
372                                 "    {0}" +
373                                 "    /// <remarks/>{0}" +
374                                 "    [System.Xml.Serialization.XmlAttributeAttribute(\"street\")]{0}" +
375                                 "    public string Street {{{0}" +
376                                 "        get {{{0}" +
377                                 "            return this.streetField;{0}" +
378                                 "        }}{0}" +
379                                 "        set {{{0}" +
380                                 "            this.streetField = value;{0}" +
381                                 "        }}{0}" +
382                                 "    }}{0}" +
383                                 "}}{0}" +
384                                 "{0}" +
385                                 "/// <remarks/>{0}" +
386                                 "[System.FlagsAttribute()]{0}" +
387                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"System.Xml\", \"{1}\")]{0}" +
388                                 "[System.SerializableAttribute()]{0}" +
389                                 "public enum FlagEnum {{{0}" +
390                                 "    {0}" +
391                                 "    /// <remarks/>{0}" +
392                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"one\")]{0}" +
393                                 "    e1 = 1,{0}" +
394                                 "    {0}" +
395                                 "    /// <remarks/>{0}" +
396                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"two\")]{0}" +
397                                 "    e2 = 2,{0}" +
398                                 "    {0}" +
399                                 "    /// <remarks/>{0}" +
400                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"four\")]{0}" +
401                                 "    e4 = 4,{0}" +
402                                 "}}{0}" +
403                                 "{0}" +
404                                 "/// <remarks/>{0}" +
405                                 "[System.FlagsAttribute()]{0}" +
406                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
407                                 "[System.SerializableAttribute()]{0}" +
408                                 "public enum MapModifiers {{{0}" +
409                                 "    {0}" +
410                                 "    /// <remarks/>{0}" +
411                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"public\")]{0}" +
412                                 "    Public = 1,{0}" +
413                                 "    {0}" +
414                                 "    /// <remarks/>{0}" +
415                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"protected\")]{0}" +
416                                 "    Protected = 2,{0}" +
417                                 "}}{0}", Environment.NewLine), sw.ToString (), "#2");
418                 }
419
420                 [Test]
421                 public void ExportTypeMapping_ItemChoiceType ()
422                 {
423                         CodeNamespace codeNamespace = ExportCode (typeof (ItemChoiceType));
424                         Assert.IsNotNull (codeNamespace, "#1");
425
426                         StringWriter sw = new StringWriter ();
427                         CodeDomProvider provider = new CSharpCodeProvider ();
428                         ICodeGenerator generator = provider.CreateGenerator ();
429                         generator.GenerateCodeFromNamespace (codeNamespace, sw, new CodeGeneratorOptions ());
430
431                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
432                                 "{0}{0}" +
433                                 "/// <remarks/>{0}" +
434                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
435                                 "[System.SerializableAttribute()]{0}" +
436                                 "[System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema=false)]{0}" +
437                                 "[System.Xml.Serialization.XmlRootAttribute(Namespace=\"\", IsNullable=false)]{0}" +
438                                 "public enum ItemChoiceType {{{0}" +
439                                 "    {0}" +
440                                 "    /// <remarks/>{0}" +
441                                 "    ChoiceZero,{0}" +
442                                 "    {0}" +
443                                 "    /// <remarks/>{0}" +
444                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"ChoiceOne\")]{0}" +
445                                 "    StrangeOne,{0}" +
446                                 "    {0}" +
447                                 "    /// <remarks/>{0}" +
448                                 "    ChoiceTwo,{0}" +
449                                 "}}{0}", Environment.NewLine), sw.ToString (), "#2");
450
451                         codeNamespace = ExportCode (typeof (ItemChoiceType[]));
452                         Assert.IsNotNull (codeNamespace, "#3");
453
454                         sw.GetStringBuilder ().Length = 0;
455                         generator.GenerateCodeFromNamespace (codeNamespace, sw, new CodeGeneratorOptions ());
456
457                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
458                                 "{0}{0}" +
459                                 "/// <remarks/>{0}" +
460                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
461                                 "[System.SerializableAttribute()]{0}" +
462                                 "[System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema=false)]{0}" +
463                                 "public enum ItemChoiceType {{{0}" +
464                                 "    {0}" +
465                                 "    /// <remarks/>{0}" +
466                                 "    ChoiceZero,{0}" +
467                                 "    {0}" +
468                                 "    /// <remarks/>{0}" +
469                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"ChoiceOne\")]{0}" +
470                                 "    StrangeOne,{0}" +
471                                 "    {0}" +
472                                 "    /// <remarks/>{0}" +
473                                 "    ChoiceTwo,{0}" +
474                                 "}}{0}", Environment.NewLine), sw.ToString (), "#4");
475                 }
476
477                 [Test]
478                 public void ExportTypeMapping_ClassArrayContainer ()
479                 {
480                         CodeNamespace codeNamespace = ExportCode (typeof (ClassArrayContainer));
481                         Assert.IsNotNull (codeNamespace, "#1");
482
483                         StringWriter sw = new StringWriter ();
484                         CodeDomProvider provider = new CSharpCodeProvider ();
485                         ICodeGenerator generator = provider.CreateGenerator ();
486                         generator.GenerateCodeFromNamespace (codeNamespace, sw, new CodeGeneratorOptions ());
487
488                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
489                                 "{0}{0}" +
490                                 "/// <remarks/>{0}" +
491                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
492                                 "[System.SerializableAttribute()]{0}" +
493                                 "[System.Diagnostics.DebuggerStepThroughAttribute()]{0}" +
494                                 "[System.ComponentModel.DesignerCategoryAttribute(\"code\")]{0}" +
495                                 "[System.Xml.Serialization.XmlRootAttribute(Namespace=\"\", IsNullable=true)]{0}" +
496                                 "public partial class ClassArrayContainer {{{0}" +
497                                 "    {0}" +
498                                 "    private MonoTests.System.Xml.TestClasses.SimpleClass[] itemsField;{0}" +
499                                 "    {0}" +
500                                 "    /// <remarks/>{0}" +
501                                 "    public MonoTests.System.Xml.TestClasses.SimpleClass[] items {{{0}" +
502                                 "        get {{{0}" +
503                                 "            return this.itemsField;{0}" +
504                                 "        }}{0}" +
505                                 "        set {{{0}" +
506                                 "            this.itemsField = value;{0}" +
507                                 "        }}{0}" +
508                                 "    }}{0}" +
509                                 "}}{0}" +
510                                 "{0}" +
511                                 "/// <remarks/>{0}" +
512                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
513                                 "[System.SerializableAttribute()]{0}" +
514                                 "[System.Diagnostics.DebuggerStepThroughAttribute()]{0}" +
515                                 "[System.ComponentModel.DesignerCategoryAttribute(\"code\")]{0}" +
516                                 "public partial class SimpleClass {{{0}" +
517                                 "    {0}" +
518                                 "    private string somethingField;{0}" +
519                                 "    {0}" +
520                                 "    /// <remarks/>{0}" +
521                                 "    public string something {{{0}" +
522                                 "        get {{{0}" +
523                                 "            return this.somethingField;{0}" +
524                                 "        }}{0}" +
525                                 "        set {{{0}" +
526                                 "            this.somethingField = value;{0}" +
527                                 "        }}{0}" +
528                                 "    }}{0}" +
529                                 "}}{0}", Environment.NewLine), sw.ToString (), "#2");
530                 }
531
532                 [Test]
533                 [Category ("NotWorking")] // bug #78214
534                 public void ExportTypeMapping_Root ()
535                 {
536                         CodeNamespace codeNamespace = ExportCode (typeof (Root));
537                         Assert.IsNotNull (codeNamespace, "#1");
538
539                         StringWriter sw = new StringWriter ();
540                         CodeDomProvider provider = new CSharpCodeProvider ();
541                         ICodeGenerator generator = provider.CreateGenerator ();
542                         generator.GenerateCodeFromNamespace (codeNamespace, sw, new CodeGeneratorOptions ());
543
544                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
545                                 "{0}{0}" +
546                                 "/// <remarks/>{0}" +
547                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
548                                 "[System.SerializableAttribute()]{0}" +
549                                 "[System.Diagnostics.DebuggerStepThroughAttribute()]{0}" +
550                                 "[System.ComponentModel.DesignerCategoryAttribute(\"code\")]{0}" +
551                                 "[System.Xml.Serialization.XmlTypeAttribute(Namespace=\"urn:aNS\")]{0}" +
552                                 "[System.Xml.Serialization.XmlRootAttribute(\"root\", Namespace=\"urn:aNS\", IsNullable=false)]{0}" +
553                                 "public partial class Root {{{0}" +
554                                 "    {0}" +
555                                 "    private MonoTests.System.Xml.TestClasses.OptionalValueTypeContainer optionalValueField;{0}" +
556                                 "    {0}" +
557                                 "    private MonoTests.System.Xml.TestClasses.TestDefault defaultField;{0}" +
558                                 "    {0}" +
559                                 "    /// <remarks/>{0}" +
560                                 "    public MonoTests.System.Xml.TestClasses.OptionalValueTypeContainer OptionalValue {{{0}" +
561                                 "        get {{{0}" +
562                                 "            return this.optionalValueField;{0}" +
563                                 "        }}{0}" +
564                                 "        set {{{0}" +
565                                 "            this.optionalValueField = value;{0}" +
566                                 "        }}{0}" +
567                                 "    }}{0}" +
568                                 "    {0}" +
569                                 "    /// <remarks/>{0}" +
570                                 "    public MonoTests.System.Xml.TestClasses.TestDefault Default {{{0}" +
571                                 "        get {{{0}" +
572                                 "            return this.defaultField;{0}" +
573                                 "        }}{0}" +
574                                 "        set {{{0}" +
575                                 "            this.defaultField = value;{0}" +
576                                 "        }}{0}" +
577                                 "    }}{0}" +
578                                 "}}{0}" +
579                                 "{0}" +
580                                 "/// <remarks/>{0}" +
581                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
582                                 "[System.SerializableAttribute()]{0}" +
583                                 "[System.Diagnostics.DebuggerStepThroughAttribute()]{0}" +
584                                 "[System.ComponentModel.DesignerCategoryAttribute(\"code\")]{0}" +
585                                 "[System.Xml.Serialization.XmlTypeAttribute(TypeName=\"optionalValueType\", Namespace=\"some:urn\")]{0}" +
586                                 "public partial class OptionalValueTypeContainer {{{0}" +
587                                 "    {0}" +
588                                 "    private MonoTests.System.Xml.TestClasses.FlagEnum attributesField;{0}" +
589                                 "    {0}" +
590                                 "    private MonoTests.System.Xml.TestClasses.FlagEnum flagsField;{0}" +
591                                 "    {0}" +
592                                 "    private bool flagsFieldSpecified;{0}" +
593                                 "    {0}" +
594                                 "    private bool isEmptyField;{0}" +
595                                 "    {0}" +
596                                 "    private bool isEmptyFieldSpecified;{0}" +
597                                 "    {0}" +
598                                 "    private bool isNullField;{0}" +
599                                 "    {0}" +
600                                 "    public OptionalValueTypeContainer() {{{0}" +
601                                 "        this.attributesField = (MonoTests.System.Xml.TestClasses.FlagEnum.e1 | MonoTests.System.Xml.TestClasses.FlagEnum.e4);{0}" +
602                                 "        this.flagsField = MonoTests.System.Xml.TestClasses.FlagEnum.e1;{0}" +
603                                 "    }}{0}" +
604                                 "    {0}" +
605                                 "    /// <remarks/>{0}" +
606                                 "    public MonoTests.System.Xml.TestClasses.FlagEnum Attributes {{{0}" +
607                                 "        get {{{0}" +
608                                 "            return this.attributesField;{0}" +
609                                 "        }}{0}" +
610                                 "        set {{{0}" +
611                                 "            this.attributesField = value;{0}" +
612                                 "        }}{0}" +
613                                 "    }}{0}" +
614                                 "    {0}" +
615                                 "    /// <remarks/>{0}" +
616                                 "    public MonoTests.System.Xml.TestClasses.FlagEnum Flags {{{0}" +
617                                 "        get {{{0}" +
618                                 "            return this.flagsField;{0}" +
619                                 "        }}{0}" +
620                                 "        set {{{0}" +
621                                 "            this.flagsField = value;{0}" +
622                                 "        }}{0}" +
623                                 "    }}{0}" +
624                                 "    {0}" +
625                                 "    /// <remarks/>{0}" +
626                                 "    [System.Xml.Serialization.XmlIgnoreAttribute()]{0}" +
627                                 "    public bool FlagsSpecified {{{0}" +
628                                 "        get {{{0}" +
629                                 "            return this.flagsFieldSpecified;{0}" +
630                                 "        }}{0}" +
631                                 "        set {{{0}" +
632                                 "            this.flagsFieldSpecified = value;{0}" +
633                                 "        }}{0}" +
634                                 "    }}{0}" +
635                                 "    {0}" +
636                                 "    /// <remarks/>{0}" +
637                                 "    public bool IsEmpty {{{0}" +
638                                 "        get {{{0}" +
639                                 "            return this.isEmptyField;{0}" +
640                                 "        }}{0}" +
641                                 "        set {{{0}" +
642                                 "            this.isEmptyField = value;{0}" +
643                                 "        }}{0}" +
644                                 "    }}{0}" +
645                                 "    {0}" +
646                                 "    /// <remarks/>{0}" +
647                                 "    [System.Xml.Serialization.XmlIgnoreAttribute()]{0}" +
648                                 "    public bool IsEmptySpecified {{{0}" +
649                                 "        get {{{0}" +
650                                 "            return this.isEmptyFieldSpecified;{0}" +
651                                 "        }}{0}" +
652                                 "        set {{{0}" +
653                                 "            this.isEmptyFieldSpecified = value;{0}" +
654                                 "        }}{0}" +
655                                 "    }}{0}" +
656                                 "    {0}" +
657                                 "    /// <remarks/>{0}" +
658                                 "    public bool IsNull {{{0}" +
659                                 "        get {{{0}" +
660                                 "            return this.isNullField;{0}" +
661                                 "        }}{0}" +
662                                 "        set {{{0}" +
663                                 "            this.isNullField = value;{0}" +
664                                 "        }}{0}" +
665                                 "    }}{0}" +
666                                 "}}{0}" +
667                                 "{0}" +
668                                 "/// <remarks/>{0}" +
669                                 "[System.FlagsAttribute()]{0}" +
670                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
671                                 "[System.SerializableAttribute()]{0}" +
672                                 "[System.Xml.Serialization.XmlTypeAttribute(Namespace=\"some:urn\")]{0}" +
673                                 "public enum FlagEnum {{{0}" +
674                                 "    {0}" +
675                                 "    /// <remarks/>{0}" +
676                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"one\")]{0}" +
677                                 "    e1 = 1,{0}" +
678                                 "    {0}" +
679                                 "    /// <remarks/>{0}" +
680                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"two\")]{0}" +
681                                 "    e2 = 2,{0}" +
682                                 "    {0}" +
683                                 "    /// <remarks/>{0}" +
684                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"four\")]{0}" +
685                                 "    e4 = 4,{0}" +
686                                 "}}{0}" +
687                                 "{0}" +
688                                 "/// <remarks/>{0}" +
689                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"System.Xml\", \"{1}\")]{0}" +
690                                 "[System.SerializableAttribute()]{0}" +
691                                 "[System.Diagnostics.DebuggerStepThroughAttribute()]{0}" +
692                                 "[System.ComponentModel.DesignerCategoryAttribute(\"code\")]{0}" +
693                                 "[System.Xml.Serialization.XmlTypeAttribute(Namespace=\"urn:myNS\")]{0}" +
694                                 "public partial class TestDefault {{{0}" +
695                                 "    {0}" +
696                                 "    private string strField;{0}" +
697                                 "    {0}" +
698                                 "    private string strDefaultField;{0}" +
699                                 "    {0}" +
700                                 "    private bool boolTField;{0}" +
701                                 "    {0}" +
702                                 "    private bool boolFField;{0}" +
703                                 "    {0}" +
704                                 "    private decimal decimalvalField;{0}" +
705                                 "    {0}" +
706                                 "    private MonoTests.System.Xml.TestClasses.FlagEnum flagField;{0}" +
707                                 "    {0}" +
708                                 "    private MonoTests.System.Xml.TestClasses.FlagEnum_Encoded flagencodedField;{0}" +
709                                 "    {0}" +
710                                 "    public TestDefault() {{{0}" +
711                                 "        this.strDefaultField = \"Default Value\";{0}" +
712                                 "        this.flagField = (MonoTests.System.Xml.TestClasses.FlagEnum.e1 | MonoTests.System.Xml.TestClasses.FlagEnum.e4);{0}" +
713                                 "        this.flagencodedField = (MonoTests.System.Xml.TestClasses.FlagEnum_Encoded.e1 | MonoTests.System.Xml.TestClasses.FlagEnum_Encoded.e4);{0}" +
714                                 "    }}{0}" +
715                                 "    {0}" +
716                                 "    /// <remarks/>{0}" +
717                                 "    public string str {{{0}" +
718                                 "        get {{{0}" +
719                                 "            return this.strField;{0}" +
720                                 "        }}{0}" +
721                                 "        set {{{0}" +
722                                 "            this.strField = value;{0}" +
723                                 "        }}{0}" +
724                                 "    }}{0}" +
725                                 "    {0}" +
726                                 "    /// <remarks/>{0}" +
727                                 "    public string strDefault {{{0}" +
728                                 "        get {{{0}" +
729                                 "            return this.strDefaultField;{0}" +
730                                 "        }}{0}" +
731                                 "        set {{{0}" +
732                                 "            this.strDefaultField = value;{0}" +
733                                 "        }}{0}" +
734                                 "    }}{0}" +
735                                 "    {0}" +
736                                 "    /// <remarks/>{0}" +
737                                 "    public bool boolT {{{0}" +
738                                 "        get {{{0}" +
739                                 "            return this.boolTField;{0}" +
740                                 "        }}{0}" +
741                                 "        set {{{0}" +
742                                 "            this.boolTField = value;{0}" +
743                                 "        }}{0}" +
744                                 "    }}{0}" +
745                                 "    {0}" +
746                                 "    /// <remarks/>{0}" +
747                                 "    public bool boolF {{{0}" +
748                                 "        get {{{0}" +
749                                 "            return this.boolFField;{0}" +
750                                 "        }}{0}" +
751                                 "        set {{{0}" +
752                                 "            this.boolFField = value;{0}" +
753                                 "        }}{0}" +
754                                 "    }}{0}" +
755                                 "    {0}" +
756                                 "    /// <remarks/>{0}" +
757                                 "    public decimal decimalval {{{0}" +
758                                 "        get {{{0}" +
759                                 "            return this.decimalvalField;{0}" +
760                                 "        }}{0}" +
761                                 "        set {{{0}" +
762                                 "            this.decimalvalField = value;{0}" +
763                                 "        }}{0}" +
764                                 "    }}{0}" +
765                                 "    {0}" +
766                                 "    /// <remarks/>{0}" +
767                                 "    public MonoTests.System.Xml.TestClasses.FlagEnum flag {{{0}" +
768                                 "        get {{{0}" +
769                                 "            return this.flagField;{0}" +
770                                 "        }}{0}" +
771                                 "        set {{{0}" +
772                                 "            this.flagField = value;{0}" +
773                                 "        }}{0}" +
774                                 "    }}{0}" +
775                                 "    {0}" +
776                                 "    /// <remarks/>{0}" +
777                                 "    public MonoTests.System.Xml.TestClasses.FlagEnum_Encoded flagencoded {{{0}" +
778                                 "        get {{{0}" +
779                                 "            return this.flagencodedField;{0}" +
780                                 "        }}{0}" +
781                                 "        set {{{0}" +
782                                 "            this.flagencodedField = value;{0}" +
783                                 "        }}{0}" +
784                                 "    }}{0}" +
785                                 "}}{0}" +
786                                 "{0}" +
787                                 "/// <remarks/>{0}" +
788                                 "[System.FlagsAttribute()]{0}" +
789                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
790                                 "[System.SerializableAttribute()]{0}" +
791                                 "[System.Xml.Serialization.XmlTypeAttribute(Namespace=\"urn:myNS\")]{0}" +
792                                 "public enum FlagEnum {{{0}" +
793                                 "    {0}" +
794                                 "    /// <remarks/>{0}" +
795                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"one\")]{0}" +
796                                 "    e1 = 1,{0}" +
797                                 "    {0}" +
798                                 "    /// <remarks/>{0}" +
799                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"two\")]{0}" +
800                                 "    e2 = 2,{0}" +
801                                 "    {0}" +
802                                 "    /// <remarks/>{0}" +
803                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"four\")]{0}" +
804                                 "    e4 = 4,{0}" +
805                                 "}}{0}" +
806                                 "{0}" +
807                                 "/// <remarks/>{0}" +
808                                 "[System.FlagsAttribute()]{0}" +
809                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
810                                 "[System.SerializableAttribute()]{0}" +
811                                 "[System.Xml.Serialization.XmlTypeAttribute(Namespace=\"urn:myNS\")]{0}" +
812                                 "public enum FlagEnum_Encoded {{{0}" +
813                                 "    {0}" +
814                                 "    /// <remarks/>{0}" +
815                                 "    e1 = 1,{0}" +
816                                 "    {0}" +
817                                 "    /// <remarks/>{0}" +
818                                 "    e2 = 2,{0}" +
819                                 "    {0}" +
820                                 "    /// <remarks/>{0}" +
821                                 "    e4 = 4,{0}" +
822                                 "}}{0}", Environment.NewLine), sw.ToString (), "#2");
823                 }
824
825                 [Test]
826                 public void ExportTypeMapping_SimpleClassWithXmlAttributes ()
827                 {
828                         CodeNamespace codeNamespace = ExportCode (typeof (SimpleClassWithXmlAttributes));
829                         Assert.IsNotNull (codeNamespace, "#1");
830
831                         StringWriter sw = new StringWriter ();
832                         CodeDomProvider provider = new CSharpCodeProvider ();
833                         ICodeGenerator generator = provider.CreateGenerator ();
834                         generator.GenerateCodeFromNamespace (codeNamespace, sw, new CodeGeneratorOptions ());
835
836                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
837                                 "{0}{0}" +
838                                 "/// <remarks/>{0}" +
839                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
840                                 "[System.SerializableAttribute()]{0}" +
841                                 "[System.Diagnostics.DebuggerStepThroughAttribute()]{0}" +
842                                 "[System.ComponentModel.DesignerCategoryAttribute(\"code\")]{0}" +
843                                 "[System.Xml.Serialization.XmlRootAttribute(\"simple\", Namespace=\"\", IsNullable=true)]{0}" +
844                                 "public partial class SimpleClassWithXmlAttributes {{{0}" +
845                                 "    {0}" +
846                                 "    private string somethingField;{0}" +
847                                 "    {0}" +
848                                 "    /// <remarks/>{0}" +
849                                 "    [System.Xml.Serialization.XmlAttributeAttribute(\"member\")]{0}" +
850                                 "    public string something {{{0}" +
851                                 "        get {{{0}" +
852                                 "            return this.somethingField;{0}" +
853                                 "        }}{0}" +
854                                 "        set {{{0}" +
855                                 "            this.somethingField = value;{0}" +
856                                 "        }}{0}" +
857                                 "    }}{0}" +
858                                 "}}{0}", Environment.NewLine), sw.ToString (), "#2");
859                 }
860
861                 [Test]
862                 public void ExportTypeMapping_XsdPrimitive_Arrays ()
863                 {
864                         ArrayList types = new ArrayList ();
865                         types.Add (typeof (sbyte[]));
866                         types.Add (typeof (bool[]));
867                         types.Add (typeof (short[]));
868                         types.Add (typeof (int[]));
869                         types.Add (typeof (long[]));
870                         types.Add (typeof (float[]));
871                         types.Add (typeof (double[]));
872                         types.Add (typeof (decimal[]));
873                         types.Add (typeof (ushort[]));
874                         types.Add (typeof (uint[]));
875                         types.Add (typeof (ulong[]));
876                         types.Add (typeof (DateTime[]));
877                         types.Add (typeof (XmlQualifiedName[]));
878                         types.Add (typeof (string[]));
879
880                         StringWriter sw = new StringWriter ();
881                         CodeDomProvider provider = new CSharpCodeProvider ();
882                         ICodeGenerator generator = provider.CreateGenerator ();
883
884                         foreach (Type type in types) {
885                                 CodeNamespace codeNamespace = ExportCode (type);
886                                 Assert.IsNotNull (codeNamespace, type.FullName + "#1");
887
888                                 generator.GenerateCodeFromNamespace (codeNamespace, sw, new CodeGeneratorOptions ());
889
890                                 Assert.AreEqual (Environment.NewLine, sw.ToString (), 
891                                         type.FullName + "#2");
892
893                                 sw.GetStringBuilder ().Length = 0;
894                         }
895                 }
896
897                 [Test]
898                 public void ExportTypeMapping_ZeroFlagEnum ()
899                 {
900                         CodeNamespace codeNamespace = ExportCode (typeof (ZeroFlagEnum));
901                         Assert.IsNotNull (codeNamespace, "#1");
902
903                         StringWriter sw = new StringWriter ();
904                         CodeDomProvider provider = new CSharpCodeProvider ();
905                         ICodeGenerator generator = provider.CreateGenerator ();
906                         generator.GenerateCodeFromNamespace (codeNamespace, sw, new CodeGeneratorOptions ());
907
908                         Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
909                                 "{0}{0}" +
910                                 "/// <remarks/>{0}" +
911                                 "[System.FlagsAttribute()]{0}" +
912                                 "[System.CodeDom.Compiler.GeneratedCodeAttribute(\"nunit-lite-console\", \"0.0.0.0\")]{0}" +
913                                 "[System.SerializableAttribute()]{0}" +
914                                 "[System.Xml.Serialization.XmlRootAttribute(Namespace=\"\", IsNullable=false)]{0}" +
915                                 "public enum ZeroFlagEnum {{{0}" +
916                                 "    {0}" +
917                                 "    /// <remarks/>{0}" +
918                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"zero\")]{0}" +
919                                 "    e0 = 1,{0}" +
920                                 "    {0}" +
921                                 "    /// <remarks/>{0}" +
922                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"o<n>e\")]{0}" +
923                                 "    e1 = 2,{0}" +
924                                 "    {0}" +
925                                 "    /// <remarks/>{0}" +
926                                 "    [System.Xml.Serialization.XmlEnumAttribute(\"tns:t<w>o\")]{0}" +
927                                 "    e2 = 4,{0}" +
928                                 "}}{0}", Environment.NewLine), sw.ToString (), "#2");
929                 }
930
931                 [Test]
932                 public void DuplicateIdentifiers ()
933                 {
934                         XmlSchema xs = XmlSchema.Read (File.OpenText ("Test/XmlFiles/xsd/82078.xsd"), null);
935
936                         XmlSchemas xss = new XmlSchemas ();
937                         xss.Add (xs);
938                         XmlSchemaImporter imp = new XmlSchemaImporter (xss);
939                         CodeNamespace cns = new CodeNamespace ();
940                         XmlCodeExporter exp = new XmlCodeExporter (cns);
941                         XmlQualifiedName qname = new XmlQualifiedName (
942                                 "Operation", "http://tempuri.org/");
943                         exp.ExportTypeMapping (imp.ImportTypeMapping (qname));
944                         CodeCompileUnit ccu = new CodeCompileUnit ();
945                         ccu.Namespaces.Add (cns);
946
947                         CodeDomProvider provider = new CSharpCodeProvider ();
948                         ICodeCompiler compiler = provider.CreateCompiler ();
949
950                         CompilerParameters options = new CompilerParameters ();
951                         options.ReferencedAssemblies.Add ("System.dll");
952                         options.ReferencedAssemblies.Add ("System.Xml.dll");
953                         options.GenerateInMemory = true;
954
955                         CompilerResults result = compiler.CompileAssemblyFromDom (options, ccu);
956                         Assert.AreEqual (0, result.Errors.Count, "#1");
957                         Assert.IsNotNull (result.CompiledAssembly, "#2");
958                 }
959
960                 [Test]
961                 public void ExportSimpleContentExtensionEnum ()
962                 {
963                         string xsd = @"
964 <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:b='urn:bar' targetNamespace='urn:bar'>
965   <xs:element name='Foo' type='b:DayOfWeek' />
966   <xs:complexType name='DayOfWeek'>
967     <xs:simpleContent>
968       <xs:extension base='b:WeekDay' />
969     </xs:simpleContent>
970   </xs:complexType>
971   <xs:simpleType name='WeekDay'>
972     <xs:restriction base='xs:string'>
973       <xs:enumeration value='Sunday'/>
974       <xs:enumeration value='Monday'/>
975       <xs:enumeration value='Tuesday'/>
976       <xs:enumeration value='Wednesday'/>
977       <xs:enumeration value='Thursday'/>
978       <xs:enumeration value='Friday'/>
979       <xs:enumeration value='Saturday'/>
980     </xs:restriction>
981   </xs:simpleType>
982 </xs:schema>";
983                         XmlSchema xs = XmlSchema.Read (new StringReader (xsd), null);
984                         XmlSchemas xss = new XmlSchemas ();
985                         xss.Add (xs);
986                         XmlSchemaImporter imp = new XmlSchemaImporter (xss);
987                         XmlTypeMapping m = imp.ImportTypeMapping (new XmlQualifiedName ("Foo", "urn:bar"));
988                         CodeNamespace cns = new CodeNamespace ();
989                         XmlCodeExporter exp = new XmlCodeExporter (cns);
990                         exp.ExportTypeMapping (m);
991                         CodeTypeDeclaration enumType = null;
992                         foreach (CodeTypeDeclaration ctd in cns.Types)
993                                 if (ctd.Name == "WeekDay")
994                                         enumType = ctd;
995                         Assert.IsNotNull (enumType);
996                 }
997
998                 CodeNamespace ExportCode (Type type)
999                 {
1000                         XmlReflectionImporter imp = new XmlReflectionImporter ();
1001                         XmlTypeMapping map = imp.ImportTypeMapping (type);
1002                         CodeNamespace codeNamespace = new CodeNamespace ();
1003                         XmlCodeExporter exp = new XmlCodeExporter (codeNamespace);
1004                         exp.ExportTypeMapping (map);
1005                         return codeNamespace;
1006                 }
1007
1008                 [XmlRootAttribute ("root", Namespace="urn:aNS", IsNullable=false)]
1009                 public class Root
1010                 {
1011                         public OptionalValueTypeContainer OptionalValue;
1012                         public TestDefault Default;
1013                 }
1014         }
1015 }
1016
1017 #endif