XmlReflectionImporterTests.cs 66 KB

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