XmlSchemaExporterTests.cs 101 KB

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