PageRenderTime 59ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Scripting/Test/ObjectFormatterTests.Fixtures.cs

https://gitlab.com/sharadag/TestProject2
C# | 485 lines | 382 code | 103 blank | 0 comment | 3 complexity | 09dd71eb33e59b13c314c4f7fe51f570 MD5 | raw file
  1. #pragma warning disable 169 // unused field
  2. #pragma warning disable 649 // field not set, will always be default value
  3. using System;
  4. using System.Collections;
  5. using System.Diagnostics;
  6. using System.Runtime.CompilerServices;
  7. namespace ObjectFormatterFixtures
  8. {
  9. internal class Outer
  10. {
  11. public class Nested<T>
  12. {
  13. public readonly int A = 1;
  14. public readonly int B = 2;
  15. public static readonly int S = 3;
  16. }
  17. }
  18. internal class A<T>
  19. {
  20. public class B<S>
  21. {
  22. public class C
  23. {
  24. public class D<Q, R>
  25. {
  26. public class E
  27. {
  28. }
  29. }
  30. }
  31. }
  32. public static readonly B<T> X = new B<T>();
  33. }
  34. internal class Sort
  35. {
  36. public readonly byte ab = 1;
  37. public readonly sbyte aB = -1;
  38. public readonly short Ac = -1;
  39. public readonly ushort Ad = 1;
  40. public readonly int ad = -1;
  41. public readonly uint aE = 1;
  42. public readonly long aF = -1;
  43. public readonly ulong AG = 1;
  44. }
  45. internal class RecursiveRootHidden
  46. {
  47. public readonly int A;
  48. public readonly int B;
  49. [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
  50. public RecursiveRootHidden C;
  51. }
  52. internal class RecursiveProxy
  53. {
  54. private class Proxy
  55. {
  56. public Proxy() { }
  57. public Proxy(Node node) { x = node.value; y = node.next; }
  58. public readonly int x;
  59. public readonly Node y;
  60. }
  61. [DebuggerTypeProxy(typeof(Proxy))]
  62. public class Node
  63. {
  64. public Node(int value)
  65. {
  66. if (value < 5)
  67. {
  68. next = new Node(value + 1);
  69. }
  70. this.value = value;
  71. }
  72. public readonly int value;
  73. public readonly Node next;
  74. }
  75. }
  76. internal class InvalidRecursiveProxy
  77. {
  78. private class Proxy
  79. {
  80. public Proxy() { }
  81. public Proxy(Node c) { }
  82. public readonly int x;
  83. public readonly Node p = new Node();
  84. public readonly int y;
  85. }
  86. [DebuggerTypeProxy(typeof(Proxy))]
  87. public class Node
  88. {
  89. public readonly int a;
  90. public readonly int b;
  91. }
  92. }
  93. internal class ComplexProxyBase
  94. {
  95. private int Foo()
  96. {
  97. return 1;
  98. }
  99. }
  100. internal class ComplexProxy : ComplexProxyBase
  101. {
  102. public ComplexProxy()
  103. {
  104. }
  105. public ComplexProxy(object b)
  106. {
  107. }
  108. [DebuggerDisplay("*1")]
  109. public int _02_public_property_dd { get { return 1; } }
  110. [DebuggerDisplay("*2")]
  111. private int _03_private_property_dd { get { return 1; } }
  112. [DebuggerDisplay("*3")]
  113. protected int _04_protected_property_dd { get { return 1; } }
  114. [DebuggerDisplay("*4")]
  115. internal int _05_internal_property_dd { get { return 1; } }
  116. [DebuggerDisplay("+1")]
  117. [DebuggerBrowsable(DebuggerBrowsableState.Never)]
  118. public readonly int _06_public_field_dd_never;
  119. [DebuggerDisplay("+2")]
  120. private readonly int _07_private_field_dd;
  121. [DebuggerDisplay("+3")]
  122. protected readonly int _08_protected_field_dd;
  123. [DebuggerDisplay("+4")]
  124. internal readonly int _09_internal_field_dd;
  125. [DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
  126. private readonly int _10_private_collapsed;
  127. [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
  128. private readonly int _10_private_rootHidden;
  129. public readonly int _12_public;
  130. private readonly int _13_private;
  131. protected readonly int _14_protected;
  132. internal readonly int _15_internal;
  133. [DebuggerDisplay("==\r\n=\r\n=")]
  134. public readonly int _16_eolns;
  135. [DebuggerDisplay("=={==")]
  136. public readonly int _17_braces_0;
  137. [DebuggerDisplay("=={{==")]
  138. public readonly int _17_braces_1;
  139. [DebuggerDisplay("=={'{'}==")]
  140. public readonly int _17_braces_2;
  141. [DebuggerDisplay("=={'\\{'}==")]
  142. public readonly int _17_braces_3;
  143. [DebuggerDisplay("=={1/*{*/}==")]
  144. public readonly int _17_braces_4;
  145. [DebuggerDisplay("=={'{'/*\\}*/}==")]
  146. public readonly int _17_braces_5;
  147. [DebuggerDisplay("=={'{'/*}*/}==")]
  148. public readonly int _17_braces_6;
  149. [DebuggerDisplay("==\\{\\x\\t==")]
  150. public readonly int _19_escapes;
  151. [DebuggerDisplay("{1+1}")]
  152. public readonly int _21;
  153. [DebuggerDisplay("{\"xxx\"}")]
  154. public readonly int _22;
  155. [DebuggerDisplay("{\"xxx\",nq}")]
  156. public readonly int _23;
  157. [DebuggerDisplay("{'x'}")]
  158. public readonly int _24;
  159. [DebuggerDisplay("{'x',nq}")]
  160. public readonly int _25;
  161. [DebuggerDisplay("{new B()}")]
  162. public readonly int _26_0;
  163. [DebuggerDisplay("{new D()}")]
  164. public readonly int _26_1;
  165. [DebuggerDisplay("{new E()}")]
  166. public readonly int _26_2;
  167. [DebuggerDisplay("{ReturnVoid()}")]
  168. public readonly int _26_3;
  169. private void ReturnVoid() { }
  170. [DebuggerDisplay("{F1(1)}")]
  171. public readonly int _26_4;
  172. [DebuggerDisplay("{Foo}")]
  173. public readonly int _26_5;
  174. [DebuggerDisplay("{foo}")]
  175. public readonly int _26_6;
  176. private int foo()
  177. {
  178. return 2;
  179. }
  180. private int F1(int a) { return 1; }
  181. private int F2(short a) { return 2; }
  182. [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
  183. public readonly C _27_rootHidden = new C();
  184. public readonly C _28 = new C();
  185. [DebuggerBrowsable(DebuggerBrowsableState.Collapsed)]
  186. public readonly C _29_collapsed = new C();
  187. public int _31 { get; set; }
  188. [CompilerGenerated]
  189. public readonly int _32;
  190. [CompilerGenerated]
  191. private readonly int _33;
  192. public int _34_Exception { get { throw new Exception("error1"); } }
  193. [DebuggerDisplay("-!-")]
  194. public int _35_Exception { get { throw new Exception("error2"); } }
  195. public readonly object _36 = new ToStringException();
  196. [DebuggerBrowsable(DebuggerBrowsableState.Never)]
  197. public int _37 { get { throw new Exception("error3"); } }
  198. public int _38_private_get_public_set { private get { return 1; } set { } }
  199. public int _39_public_get_private_set { get { return 1; } private set { } }
  200. private int _40_private_get_private_set { get { return 1; } set { } }
  201. private int _41_set_only_property { set { } }
  202. public override string ToString()
  203. {
  204. return "AStr";
  205. }
  206. }
  207. [DebuggerTypeProxy(typeof(ComplexProxy))]
  208. internal class TypeWithComplexProxy
  209. {
  210. public override string ToString()
  211. {
  212. return "BStr";
  213. }
  214. }
  215. [DebuggerTypeProxy(typeof(Proxy))]
  216. [DebuggerDisplay("DD")]
  217. internal class TypeWithDebuggerDisplayAndProxy
  218. {
  219. public override string ToString()
  220. {
  221. return "<ToString>";
  222. }
  223. [DebuggerDisplay("pxy")]
  224. private class Proxy
  225. {
  226. public Proxy(object x)
  227. {
  228. }
  229. public readonly int A;
  230. public readonly int B;
  231. }
  232. }
  233. internal class C
  234. {
  235. public readonly int A = 1;
  236. public readonly int B = 2;
  237. public override string ToString()
  238. {
  239. return "CStr";
  240. }
  241. }
  242. [DebuggerDisplay("DebuggerDisplayValue")]
  243. internal class BaseClassWithDebuggerDisplay
  244. {
  245. }
  246. internal class InheritedDebuggerDisplay : BaseClassWithDebuggerDisplay
  247. {
  248. }
  249. internal class ToStringException
  250. {
  251. public override string ToString()
  252. {
  253. throw new MyException();
  254. }
  255. }
  256. internal class MyException : Exception
  257. {
  258. public override string ToString()
  259. {
  260. return "my exception";
  261. }
  262. }
  263. public class ThrowingDictionary : IDictionary
  264. {
  265. private readonly int _throwAt;
  266. public ThrowingDictionary(int throwAt)
  267. {
  268. _throwAt = throwAt;
  269. }
  270. public void Add(object key, object value)
  271. {
  272. throw new NotImplementedException();
  273. }
  274. public void Clear()
  275. {
  276. throw new NotImplementedException();
  277. }
  278. public bool Contains(object key)
  279. {
  280. throw new NotImplementedException();
  281. }
  282. public IDictionaryEnumerator GetEnumerator()
  283. {
  284. return new E(_throwAt);
  285. }
  286. public bool IsFixedSize
  287. {
  288. get { throw new NotImplementedException(); }
  289. }
  290. public bool IsReadOnly
  291. {
  292. get { throw new NotImplementedException(); }
  293. }
  294. public ICollection Keys
  295. {
  296. get { return new[] { 1, 2 }; }
  297. }
  298. public void Remove(object key)
  299. {
  300. }
  301. public ICollection Values
  302. {
  303. get { return new[] { 1, 2 }; }
  304. }
  305. public object this[object key]
  306. {
  307. get
  308. {
  309. return 1;
  310. }
  311. set
  312. {
  313. }
  314. }
  315. public void CopyTo(Array array, int index)
  316. {
  317. }
  318. public int Count
  319. {
  320. get { return 10; }
  321. }
  322. public bool IsSynchronized
  323. {
  324. get { throw new NotImplementedException(); }
  325. }
  326. public object SyncRoot
  327. {
  328. get { throw new NotImplementedException(); }
  329. }
  330. IEnumerator IEnumerable.GetEnumerator()
  331. {
  332. return new E(-1);
  333. }
  334. private class E : IEnumerator, IDictionaryEnumerator
  335. {
  336. private int _i;
  337. private readonly int _throwAt;
  338. public E(int throwAt)
  339. {
  340. _throwAt = throwAt;
  341. }
  342. public object Current
  343. {
  344. get { return new DictionaryEntry(_i, _i); }
  345. }
  346. public bool MoveNext()
  347. {
  348. _i++;
  349. if (_i == _throwAt)
  350. {
  351. throw new Exception();
  352. }
  353. return _i < 5;
  354. }
  355. public void Reset()
  356. {
  357. }
  358. public DictionaryEntry Entry
  359. {
  360. get { return (DictionaryEntry)Current; }
  361. }
  362. public object Key
  363. {
  364. get { return _i; }
  365. }
  366. public object Value
  367. {
  368. get { return _i; }
  369. }
  370. }
  371. }
  372. public class ListNode
  373. {
  374. public ListNode next;
  375. public object data;
  376. }
  377. public class LongMembers
  378. {
  379. public readonly string LongName0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789 = "hello";
  380. public readonly string LongValue = "0123456789_0123456789_0123456789_0123456789_0123456789_0123456789_0123456789";
  381. }
  382. }