XmlSchemaExporterTests.cs 101 KB

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