PageRenderTime 140ms CodeModel.GetById 33ms RepoModel.GetById 1ms app.codeStats 1ms

/Src/Compilers/CSharp/Test/Emit/CodeGen/WinRTCollectionTests.cs

https://github.com/EkardNT/Roslyn
C# | 7443 lines | 7248 code | 42 blank | 153 comment | 2 complexity | 6c30fac654fbeaf461328d7ac2aac221 MD5 | raw file
  1. // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  2. using System.Collections.Generic;
  3. using Microsoft.CodeAnalysis.CSharp;
  4. using Microsoft.CodeAnalysis.CSharp.Symbols;
  5. using Microsoft.CodeAnalysis.CSharp.Syntax;
  6. using ProprietaryTestResources = Microsoft.CodeAnalysis.Test.Resources.Proprietary;
  7. using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
  8. using Microsoft.CodeAnalysis.Test.Utilities;
  9. using Roslyn.Test.Utilities;
  10. using Xunit;
  11. namespace Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen
  12. {
  13. public class WinRTCollectionTests : CSharpTestBase
  14. {
  15. private MetadataReference[] _legacyRefs = null;
  16. public MetadataReference[] LegacyRefs
  17. {
  18. get
  19. {
  20. if (_legacyRefs == null)
  21. {
  22. var list = new List<MetadataReference>(WinRtRefs.Length + 2);
  23. list.AddRange(WinRtRefs);
  24. list.Add(
  25. new MetadataImageReference(
  26. TestResources.WinRt.Windows_Languages_WinRTTest.AsImmutableOrNull(),
  27. display: "WinRTTest"));
  28. list.Add(
  29. new MetadataImageReference(
  30. ProprietaryTestResources.NetFX.v4_0_30319_17929.System_Core.AsImmutableOrNull(),
  31. display: "SystemCore"));
  32. _legacyRefs = list.ToArray();
  33. }
  34. return _legacyRefs;
  35. }
  36. }
  37. [Fact, WorkItem(762316, "DevDiv")]
  38. public void InheritFromTypeWithProjections()
  39. {
  40. var source = @"
  41. using Windows.UI.Xaml;
  42. public sealed class BehaviorCollection : DependencyObjectCollection
  43. {
  44. private int count;
  45. public BehaviorCollection()
  46. {
  47. count = this.Count;
  48. }
  49. public object GetItem(int i)
  50. {
  51. return this[i];
  52. }
  53. }";
  54. var comp = CreateCompilationWithMscorlib45(source, references: WinRtRefs);
  55. comp.VerifyDiagnostics();
  56. }
  57. [Fact]
  58. public void IVectorProjectionTests()
  59. {
  60. var source =
  61. @"using System;
  62. using Windows.Data.Json;
  63. public class Class1
  64. {
  65. public static void Main(string[] args)
  66. {
  67. var jsonArray = new JsonArray();
  68. var a = JsonValue.CreateStringValue(""a"");
  69. jsonArray.Add(a);
  70. var b = JsonValue.CreateStringValue(""b"");
  71. jsonArray.Insert(0, b);
  72. jsonArray.Remove(b);
  73. Console.WriteLine(jsonArray.Contains(b));
  74. Console.WriteLine(jsonArray.IndexOf(a));
  75. jsonArray.RemoveAt(0);
  76. Console.WriteLine(jsonArray.Count);
  77. jsonArray.Add(b);
  78. foreach (var json in jsonArray)
  79. {
  80. Console.WriteLine(json.GetString());
  81. }
  82. Console.WriteLine(jsonArray.Count);
  83. jsonArray.Clear();
  84. Console.WriteLine(jsonArray.Count);
  85. }
  86. }";
  87. string expectedOutput =
  88. @"False
  89. 0
  90. 0
  91. b
  92. 1
  93. 0";
  94. var verifier = CompileAndVerifyOnWin8Only(source,
  95. expectedOutput: expectedOutput,
  96. additionalRefs: WinRtRefs,
  97. emitOptions: EmitOptions.RefEmitBug);
  98. verifier.VerifyIL("Class1.Main",
  99. @"{
  100. // Code size 174 (0xae)
  101. .maxstack 3
  102. .locals init (Windows.Data.Json.JsonArray V_0, //jsonArray
  103. Windows.Data.Json.JsonValue V_1, //a
  104. Windows.Data.Json.JsonValue V_2, //b
  105. System.Collections.Generic.IEnumerator<Windows.Data.Json.IJsonValue> V_3)
  106. IL_0000: newobj ""Windows.Data.Json.JsonArray..ctor()""
  107. IL_0005: stloc.0
  108. IL_0006: ldstr ""a""
  109. IL_000b: call ""Windows.Data.Json.JsonValue Windows.Data.Json.JsonValue.CreateStringValue(string)""
  110. IL_0010: stloc.1
  111. IL_0011: ldloc.0
  112. IL_0012: ldloc.1
  113. IL_0013: callvirt ""void System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Add(Windows.Data.Json.IJsonValue)""
  114. IL_0018: ldstr ""b""
  115. IL_001d: call ""Windows.Data.Json.JsonValue Windows.Data.Json.JsonValue.CreateStringValue(string)""
  116. IL_0022: stloc.2
  117. IL_0023: ldloc.0
  118. IL_0024: ldc.i4.0
  119. IL_0025: ldloc.2
  120. IL_0026: callvirt ""void System.Collections.Generic.IList<Windows.Data.Json.IJsonValue>.Insert(int, Windows.Data.Json.IJsonValue)""
  121. IL_002b: ldloc.0
  122. IL_002c: ldloc.2
  123. IL_002d: callvirt ""bool System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Remove(Windows.Data.Json.IJsonValue)""
  124. IL_0032: pop
  125. IL_0033: ldloc.0
  126. IL_0034: ldloc.2
  127. IL_0035: callvirt ""bool System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Contains(Windows.Data.Json.IJsonValue)""
  128. IL_003a: call ""void System.Console.WriteLine(bool)""
  129. IL_003f: ldloc.0
  130. IL_0040: ldloc.1
  131. IL_0041: callvirt ""int System.Collections.Generic.IList<Windows.Data.Json.IJsonValue>.IndexOf(Windows.Data.Json.IJsonValue)""
  132. IL_0046: call ""void System.Console.WriteLine(int)""
  133. IL_004b: ldloc.0
  134. IL_004c: ldc.i4.0
  135. IL_004d: callvirt ""void System.Collections.Generic.IList<Windows.Data.Json.IJsonValue>.RemoveAt(int)""
  136. IL_0052: ldloc.0
  137. IL_0053: callvirt ""int System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Count.get""
  138. IL_0058: call ""void System.Console.WriteLine(int)""
  139. IL_005d: ldloc.0
  140. IL_005e: ldloc.2
  141. IL_005f: callvirt ""void System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Add(Windows.Data.Json.IJsonValue)""
  142. IL_0064: ldloc.0
  143. IL_0065: callvirt ""System.Collections.Generic.IEnumerator<Windows.Data.Json.IJsonValue> System.Collections.Generic.IEnumerable<Windows.Data.Json.IJsonValue>.GetEnumerator()""
  144. IL_006a: stloc.3
  145. .try
  146. {
  147. IL_006b: br.s IL_007d
  148. IL_006d: ldloc.3
  149. IL_006e: callvirt ""Windows.Data.Json.IJsonValue System.Collections.Generic.IEnumerator<Windows.Data.Json.IJsonValue>.Current.get""
  150. IL_0073: callvirt ""string Windows.Data.Json.IJsonValue.GetString()""
  151. IL_0078: call ""void System.Console.WriteLine(string)""
  152. IL_007d: ldloc.3
  153. IL_007e: callvirt ""bool System.Collections.IEnumerator.MoveNext()""
  154. IL_0083: brtrue.s IL_006d
  155. IL_0085: leave.s IL_0091
  156. }
  157. finally
  158. {
  159. IL_0087: ldloc.3
  160. IL_0088: brfalse.s IL_0090
  161. IL_008a: ldloc.3
  162. IL_008b: callvirt ""void System.IDisposable.Dispose()""
  163. IL_0090: endfinally
  164. }
  165. IL_0091: ldloc.0
  166. IL_0092: callvirt ""int System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Count.get""
  167. IL_0097: call ""void System.Console.WriteLine(int)""
  168. IL_009c: ldloc.0
  169. IL_009d: callvirt ""void System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Clear()""
  170. IL_00a2: ldloc.0
  171. IL_00a3: callvirt ""int System.Collections.Generic.ICollection<Windows.Data.Json.IJsonValue>.Count.get""
  172. IL_00a8: call ""void System.Console.WriteLine(int)""
  173. IL_00ad: ret
  174. }
  175. ");
  176. }
  177. [Fact]
  178. public void IVectorViewProjectionTests()
  179. {
  180. var source =
  181. @"using System;
  182. using Windows.Foundation;
  183. public class Class1
  184. {
  185. public static void Main(string[] args)
  186. {
  187. var results = new WwwFormUrlDecoder(""?param1=test"");
  188. Console.Out.WriteLine(results[0].Name + results[0].Value);
  189. }
  190. }";
  191. var expectedOut = "param1test";
  192. var verifier = CompileAndVerifyOnWin8Only(
  193. source,
  194. expectedOutput: expectedOut,
  195. additionalRefs: WinRtRefs,
  196. emitOptions: EmitOptions.RefEmitBug);
  197. verifier.VerifyIL("Class1.Main",
  198. @"{
  199. // Code size 51 (0x33)
  200. .maxstack 4
  201. .locals init (Windows.Foundation.WwwFormUrlDecoder V_0) //results
  202. IL_0000: ldstr ""?param1=test""
  203. IL_0005: newobj ""Windows.Foundation.WwwFormUrlDecoder..ctor(string)""
  204. IL_000a: stloc.0
  205. IL_000b: call ""System.IO.TextWriter System.Console.Out.get""
  206. IL_0010: ldloc.0
  207. IL_0011: ldc.i4.0
  208. IL_0012: callvirt ""Windows.Foundation.IWwwFormUrlDecoderEntry System.Collections.Generic.IReadOnlyList<Windows.Foundation.IWwwFormUrlDecoderEntry>.this[int].get""
  209. IL_0017: callvirt ""string Windows.Foundation.IWwwFormUrlDecoderEntry.Name.get""
  210. IL_001c: ldloc.0
  211. IL_001d: ldc.i4.0
  212. IL_001e: callvirt ""Windows.Foundation.IWwwFormUrlDecoderEntry System.Collections.Generic.IReadOnlyList<Windows.Foundation.IWwwFormUrlDecoderEntry>.this[int].get""
  213. IL_0023: callvirt ""string Windows.Foundation.IWwwFormUrlDecoderEntry.Value.get""
  214. IL_0028: call ""string string.Concat(string, string)""
  215. IL_002d: callvirt ""void System.IO.TextWriter.WriteLine(string)""
  216. IL_0032: ret
  217. }");
  218. }
  219. [Fact]
  220. public void IMapProjectionTests()
  221. {
  222. var source =
  223. @"using System;
  224. using System.Collections.Generic;
  225. using Windows.ApplicationModel.DataTransfer;
  226. public class Class1
  227. {
  228. public static void Main(string[] args)
  229. {
  230. var dataPackage = new DataPackage();
  231. var dpps = dataPackage.Properties;
  232. dpps.Add(new KeyValuePair<string, object>(""testKey1"", ""testValue1""));
  233. Console.Out.WriteLine(dpps.ContainsKey(""testKey1""));
  234. Console.Out.WriteLine(dpps[""testKey1""]);
  235. dpps.Add(""testKey2"", ""testValue2"");
  236. object tv2;
  237. dpps.TryGetValue(""testKey2"", out tv2);
  238. Console.Out.WriteLine(tv2);
  239. dpps[""testKey2""] = ""testValue3"";
  240. dpps.Remove(""testKey1"");
  241. var valsEnumerator = dpps.Values.GetEnumerator();
  242. var keysEnumerator = dpps.Keys.GetEnumerator();
  243. while (keysEnumerator.MoveNext() && valsEnumerator.MoveNext())
  244. {
  245. Console.Out.WriteLine(keysEnumerator.Current + valsEnumerator.Current);
  246. }
  247. }
  248. }";
  249. var expectedOut =
  250. @"True
  251. testValue1
  252. testValue2
  253. testKey2testValue3
  254. ";
  255. var verifier = CompileAndVerifyOnWin8Only(
  256. source,
  257. expectedOutput: expectedOut,
  258. additionalRefs: WinRtRefs,
  259. emitOptions: EmitOptions.RefEmitBug);
  260. verifier.VerifyIL("Class1.Main",
  261. @"{
  262. // Code size 213 (0xd5)
  263. .maxstack 3
  264. .locals init (Windows.ApplicationModel.DataTransfer.DataPackagePropertySet V_0, //dpps
  265. object V_1, //tv2
  266. System.Collections.Generic.IEnumerator<object> V_2, //valsEnumerator
  267. System.Collections.Generic.IEnumerator<string> V_3) //keysEnumerator
  268. IL_0000: newobj ""Windows.ApplicationModel.DataTransfer.DataPackage..ctor()""
  269. IL_0005: callvirt ""Windows.ApplicationModel.DataTransfer.DataPackagePropertySet Windows.ApplicationModel.DataTransfer.DataPackage.Properties.get""
  270. IL_000a: stloc.0
  271. IL_000b: ldloc.0
  272. IL_000c: ldstr ""testKey1""
  273. IL_0011: ldstr ""testValue1""
  274. IL_0016: newobj ""System.Collections.Generic.KeyValuePair<string, object>..ctor(string, object)""
  275. IL_001b: callvirt ""void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, object>>.Add(System.Collections.Generic.KeyValuePair<string, object>)""
  276. IL_0020: call ""System.IO.TextWriter System.Console.Out.get""
  277. IL_0025: ldloc.0
  278. IL_0026: ldstr ""testKey1""
  279. IL_002b: callvirt ""bool System.Collections.Generic.IDictionary<string, object>.ContainsKey(string)""
  280. IL_0030: callvirt ""void System.IO.TextWriter.WriteLine(bool)""
  281. IL_0035: call ""System.IO.TextWriter System.Console.Out.get""
  282. IL_003a: ldloc.0
  283. IL_003b: ldstr ""testKey1""
  284. IL_0040: callvirt ""object System.Collections.Generic.IDictionary<string, object>.this[string].get""
  285. IL_0045: callvirt ""void System.IO.TextWriter.WriteLine(object)""
  286. IL_004a: ldloc.0
  287. IL_004b: ldstr ""testKey2""
  288. IL_0050: ldstr ""testValue2""
  289. IL_0055: callvirt ""void System.Collections.Generic.IDictionary<string, object>.Add(string, object)""
  290. IL_005a: ldloc.0
  291. IL_005b: ldstr ""testKey2""
  292. IL_0060: ldloca.s V_1
  293. IL_0062: callvirt ""bool System.Collections.Generic.IDictionary<string, object>.TryGetValue(string, out object)""
  294. IL_0067: pop
  295. IL_0068: call ""System.IO.TextWriter System.Console.Out.get""
  296. IL_006d: ldloc.1
  297. IL_006e: callvirt ""void System.IO.TextWriter.WriteLine(object)""
  298. IL_0073: ldloc.0
  299. IL_0074: ldstr ""testKey2""
  300. IL_0079: ldstr ""testValue3""
  301. IL_007e: callvirt ""void System.Collections.Generic.IDictionary<string, object>.this[string].set""
  302. IL_0083: ldloc.0
  303. IL_0084: ldstr ""testKey1""
  304. IL_0089: callvirt ""bool System.Collections.Generic.IDictionary<string, object>.Remove(string)""
  305. IL_008e: pop
  306. IL_008f: ldloc.0
  307. IL_0090: callvirt ""System.Collections.Generic.ICollection<object> System.Collections.Generic.IDictionary<string, object>.Values.get""
  308. IL_0095: callvirt ""System.Collections.Generic.IEnumerator<object> System.Collections.Generic.IEnumerable<object>.GetEnumerator()""
  309. IL_009a: stloc.2
  310. IL_009b: ldloc.0
  311. IL_009c: callvirt ""System.Collections.Generic.ICollection<string> System.Collections.Generic.IDictionary<string, object>.Keys.get""
  312. IL_00a1: callvirt ""System.Collections.Generic.IEnumerator<string> System.Collections.Generic.IEnumerable<string>.GetEnumerator()""
  313. IL_00a6: stloc.3
  314. IL_00a7: br.s IL_00c4
  315. IL_00a9: call ""System.IO.TextWriter System.Console.Out.get""
  316. IL_00ae: ldloc.3
  317. IL_00af: callvirt ""string System.Collections.Generic.IEnumerator<string>.Current.get""
  318. IL_00b4: ldloc.2
  319. IL_00b5: callvirt ""object System.Collections.Generic.IEnumerator<object>.Current.get""
  320. IL_00ba: call ""string string.Concat(object, object)""
  321. IL_00bf: callvirt ""void System.IO.TextWriter.WriteLine(string)""
  322. IL_00c4: ldloc.3
  323. IL_00c5: callvirt ""bool System.Collections.IEnumerator.MoveNext()""
  324. IL_00ca: brfalse.s IL_00d4
  325. IL_00cc: ldloc.2
  326. IL_00cd: callvirt ""bool System.Collections.IEnumerator.MoveNext()""
  327. IL_00d2: brtrue.s IL_00a9
  328. IL_00d4: ret
  329. }");
  330. }
  331. // TODO: There are no suitable winmd members to test the IMapView projections,
  332. // a custom winmd will have to be used after winmd references are implemented
  333. [Fact]
  334. public void MultipleInterfaceMethodConflictTests()
  335. {
  336. var source =
  337. @"using Windows.Data.Json;
  338. using Windows.Foundation;
  339. public class Class1
  340. {
  341. public static void Main(string[] args)
  342. {
  343. var en = new JsonArray().GetEnumerator();
  344. en = new WwwFormUrlDecoder(""?param1=test"").GetEnumerator();
  345. }
  346. }";
  347. var comp = CreateCompilation(source, references: WinRtRefs);
  348. // JsonArray implements both IEnumerable and IList, which both have a GetEnumerator
  349. // method. We can't know which interface method to call, so we shouldn't emit a
  350. // GetEnumerator method at all.
  351. comp.VerifyDiagnostics(
  352. Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "GetEnumerator")
  353. .WithArguments("Windows.Data.Json.JsonArray", "GetEnumerator"),
  354. Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "GetEnumerator")
  355. .WithArguments("Windows.Foundation.WwwFormUrlDecoder", "GetEnumerator"));
  356. }
  357. [Fact]
  358. public void LegacyCollectionTest01()
  359. {
  360. var source =
  361. @"using Windows.Languages.WinRTTest;
  362. using System.Collections.Generic;
  363. using System.Reflection;
  364. using System.Linq.Expressions;
  365. using System;
  366. using System.Linq;
  367. class AllMembers
  368. {
  369. private static int FailedCount = 0;
  370. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  371. {
  372. var temp = Console.ForegroundColor;
  373. if (actual != expected)
  374. {
  375. FailedCount++;
  376. Console.ForegroundColor = ConsoleColor.Red;
  377. Console.Write(""FAIL: "");
  378. }
  379. else
  380. {
  381. Console.ForegroundColor = ConsoleColor.Green;
  382. Console.Write(""PASS: "");
  383. }
  384. Console.ForegroundColor = temp;
  385. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  386. return actual == expected;
  387. }
  388. private static bool ValidateValue(object actual, object expected)
  389. {
  390. var temp = Console.ForegroundColor;
  391. if (actual.ToString() != expected.ToString())
  392. {
  393. FailedCount++;
  394. Console.ForegroundColor = ConsoleColor.Red;
  395. Console.Write(""FAIL: "");
  396. }
  397. else
  398. {
  399. Console.ForegroundColor = ConsoleColor.Green;
  400. Console.Write(""PASS: "");
  401. }
  402. Console.ForegroundColor = temp;
  403. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  404. return actual.ToString() == expected.ToString();
  405. }
  406. static void TestIIterableMembers()
  407. {
  408. Console.WriteLine(""=== IIterableFloat ==="");
  409. var i = new IIterableFloat();
  410. i.ClearFlag();
  411. IEnumerator<float> enumerator = ((IEnumerable<float>)i).GetEnumerator();
  412. ValidateMethod(i.GetFlagState(), TestMethodCalled.IIterable_First);
  413. }
  414. static int Main()
  415. {
  416. TestIIterableMembers();
  417. Console.WriteLine(FailedCount);
  418. return FailedCount;
  419. }
  420. }";
  421. var verifier = CompileAndVerify(source,
  422. additionalRefs: LegacyRefs,
  423. emitOptions: EmitOptions.RefEmitBug,
  424. verify: false);
  425. verifier.VerifyDiagnostics(
  426. // (3,1): info CS8019: Unnecessary using directive.
  427. // using System.Reflection;
  428. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  429. // (4,1): info CS8019: Unnecessary using directive.
  430. // using System.Linq.Expressions;
  431. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  432. // (6,1): info CS8019: Unnecessary using directive.
  433. // using System.Linq;
  434. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"));
  435. verifier.VerifyIL("AllMembers.TestIIterableMembers",
  436. @"{
  437. // Code size 41 (0x29)
  438. .maxstack 2
  439. IL_0000: ldstr ""=== IIterableFloat ===""
  440. IL_0005: call ""void System.Console.WriteLine(string)""
  441. IL_000a: newobj ""Windows.Languages.WinRTTest.IIterableFloat..ctor()""
  442. IL_000f: dup
  443. IL_0010: callvirt ""void Windows.Languages.WinRTTest.IIterableFloat.ClearFlag()""
  444. IL_0015: dup
  445. IL_0016: callvirt ""System.Collections.Generic.IEnumerator<float> System.Collections.Generic.IEnumerable<float>.GetEnumerator()""
  446. IL_001b: pop
  447. IL_001c: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IIterableFloat.GetFlagState()""
  448. IL_0021: ldc.i4.1
  449. IL_0022: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  450. IL_0027: pop
  451. IL_0028: ret
  452. }");
  453. }
  454. [Fact]
  455. public void LegacyCollectionTest02()
  456. {
  457. var source =
  458. @"using Windows.Languages.WinRTTest;
  459. using System.Collections.Generic;
  460. using System.Reflection;
  461. using System.Linq.Expressions;
  462. using System;
  463. using System.Linq;
  464. class AllMembers
  465. {
  466. private static int FailedCount = 0;
  467. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  468. {
  469. var temp = Console.ForegroundColor;
  470. if (actual != expected)
  471. {
  472. FailedCount++;
  473. Console.ForegroundColor = ConsoleColor.Red;
  474. Console.Write(""FAIL: "");
  475. }
  476. else
  477. {
  478. Console.ForegroundColor = ConsoleColor.Green;
  479. Console.Write(""PASS: "");
  480. }
  481. Console.ForegroundColor = temp;
  482. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  483. return actual == expected;
  484. }
  485. private static bool ValidateValue(object actual, object expected)
  486. {
  487. var temp = Console.ForegroundColor;
  488. if (actual.ToString() != expected.ToString())
  489. {
  490. FailedCount++;
  491. Console.ForegroundColor = ConsoleColor.Red;
  492. Console.Write(""FAIL: "");
  493. }
  494. else
  495. {
  496. Console.ForegroundColor = ConsoleColor.Green;
  497. Console.Write(""PASS: "");
  498. }
  499. Console.ForegroundColor = temp;
  500. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  501. return actual.ToString() == expected.ToString();
  502. }
  503. static void TestIVectorIntMembers()
  504. {
  505. Console.WriteLine(""=== IVectorInt ==="");
  506. var v = new IVectorInt();
  507. //Add
  508. v.ClearFlag();
  509. v.Add(1);
  510. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  511. ValidateValue(v[0], 1);
  512. //Contains
  513. v.ClearFlag();
  514. bool b = v.Contains(1);
  515. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  516. ValidateValue(b, true);
  517. //CopyTo
  518. v.ClearFlag();
  519. int[] arr = new int[10];
  520. v.CopyTo(arr, 0);
  521. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  522. ValidateValue(arr[0], 1);
  523. ValidateValue(arr[1], 0); //there should be nothing there! :)
  524. //GetEnumerator
  525. v.ClearFlag();
  526. int count = v.Count;
  527. IEnumerator<int> enumerator = ((IEnumerable<int>)v).GetEnumerator();
  528. ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First);
  529. int index = 0;
  530. foreach (var e in v)
  531. {
  532. index = index + 1;
  533. ValidateValue(e, index);
  534. }
  535. ValidateValue(index, 1); //there should only be 1 element there
  536. //IndexOf
  537. v.ClearFlag();
  538. var rez = v.IndexOf(1);
  539. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  540. ValidateValue(rez, 0); // 1 is on the first line :)
  541. //Insert
  542. v.ClearFlag();
  543. v.Insert(1, 2);
  544. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
  545. ValidateValue(v[1], 2);
  546. //IsReadOnly
  547. v.ClearFlag();
  548. bool isReadOnly = v.IsReadOnly;
  549. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  550. ValidateValue(isReadOnly, false);
  551. //Indexing
  552. v.ClearFlag();
  553. int val = v[0];
  554. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  555. ValidateValue(val, 1);
  556. v.ClearFlag();
  557. val = v[1];
  558. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  559. ValidateValue(val, 2);
  560. //Remove
  561. v.ClearFlag();
  562. v.Remove(1);
  563. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  564. ValidateValue(v.Count, 1);
  565. //RemoveAt
  566. v.ClearFlag();
  567. v.RemoveAt(0);
  568. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  569. ValidateValue(v.Count, 0);
  570. //Clear
  571. v.Add(1);
  572. v.Add(2);
  573. v.ClearFlag();
  574. v.Clear();
  575. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
  576. ValidateValue(v.Count, 0);
  577. }
  578. static void TestIVectorStructMembers()
  579. {
  580. Console.WriteLine(""=== IVectorStruct ==="");
  581. var v = new IVectorStruct();
  582. var ud = new UserDefinedStruct()
  583. {
  584. Id = 1
  585. }
  586. ;
  587. //Add
  588. v.ClearFlag();
  589. v.Add(ud);
  590. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  591. ValidateValue(v[0].Id, 1);
  592. //Contains
  593. v.ClearFlag();
  594. bool b = v.Contains(ud);
  595. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  596. ValidateValue(b, true);
  597. //CopyTo
  598. v.ClearFlag();
  599. UserDefinedStruct[] arr = new UserDefinedStruct[10];
  600. v.CopyTo(arr, 0);
  601. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  602. ValidateValue(arr[0].Id, ud.Id);
  603. //GetEnumerator
  604. v.ClearFlag();
  605. int count = v.Count;
  606. IEnumerator<UserDefinedStruct> enumerator = ((IEnumerable<UserDefinedStruct>)v).GetEnumerator();
  607. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_get_Size);
  608. enumerator.MoveNext();
  609. ValidateValue((enumerator.Current).Id, 1);
  610. int index = 0;
  611. foreach (var e in v)
  612. {
  613. index = index + 1;
  614. ValidateValue(e.Id, index);
  615. }
  616. ValidateValue(index, 1); //there should only be 1 element there
  617. //IndexOf
  618. v.ClearFlag();
  619. var rez = v.IndexOf(ud);
  620. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  621. ValidateValue(rez, 0); // 1 is on the first line :)
  622. //Insert
  623. v.ClearFlag();
  624. v.Insert(1, new UserDefinedStruct()
  625. {
  626. Id = 4
  627. }
  628. );
  629. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
  630. ValidateValue(v[1].Id, 4);
  631. //IsReadOnly
  632. v.ClearFlag();
  633. bool isReadOnly = v.IsReadOnly;
  634. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  635. ValidateValue(isReadOnly, false);
  636. //Indexing
  637. v.ClearFlag();
  638. var val = v[0];
  639. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  640. ValidateValue(val.Id, ud.Id);
  641. v.ClearFlag();
  642. val = v[1];
  643. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  644. ValidateValue(val.Id, 4);
  645. //Remove
  646. v.ClearFlag();
  647. v.Remove(ud);
  648. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  649. ValidateValue(v.Count, 1);
  650. //RemoveAt
  651. v.ClearFlag();
  652. v.RemoveAt(0);
  653. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  654. ValidateValue(v.Count, 0);
  655. //Clear
  656. v.Add(ud);
  657. v.Add(new UserDefinedStruct()
  658. {
  659. Id = 4
  660. }
  661. );
  662. v.ClearFlag();
  663. v.Clear();
  664. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
  665. ValidateValue(v.Count, 0);
  666. }
  667. static void TestIVectorUintStructMembers()
  668. {
  669. Console.WriteLine(""=== IVectorUintStruct ==="");
  670. var v = new IVectorUintStruct();
  671. //Add
  672. v.ClearFlag();
  673. v.Add(7);
  674. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  675. ValidateValue((v as IList<uint>)[0], 7);
  676. //Contains
  677. v.ClearFlag();
  678. bool b = v.Contains(7);
  679. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  680. ValidateValue(b, true);
  681. //IndexOf
  682. v.ClearFlag();
  683. var rez = ((IList<uint>)v).IndexOf(7);
  684. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  685. ValidateValue(rez, 0);
  686. //Insert
  687. v.ClearFlag();
  688. v.Insert(1, 5);
  689. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
  690. ValidateValue((v as IList<uint>)[1], 5);
  691. //IsReadOnly
  692. v.ClearFlag();
  693. bool isReadOnly = ((IList<uint>)v).IsReadOnly;
  694. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  695. ValidateValue(isReadOnly, false);
  696. //Indexing
  697. v.ClearFlag();
  698. uint val = ((uint)(v as IList<uint>)[0]);
  699. ValidateValue(val, 7);
  700. v.ClearFlag();
  701. val = ((IList<uint>)v)[1];
  702. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  703. ValidateValue(val, 5);
  704. //Remove
  705. v.ClearFlag();
  706. v.Remove(5);
  707. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  708. ValidateValue(((IList<uint>)v).Count, 1);
  709. //RemoveAt
  710. try
  711. {
  712. v.ClearFlag();
  713. ((IList<uint>)v).RemoveAt(0);
  714. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  715. ValidateValue(((IList<uint>)v).Count, 0);
  716. }
  717. catch (Exception exce)
  718. {
  719. Console.WriteLine(""RemoveAt"");
  720. Console.WriteLine(exce.Message);
  721. }
  722. //Clear
  723. v.Add(1);
  724. v.Add(2);
  725. v.ClearFlag();
  726. ((IList<uint>)v).Clear();
  727. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
  728. ValidateValue(((IList<uint>)v).Count, 0);
  729. var ud = new UserDefinedStruct()
  730. {
  731. Id = 1
  732. }
  733. ;
  734. //Add
  735. v.ClearFlag();
  736. v.Add(ud);
  737. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  738. ValidateValue(((IList<UserDefinedStruct>)v)[0].Id, 1);
  739. //Contains
  740. v.ClearFlag();
  741. b = v.Contains(ud);
  742. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  743. ValidateValue(b, true);
  744. //'CopyTo
  745. //v.ClearFlag()
  746. //Dim arr As UserDefinedStruct()
  747. //ReDim arr(10)
  748. //v.CopyTo(arr, 0)
  749. //ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt)
  750. //ValidateValue(arr[0].Id, ud.Id)
  751. //GetEnumerator
  752. v.ClearFlag();
  753. int count = ((IList<UserDefinedStruct>)v).Count;
  754. IEnumerator<UserDefinedStruct> enumerator = ((IList<UserDefinedStruct>)v).GetEnumerator();
  755. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetMany);
  756. enumerator.MoveNext();
  757. ValidateValue((enumerator.Current).Id, 1);
  758. //IndexOf
  759. v.ClearFlag();
  760. rez = v.IndexOf(ud);
  761. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  762. ValidateValue(rez, 0); // 1 is on the first line :)
  763. //Insert
  764. v.ClearFlag();
  765. v.Insert(1, new UserDefinedStruct()
  766. {
  767. Id = 4
  768. }
  769. );
  770. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
  771. ValidateValue(((IList<UserDefinedStruct>)v)[1].Id, 4);
  772. //IsReadOnly
  773. v.ClearFlag();
  774. isReadOnly = ((IList<UserDefinedStruct>)v).IsReadOnly;
  775. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  776. ValidateValue(isReadOnly, false);
  777. //Indexing
  778. v.ClearFlag();
  779. var val2 = ((IList<UserDefinedStruct>)v)[0];
  780. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  781. ValidateValue(val2.Id, ud.Id);
  782. v.ClearFlag();
  783. val2 = ((IList<UserDefinedStruct>)v)[1];
  784. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  785. ValidateValue(val2.Id, 4);
  786. //Remove
  787. v.ClearFlag();
  788. v.Remove(ud);
  789. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  790. ValidateValue(((IList<UserDefinedStruct>)v).Count, 1);
  791. //RemoveAt
  792. v.ClearFlag();
  793. ((IList<UserDefinedStruct>)v).RemoveAt(0);
  794. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  795. ValidateValue(((IList<UserDefinedStruct>)v).Count, 0);
  796. //Clear
  797. v.Add(ud);
  798. v.Add(new UserDefinedStruct()
  799. {
  800. Id = 4
  801. }
  802. );
  803. v.ClearFlag();
  804. ((IList<UserDefinedStruct>)v).Clear();
  805. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
  806. ValidateValue(((IList<UserDefinedStruct>)v).Count, 0);
  807. }
  808. static void TestIVectorUintFloatMembers()
  809. {
  810. Console.WriteLine(""=== IVectorUintIVectorFloat ==="");
  811. var v = new IVectorUintIVectorFloat();
  812. //Add
  813. v.ClearFlag();
  814. v.Add(7);
  815. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  816. ValidateValue(((IList<uint>)v).Count, 1);
  817. try
  818. {
  819. ValidateValue(((IList<uint>)v)[0], 7);
  820. }
  821. catch (ArgumentException exc)
  822. {
  823. Console.WriteLine(exc.Message);
  824. }
  825. //Contains
  826. v.ClearFlag();
  827. bool b = v.Contains(7);
  828. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  829. ValidateValue(b, true);
  830. //IndexOf
  831. v.ClearFlag();
  832. var rez = ((IList<uint>)v).IndexOf(7);
  833. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  834. ValidateValue(rez, 0);
  835. //Insertv.ClearFlag()
  836. v.Insert(1, 5);
  837. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
  838. try
  839. {
  840. ValidateValue(((IList<uint>)v)[1], 5);
  841. }
  842. catch (ArgumentException exc)
  843. {
  844. Console.WriteLine(exc.Message);
  845. }
  846. //IsReadOnly
  847. v.ClearFlag();
  848. bool isReadOnly = ((IList<uint>)v).IsReadOnly;
  849. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  850. ValidateValue(isReadOnly, false);
  851. //Indexing
  852. try
  853. {
  854. v.ClearFlag();
  855. var val = (v as IList<uint>)[0];
  856. ValidateValue(val, 7);
  857. v.ClearFlag();
  858. val = ((IList<uint>)v)[1];
  859. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  860. ValidateValue(val, 5);
  861. }
  862. catch (Exception exce)
  863. {
  864. Console.WriteLine(""Indexing"");
  865. Console.WriteLine(exce.Message);
  866. }
  867. //Remove
  868. v.ClearFlag();
  869. v.Remove(5);
  870. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  871. ValidateValue(((IList<uint>)v).Count, 1);
  872. //RemoveAt
  873. try
  874. {
  875. v.ClearFlag();
  876. ((IList<uint>)v).RemoveAt(0);
  877. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  878. ValidateValue(((IList<uint>)v).Count, 0);
  879. }
  880. catch (Exception exce)
  881. {
  882. Console.WriteLine(""RemoveAt"");
  883. Console.WriteLine(exce.Message);
  884. }
  885. //Clear
  886. v.Add(1);
  887. v.Add(2);
  888. v.ClearFlag();
  889. ((IList<uint>)v).Clear();
  890. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
  891. ValidateValue(((IList<uint>)v).Count, 0);
  892. //single
  893. //Add
  894. v.ClearFlag();
  895. float one = 1;
  896. v.Add(one);
  897. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  898. ValidateValue(((IList<float>)v)[0], one);
  899. //Contains
  900. v.ClearFlag();
  901. b = v.Contains(one);
  902. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  903. ValidateValue(b, true);
  904. //'CopyTo
  905. //v.ClearFlag()
  906. //Dim arr As single()
  907. //ReDim arr(10)
  908. //v.CopyTo(arr, 0)
  909. //ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt)
  910. //ValidateValue(arr[0].Id, ud.Id)
  911. //IndexOf
  912. v.ClearFlag();
  913. rez = v.IndexOf(one);
  914. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  915. ValidateValue(rez, 0); // 1 is on the first line :)
  916. //Insert
  917. v.ClearFlag();
  918. v.Insert(1, (float)4);
  919. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
  920. ValidateValue(((IList<float>)v)[1], 4);
  921. //IsReadOnly
  922. v.ClearFlag();
  923. isReadOnly = ((IList<float>)v).IsReadOnly;
  924. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  925. ValidateValue(isReadOnly, false);
  926. //Indexing
  927. v.ClearFlag();
  928. var val2 = ((IList<float>)v)[0];
  929. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  930. ValidateValue(val2, one);
  931. v.ClearFlag();
  932. val2 = ((IList<float>)v)[1];
  933. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  934. ValidateValue(val2, 4);
  935. //Remove
  936. v.ClearFlag();
  937. v.Remove(one);
  938. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  939. ValidateValue(((IList<float>)v).Count, 1);
  940. //RemoveAt
  941. v.ClearFlag();
  942. ((IList<float>)v).RemoveAt(0);
  943. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  944. ValidateValue(((IList<float>)v).Count, 0);
  945. //Clear
  946. v.Add(one);
  947. v.ClearFlag();
  948. ((IList<float>)v).Clear();
  949. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
  950. ValidateValue(((IList<float>)v).Count, 0);
  951. }
  952. static void TestIVectorIntIMapIntIntMembers()
  953. {
  954. Console.WriteLine(""=== IVectorIntIMapIntInt ==="");
  955. var v = new IVectorIntIMapIntInt();
  956. //Add
  957. v.ClearFlag();
  958. v.Add(1);
  959. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  960. ValidateValue((v as IList<int>)[0], 1);
  961. //Contains
  962. v.ClearFlag();
  963. bool b = v.Contains(1);
  964. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  965. ValidateValue(b, true);
  966. //CopyTo
  967. v.ClearFlag();
  968. int[] arr = new int[10];
  969. v.CopyTo(arr, 0);
  970. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  971. ValidateValue(arr[0], 1);
  972. ValidateValue(arr[1], 0); //there should be nothing there! :)
  973. //'GetEnumerator
  974. //v.ClearFlag()
  975. //Dim count As Integer = v.Count
  976. //Dim enumerator As IEnumerator(Of Integer) = v.GetEnumerator()
  977. //ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First)
  978. //Dim index As Integer = 0
  979. //For Each e In v
  980. // index = index + 1
  981. // ValidateValue(e, index)
  982. //Next
  983. //ValidateValue(index, 1) 'there should only be 1 element there
  984. //IndexOf
  985. v.ClearFlag();
  986. var rez = v.IndexOf(1);
  987. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  988. ValidateValue(rez, 0); // 1 is on the first line :)
  989. //Insert
  990. v.ClearFlag();
  991. v.Insert(1, 2);
  992. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
  993. ValidateValue((v as IList<int>)[1], 2);
  994. //IsReadOnly
  995. v.ClearFlag();
  996. bool isReadOnly = ((IList<int>)v).IsReadOnly;
  997. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  998. ValidateValue(isReadOnly, false);
  999. //Indexing
  1000. v.ClearFlag();
  1001. int val = ((int)(v as IList<int>)[0]);
  1002. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  1003. ValidateValue(val, 1);
  1004. v.ClearFlag();
  1005. val = ((IList<int>)v)[1];
  1006. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  1007. ValidateValue(val, 2);
  1008. //Remove
  1009. v.ClearFlag();
  1010. ((IList<int>)v).Remove(1);
  1011. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  1012. ValidateValue(((IList<int>)v).Count, 1);
  1013. //RemoveAt
  1014. v.ClearFlag();
  1015. v.RemoveAt(0);
  1016. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  1017. ValidateValue(((IList<int>)v).Count, 0);
  1018. //Clear
  1019. v.Add(1);
  1020. v.Add(2);
  1021. v.ClearFlag();
  1022. ((IList<int>)v).Clear();
  1023. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
  1024. ValidateValue(((IList<int>)v).Count, 0);
  1025. var m = v;
  1026. //Add
  1027. m.ClearFlag();
  1028. m.Add(1, 2);
  1029. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
  1030. ValidateValue(((IDictionary<int, int>)m).Count, 1);
  1031. //ContainsKey
  1032. m.ClearFlag();
  1033. bool key = m.ContainsKey(1);
  1034. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  1035. //Lookup
  1036. m.ClearFlag();
  1037. int val2 = ((int)(v as IDictionary<int, int>)[1]);
  1038. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  1039. ValidateValue(val2, 2);
  1040. //Keys
  1041. m.ClearFlag();
  1042. var keys = m.Keys;
  1043. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  1044. //Values
  1045. m.ClearFlag();
  1046. var values = m.Values;
  1047. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  1048. //Lookup
  1049. m.ClearFlag();
  1050. int outVal;
  1051. bool success = ((IDictionary<int, int>)m).TryGetValue(1, out outVal);
  1052. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  1053. ValidateValue(success, true);
  1054. ValidateValue(outVal, 2);
  1055. //Add
  1056. m.ClearFlag();
  1057. m.Add(new KeyValuePair<int, int>(3, 4));
  1058. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
  1059. ValidateValue(((IDictionary<int, int>)m).Count, 2);
  1060. //Contains
  1061. m.ClearFlag();
  1062. bool contains = m.Contains(new KeyValuePair<int, int>(3, 4));
  1063. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  1064. ValidateValue(contains, true);
  1065. //non-existant pair
  1066. m.ClearFlag();
  1067. contains = m.Contains(new KeyValuePair<int, int>(8, 9));
  1068. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  1069. ValidateValue(contains, false);
  1070. //Remove
  1071. m.ClearFlag();
  1072. bool remove = ((IDictionary<int, int>)m).Remove(1);
  1073. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Remove);
  1074. ValidateValue(((IDictionary<int, int>)m).Count, 1);
  1075. ValidateValue(remove, true);
  1076. //CopyTo
  1077. //m.ClearFlag()
  1078. //Dim arr As KeyValuePair(Of Integer, Integer)()
  1079. //ReDim arr(10)
  1080. //m.CopyTo(arr, 1)
  1081. //ValidateMethod(m.GetFlagState(), TestMethodCalled.IVector_GetAt)
  1082. //ValidateValue(arr[0].Value, 2)
  1083. //Count
  1084. m.ClearFlag();
  1085. int count = ((IDictionary<int, int>)m).Count;
  1086. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_get_Size);
  1087. ValidateValue(count, 1);
  1088. //isReadOnly
  1089. m.ClearFlag();
  1090. isReadOnly = ((IDictionary<int, int>)m).IsReadOnly;
  1091. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  1092. ValidateValue(isReadOnly, false);
  1093. //Remove
  1094. m.ClearFlag();
  1095. var rez2 = m.Remove(new KeyValuePair<int, int>(3, 4));
  1096. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Remove);
  1097. ValidateValue(rez2, true);
  1098. m.ClearFlag();
  1099. rez2 = m.Remove(new KeyValuePair<int, int>(2, 3));
  1100. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  1101. ValidateValue(rez2, false);
  1102. m.Add(1, 2);
  1103. m.Add(2, 3);
  1104. m.ClearFlag();
  1105. ((IDictionary<int, int>)m).Clear();
  1106. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Clear);
  1107. ValidateValue(((IDictionary<int, int>)m).Count, 0);
  1108. }
  1109. static void TestIVectorExplicitAddMembers()
  1110. {
  1111. IVectorExplicitAdd v = new IVectorExplicitAdd();
  1112. //Calling the user defined Add method
  1113. v.ClearFlag();
  1114. ((IMemberAdd)v).Add(1);
  1115. ValidateMethod(v.GetFlagState(), TestMethodCalled.UserDef_Add);
  1116. v.ClearFlag();
  1117. ((IMemberAdd)v).Add(1);
  1118. ValidateMethod(v.GetFlagState(), TestMethodCalled.UserDef_Add);
  1119. //Calling the Interface Add's method
  1120. v.ClearFlag();
  1121. ((IList<int>)v).Add(1);
  1122. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  1123. ValidateValue(v[0], 1);
  1124. }
  1125. static void TestIVectorViewMembers()
  1126. {
  1127. var v = new IVectorViewInt();
  1128. v.ClearFlag();
  1129. int count = v.Count;
  1130. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVectorView_get_Size);
  1131. }
  1132. static void TestIVectorUIntIVectorViewIntMembers()
  1133. {
  1134. Console.WriteLine(""=== IVectorUintIVectorViewInt ==="");
  1135. var v = new IVectorUintIVectorViewInt();
  1136. //Add
  1137. v.ClearFlag();
  1138. v.Add(1);
  1139. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  1140. ValidateValue((v as IList<uint>)[0], 1);
  1141. //Contains
  1142. v.ClearFlag();
  1143. bool b = v.Contains(1);
  1144. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  1145. ValidateValue(b, true);
  1146. //CopyTo
  1147. v.ClearFlag();
  1148. uint[] arr = new uint[10];
  1149. v.CopyTo(arr, 0);
  1150. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  1151. ValidateValue(arr[0], 1);
  1152. ValidateValue(arr[1], 0); //there should be nothing there! :)
  1153. //GetEnumerator
  1154. v.ClearFlag();
  1155. uint count = ((uint)(v as IList<uint>).Count);
  1156. IEnumerator<uint> enumerator = ((IEnumerable<uint>)v).GetEnumerator();
  1157. ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First);
  1158. uint index = 0;
  1159. foreach (var e in v)
  1160. {
  1161. index = ((uint)index + 1);
  1162. ValidateValue(e, index);
  1163. }
  1164. ValidateValue(index, 1); //there should only be 1 element there
  1165. //IndexOf
  1166. v.ClearFlag();
  1167. var rez = v.IndexOf(1);
  1168. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  1169. ValidateValue(rez, 0); // 1 is on the first line :)
  1170. //Insert
  1171. v.ClearFlag();
  1172. v.Insert(1, 2);
  1173. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
  1174. ValidateValue((v as IList<uint>)[1], 2);
  1175. //IsReadOnly
  1176. v.ClearFlag();
  1177. bool isReadOnly = v.IsReadOnly;
  1178. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  1179. ValidateValue(isReadOnly, false);
  1180. //Indexing
  1181. v.ClearFlag();
  1182. uint val = (v as IList<uint>)[0];
  1183. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  1184. ValidateValue(val, 1);
  1185. v.ClearFlag();
  1186. val = (((IList<uint>)v))[1];
  1187. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  1188. ValidateValue(val, 2);
  1189. //Remove
  1190. v.ClearFlag();
  1191. v.Remove(1);
  1192. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  1193. ValidateValue((v as IList<uint>).Count, 1);
  1194. //RemoveAt
  1195. v.ClearFlag();
  1196. v.RemoveAt(0);
  1197. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  1198. ValidateValue((v as IList<uint>).Count, 0);
  1199. //Clear
  1200. v.Add(1);
  1201. v.Add(2);
  1202. v.ClearFlag();
  1203. v.Clear();
  1204. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
  1205. ValidateValue((v as IList<uint>).Count, 0);
  1206. // IVectorView members
  1207. v.Add(1);
  1208. v.Add(2);
  1209. v.ClearFlag();
  1210. ValidateValue(((IReadOnlyList<uint>)v).Count, 2);
  1211. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_get_Size);
  1212. v.ClearFlag();
  1213. ValidateValue(((IReadOnlyList<uint>)v)[0], 1);
  1214. ValidateValue(((IReadOnlyList<uint>)v)[1], 2);
  1215. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVectorView_GetAt);
  1216. }
  1217. static void TestIVectorIntIVectorViewUintMembers()
  1218. {
  1219. Console.WriteLine(""=== IVectorIntIVectorViewUint ==="");
  1220. var v = new IVectorIntIVectorViewUint();
  1221. //Add
  1222. v.ClearFlag();
  1223. v.Add(1);
  1224. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  1225. ValidateValue((v as IList<int>)[0], 1);
  1226. //Contains
  1227. v.ClearFlag();
  1228. bool b = v.Contains(1);
  1229. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  1230. ValidateValue(b, true);
  1231. //CopyTo
  1232. v.ClearFlag();
  1233. int[] arr = new int[10];
  1234. v.CopyTo(arr, 0);
  1235. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  1236. ValidateValue(arr[0], 1);
  1237. ValidateValue(arr[1], 0); //there should be nothing there! :)
  1238. //GetEnumerator
  1239. v.ClearFlag();
  1240. uint count = ((uint)(((IList<int>)v)).Count);
  1241. IEnumerator<int> enumerator = (((IList<int>)v)).GetEnumerator();
  1242. ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First);
  1243. uint index = 0;
  1244. foreach (var e in (((IList<int>)v)))
  1245. {
  1246. index = ((uint)index + 1);
  1247. ValidateValue(e, index);
  1248. }
  1249. ValidateValue(index, 1); //there should only be 1 element there
  1250. //IndexOf
  1251. v.ClearFlag();
  1252. var rez = v.IndexOf(1);
  1253. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  1254. ValidateValue(rez, 0); // 1 is on the first line :)
  1255. //Insert
  1256. v.ClearFlag();
  1257. v.Insert(1, 2);
  1258. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
  1259. ValidateValue((v as IList<int>)[1], 2);
  1260. //IsReadOnly
  1261. v.ClearFlag();
  1262. bool isReadOnly = v.IsReadOnly;
  1263. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  1264. ValidateValue(isReadOnly, false);
  1265. //Indexing
  1266. v.ClearFlag();
  1267. uint val = ((uint)(v as IList<int>)[0]);
  1268. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  1269. ValidateValue(val, 1);
  1270. v.ClearFlag();
  1271. val = ((uint)(((IList<int>)v))[1]);
  1272. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  1273. ValidateValue(val, 2);
  1274. //Remove
  1275. v.ClearFlag();
  1276. v.Remove(1);
  1277. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  1278. ValidateValue((((IList<int>)v)).Count, 1);
  1279. //RemoveAt
  1280. v.ClearFlag();
  1281. v.RemoveAt(0);
  1282. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  1283. ValidateValue((((IList<int>)v)).Count, 0);
  1284. //Clear
  1285. v.Add(1);
  1286. v.Add(2);
  1287. v.ClearFlag();
  1288. v.Clear();
  1289. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
  1290. ValidateValue((((IList<int>)v)).Count, 0);
  1291. // IVectorView members
  1292. v.Add(1);
  1293. v.Add(2);
  1294. v.ClearFlag();
  1295. ValidateValue(((IReadOnlyList<uint>)v)[0], 0);
  1296. ValidateValue(((IReadOnlyList<uint>)v)[1], 0);
  1297. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  1298. }
  1299. static void TestIVectorStructIVectorViewStructMembers()
  1300. {
  1301. Console.WriteLine(""=== IVectorStructIVectorViewStruct ==="");
  1302. var v = new IVectorStructIVectorViewStruct();
  1303. var ud = new UserDefinedStruct()
  1304. {
  1305. Id = 1
  1306. }
  1307. ;
  1308. //Add
  1309. v.ClearFlag();
  1310. v.Add(ud);
  1311. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  1312. ValidateValue((v as IList<UserDefinedStruct>)[0].Id, 1);
  1313. //Contains
  1314. v.ClearFlag();
  1315. bool b = v.Contains(ud);
  1316. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  1317. ValidateValue(b, true);
  1318. //CopyTo
  1319. v.ClearFlag();
  1320. UserDefinedStruct[] arr = new UserDefinedStruct[10];
  1321. v.CopyTo(arr, 0);
  1322. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  1323. ValidateValue(arr[0].Id, ud.Id);
  1324. //GetEnumerator
  1325. v.ClearFlag();
  1326. int count = (v as IList<UserDefinedStruct>).Count;
  1327. IEnumerator<UserDefinedStruct> enumerator = ((IEnumerable<UserDefinedStruct>)v).GetEnumerator();
  1328. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_get_Size);
  1329. enumerator.MoveNext();
  1330. ValidateValue((enumerator.Current).Id, 1);
  1331. int index = 0;
  1332. foreach (var e in v)
  1333. {
  1334. index = index + 1;
  1335. ValidateValue(e.Id, index);
  1336. }
  1337. ValidateValue(index, 1); //there should only be 1 element there
  1338. //IndexOf
  1339. v.ClearFlag();
  1340. var rez = v.IndexOf(ud);
  1341. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  1342. ValidateValue(rez, 0); // 1 is on the first line :)
  1343. //Insert
  1344. v.ClearFlag();
  1345. v.Insert(1, new UserDefinedStruct()
  1346. {
  1347. Id = 4
  1348. }
  1349. );
  1350. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
  1351. ValidateValue((v as IList<UserDefinedStruct>)[1].Id, 4);
  1352. //IsReadOnly
  1353. v.ClearFlag();
  1354. bool isReadOnly = v.IsReadOnly;
  1355. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  1356. ValidateValue(isReadOnly, false);
  1357. //Indexing
  1358. v.ClearFlag();
  1359. var val = (v as IList<UserDefinedStruct>)[0];
  1360. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  1361. ValidateValue(val.Id, ud.Id);
  1362. v.ClearFlag();
  1363. val = ((IList<UserDefinedStruct>)v)[1];
  1364. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  1365. ValidateValue(val.Id, 4);
  1366. //Remove
  1367. v.ClearFlag();
  1368. v.Remove(ud);
  1369. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  1370. ValidateValue((v as IList<UserDefinedStruct>).Count, 1);
  1371. //RemoveAt
  1372. v.ClearFlag();
  1373. v.RemoveAt(0);
  1374. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  1375. ValidateValue((v as IList<UserDefinedStruct>).Count, 0);
  1376. //Clear
  1377. v.Add(ud);
  1378. v.Add(new UserDefinedStruct()
  1379. {
  1380. Id = 4
  1381. }
  1382. );
  1383. v.ClearFlag();
  1384. v.Clear();
  1385. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
  1386. ValidateValue((v as IList<UserDefinedStruct>).Count, 0);
  1387. // IVectorView members
  1388. v.Add(ud);
  1389. v.Add(new UserDefinedStruct()
  1390. {
  1391. Id = 4
  1392. }
  1393. );
  1394. v.ClearFlag();
  1395. ValidateValue(((IReadOnlyList<UserDefinedStruct>)v)[0].Id, ud.Id);
  1396. ValidateValue(((IReadOnlyList<UserDefinedStruct>)v)[1].Id, 4);
  1397. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  1398. }
  1399. static int Main()
  1400. {
  1401. TestIVectorIntMembers();
  1402. TestIVectorStructMembers();
  1403. TestIVectorUintStructMembers();
  1404. TestIVectorUintFloatMembers();
  1405. TestIVectorIntIMapIntIntMembers();
  1406. TestIVectorExplicitAddMembers();
  1407. TestIVectorViewMembers();
  1408. TestIVectorUIntIVectorViewIntMembers();
  1409. TestIVectorIntIVectorViewUintMembers();
  1410. TestIVectorStructIVectorViewStructMembers();
  1411. Console.WriteLine(FailedCount);
  1412. return FailedCount;
  1413. }
  1414. }";
  1415. var comp = CreateCompilationWithMscorlibAndSystemCore(source, references: LegacyRefs);
  1416. comp.VerifyDiagnostics(
  1417. // (3,1): info CS8019: Unnecessary using directive.
  1418. // using System.Reflection;
  1419. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  1420. // (4,1): info CS8019: Unnecessary using directive.
  1421. // using System.Linq.Expressions;
  1422. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  1423. // (6,1): info CS8019: Unnecessary using directive.
  1424. // using System.Linq;
  1425. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"));
  1426. }
  1427. [Fact]
  1428. public void LegacyCollectionTest03()
  1429. {
  1430. var source =
  1431. @"using Windows.Languages.WinRTTest;
  1432. using System.Collections.Generic;
  1433. using System.Reflection;
  1434. using System.Linq.Expressions;
  1435. using System;
  1436. using System.Linq;
  1437. class AllMembers
  1438. {
  1439. private static int FailedCount = 0;
  1440. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  1441. {
  1442. var temp = Console.ForegroundColor;
  1443. if (actual != expected)
  1444. {
  1445. FailedCount++;
  1446. Console.ForegroundColor = ConsoleColor.Red;
  1447. Console.Write(""FAIL: "");
  1448. }
  1449. else
  1450. {
  1451. Console.ForegroundColor = ConsoleColor.Green;
  1452. Console.Write(""PASS: "");
  1453. }
  1454. Console.ForegroundColor = temp;
  1455. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  1456. return actual == expected;
  1457. }
  1458. private static bool ValidateValue(object actual, object expected)
  1459. {
  1460. var temp = Console.ForegroundColor;
  1461. if (actual.ToString() != expected.ToString())
  1462. {
  1463. FailedCount++;
  1464. Console.ForegroundColor = ConsoleColor.Red;
  1465. Console.Write(""FAIL: "");
  1466. }
  1467. else
  1468. {
  1469. Console.ForegroundColor = ConsoleColor.Green;
  1470. Console.Write(""PASS: "");
  1471. }
  1472. Console.ForegroundColor = temp;
  1473. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  1474. return actual.ToString() == expected.ToString();
  1475. }
  1476. static void TestIMapIntIntMembers()
  1477. {
  1478. Console.WriteLine(""=== IMapIntInt ==="");
  1479. var m = new IMapIntInt();
  1480. //Add
  1481. m.ClearFlag();
  1482. m.Add(1, 2);
  1483. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
  1484. ValidateValue(m.Count, 1);
  1485. //ContainsKey
  1486. m.ClearFlag();
  1487. bool key = m.ContainsKey(1);
  1488. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  1489. //Lookup
  1490. m.ClearFlag();
  1491. int val = m[1];
  1492. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  1493. ValidateValue(val, 2);
  1494. //Keys
  1495. m.ClearFlag();
  1496. var keys = m.Keys;
  1497. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  1498. //Values
  1499. m.ClearFlag();
  1500. var values = m.Values;
  1501. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  1502. //Lookup
  1503. m.ClearFlag();
  1504. int outVal;
  1505. bool success = ((IDictionary<int, int>)m).TryGetValue(1, out outVal);
  1506. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  1507. ValidateValue(outVal, 2);
  1508. ValidateValue(success, true);
  1509. //Add
  1510. m.ClearFlag();
  1511. m.Add(new KeyValuePair<int, int>(3, 4));
  1512. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
  1513. ValidateValue(m.Count, 2);
  1514. //Contains
  1515. m.ClearFlag();
  1516. bool contains = m.Contains(new KeyValuePair<int, int>(3, 4));
  1517. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  1518. ValidateValue(contains, true);
  1519. //non-existant pair
  1520. m.ClearFlag();
  1521. contains = m.Contains(new KeyValuePair<int, int>(8, 9));
  1522. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  1523. ValidateValue(contains, false);
  1524. //Remove
  1525. m.ClearFlag();
  1526. bool remove = m.Remove(1);
  1527. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Remove);
  1528. ValidateValue(m.Count, 1);
  1529. ValidateValue(remove, true);
  1530. //Count
  1531. m.ClearFlag();
  1532. int count = m.Count;
  1533. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_get_Size);
  1534. ValidateValue(count, 1);
  1535. //isReadOnly
  1536. m.ClearFlag();
  1537. bool isReadOnly = m.IsReadOnly;
  1538. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  1539. ValidateValue(isReadOnly, false);
  1540. //Remove
  1541. m.ClearFlag();
  1542. var rez = m.Remove(new KeyValuePair<int, int>(3, 4));
  1543. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Remove);
  1544. ValidateValue(rez, true);
  1545. m.ClearFlag();
  1546. rez = m.Remove(new KeyValuePair<int, int>(2, 3));
  1547. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  1548. ValidateValue(rez, false);
  1549. m.Add(1, 2);
  1550. m.Add(2, 3);
  1551. m.ClearFlag();
  1552. m.Clear();
  1553. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Clear);
  1554. ValidateValue(m.Count, 0);
  1555. }
  1556. static void TestIMapIntStructMembers()
  1557. {
  1558. Console.WriteLine(""=== IMapIntStruct ==="");
  1559. var m = new IMapIntStruct();
  1560. var ud = new UserDefinedStruct()
  1561. {
  1562. Id = 10
  1563. }
  1564. ;
  1565. //Add
  1566. m.ClearFlag();
  1567. m.Add(1, ud);
  1568. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
  1569. ValidateValue(m.Count, 1);
  1570. //ContainsKey
  1571. m.ClearFlag();
  1572. bool key = m.ContainsKey(1);
  1573. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  1574. //Lookup
  1575. m.ClearFlag();
  1576. UserDefinedStruct val = m[1];
  1577. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  1578. ValidateValue(val.Id, 10);
  1579. //Keys
  1580. m.ClearFlag();
  1581. var keys = m.Keys;
  1582. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  1583. //Values
  1584. m.ClearFlag();
  1585. var values = m.Values;
  1586. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  1587. //Lookup
  1588. m.ClearFlag();
  1589. UserDefinedStruct outVal;
  1590. bool success = ((IDictionary<int, UserDefinedStruct>)m).TryGetValue(1, out outVal);
  1591. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  1592. ValidateValue(outVal.Id, ud.Id);
  1593. ValidateValue(success, true);
  1594. //Add
  1595. m.ClearFlag();
  1596. m.Add(new KeyValuePair<int, UserDefinedStruct>(3, new UserDefinedStruct()
  1597. {
  1598. Id = 4
  1599. }
  1600. ));
  1601. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
  1602. ValidateValue(m.Count, 2);
  1603. //Contains
  1604. m.ClearFlag();
  1605. bool contains = m.Contains(new KeyValuePair<int, UserDefinedStruct>(1, ud));
  1606. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  1607. ValidateValue(contains, true);
  1608. //non-existant pair
  1609. m.ClearFlag();
  1610. contains = m.Contains(new KeyValuePair<int, UserDefinedStruct>(8, new UserDefinedStruct()));
  1611. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  1612. ValidateValue(contains, false);
  1613. //Remove
  1614. m.ClearFlag();
  1615. bool remove = m.Remove(3);
  1616. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Remove);
  1617. ValidateValue(m.Count, 1);
  1618. ValidateValue(remove, true);
  1619. //Count
  1620. m.ClearFlag();
  1621. int count = m.Count;
  1622. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_get_Size);
  1623. ValidateValue(count, 1);
  1624. //isReadOnly
  1625. m.ClearFlag();
  1626. bool isReadOnly = m.IsReadOnly;
  1627. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  1628. ValidateValue(isReadOnly, false);
  1629. //Remove
  1630. m.ClearFlag();
  1631. var rez = m.Remove(new KeyValuePair<int, UserDefinedStruct>(1, ud));
  1632. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Remove);
  1633. ValidateValue(rez, true);
  1634. ValidateValue(m.Count, 0);
  1635. //Clear
  1636. m.Add(1, ud);
  1637. m.Add(2, ud);
  1638. m.ClearFlag();
  1639. m.Clear();
  1640. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Clear);
  1641. ValidateValue(m.Count, 0);
  1642. }
  1643. static void TestIMapExplicitAddMembers()
  1644. {
  1645. IMapExplicitAdd v = new IMapExplicitAdd();
  1646. //Calling the user defined Add method
  1647. v.ClearFlag();
  1648. ((IMemberAdd2Args)v).Add(1, 1);
  1649. ValidateMethod(v.GetFlagState(), TestMethodCalled.UserDef_Add);
  1650. v.ClearFlag();
  1651. ((IMemberAdd2Args)v).Add(2, 2);
  1652. ValidateMethod(v.GetFlagState(), TestMethodCalled.UserDef_Add);
  1653. //Calling the Interface Add's method
  1654. v.ClearFlag();
  1655. ((IDictionary<int, int>)v).Add(3, 3);
  1656. ValidateMethod(v.GetFlagState(), TestMethodCalled.IMap_Insert);
  1657. ValidateValue(v.Count, 3);
  1658. }
  1659. static void TestIMapViewMembers()
  1660. {
  1661. var m = new IMapViewIntInt();
  1662. m.ClearFlag();
  1663. int count = m.Count;
  1664. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_get_Size);
  1665. }
  1666. static void TestIMapIntIMapViewIntStructMembers()
  1667. {
  1668. Console.WriteLine(""=== IMapIMapViewIntStruct ==="");
  1669. var m = new IMapIMapViewIntStruct();
  1670. var ud = new UserDefinedStruct() { Id = 10 };
  1671. //Add
  1672. m.ClearFlag();
  1673. m.Add(1, ud);
  1674. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
  1675. ValidateValue((m as IDictionary<int, UserDefinedStruct>).Count, 1);
  1676. //ContainsKey
  1677. m.ClearFlag();
  1678. bool key = ((IDictionary<int, UserDefinedStruct>)m).ContainsKey(1);
  1679. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  1680. //Lookup
  1681. m.ClearFlag();
  1682. UserDefinedStruct val = ((IDictionary<int, UserDefinedStruct>)m)[1];
  1683. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  1684. ValidateValue(val.Id, 10);
  1685. //Keys
  1686. m.ClearFlag();
  1687. var keys = ((IDictionary<int, UserDefinedStruct>)m).Keys;
  1688. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  1689. //Values
  1690. m.ClearFlag();
  1691. var values = ((IDictionary<int, UserDefinedStruct>)m).Values;
  1692. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  1693. //Lookup
  1694. m.ClearFlag();
  1695. UserDefinedStruct outVal;
  1696. bool success = ((IDictionary<int, UserDefinedStruct>)m).TryGetValue(1, out outVal);
  1697. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  1698. ValidateValue(success, true);
  1699. //Add
  1700. m.ClearFlag();
  1701. m.Add(new KeyValuePair<int, UserDefinedStruct>(3, new UserDefinedStruct()
  1702. {
  1703. Id = 4
  1704. }
  1705. ));
  1706. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
  1707. ValidateValue((m as IDictionary<int, UserDefinedStruct>).Count, 2);
  1708. //Contains
  1709. m.ClearFlag();
  1710. bool contains = m.Contains(new KeyValuePair<int, UserDefinedStruct>(1, ud));
  1711. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  1712. ValidateValue(contains, true);
  1713. //non-existant pair
  1714. m.ClearFlag();
  1715. contains = m.Contains(new KeyValuePair<int, UserDefinedStruct>(8, new UserDefinedStruct()));
  1716. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  1717. ValidateValue(contains, false);
  1718. //Remove
  1719. m.ClearFlag();
  1720. bool remove = m.Remove(3);
  1721. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Remove);
  1722. ValidateValue((m as IDictionary<int, UserDefinedStruct>).Count, 1);
  1723. ValidateValue(remove, true);
  1724. //Count
  1725. m.ClearFlag();
  1726. int count = (m as IDictionary<int, UserDefinedStruct>).Count;
  1727. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_get_Size);
  1728. ValidateValue(count, 1);
  1729. //isReadOnly
  1730. m.ClearFlag();
  1731. bool isReadOnly = m.IsReadOnly;
  1732. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  1733. ValidateValue(isReadOnly, false);
  1734. //Remove
  1735. m.ClearFlag();
  1736. var rez = m.Remove(new KeyValuePair<int, UserDefinedStruct>(1, ud));
  1737. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Remove);
  1738. ValidateValue(rez, true);
  1739. ValidateValue((m as IDictionary<int, UserDefinedStruct>).Count, 0);
  1740. //m.ClearFlag()
  1741. //rez = m.Remove(New KeyValuePair(Of Integer, UserDefinedStruct)(3, ud))
  1742. //ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey)
  1743. //ValidateValue(rez, False)
  1744. //Clear
  1745. m.Add(1, ud);
  1746. m.Add(2, ud);
  1747. m.ClearFlag();
  1748. m.Clear();
  1749. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Clear);
  1750. ValidateValue((m as IDictionary<int, UserDefinedStruct>).Count, 0);
  1751. // IMapView members
  1752. m.ClearFlag();
  1753. count = ((IReadOnlyDictionary<int, UserDefinedStruct>)m).Count;
  1754. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_get_Size);
  1755. }
  1756. static int Main()
  1757. {
  1758. TestIMapIntIntMembers();
  1759. TestIMapIntStructMembers();
  1760. TestIMapExplicitAddMembers();
  1761. TestIMapViewMembers();
  1762. TestIMapIntIMapViewIntStructMembers();
  1763. Console.WriteLine(FailedCount);
  1764. return FailedCount;
  1765. }
  1766. }";
  1767. var verifier = CompileAndVerify(source,
  1768. additionalRefs: LegacyRefs,
  1769. emitOptions: EmitOptions.RefEmitBug,
  1770. //FIXME: Can't verify because the metadata adapter isn't implemented yet
  1771. verify: false);
  1772. verifier.VerifyDiagnostics(
  1773. // (3,1): info CS8019: Unnecessary using directive.
  1774. // using System.Reflection;
  1775. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  1776. // (4,1): info CS8019: Unnecessary using directive.
  1777. // using System.Linq.Expressions;
  1778. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  1779. // (6,1): info CS8019: Unnecessary using directive.
  1780. // using System.Linq;
  1781. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"));
  1782. verifier.VerifyIL("AllMembers.TestIMapIntIntMembers",
  1783. @"{
  1784. // Code size 756 (0x2f4)
  1785. .maxstack 4
  1786. .locals init (int V_0, //val
  1787. int V_1, //outVal
  1788. bool V_2, //success
  1789. bool V_3, //contains
  1790. bool V_4, //remove
  1791. int V_5, //count
  1792. bool V_6, //isReadOnly
  1793. bool V_7) //rez
  1794. IL_0000: ldstr ""=== IMapIntInt ===""
  1795. IL_0005: call ""void System.Console.WriteLine(string)""
  1796. IL_000a: newobj ""Windows.Languages.WinRTTest.IMapIntInt..ctor()""
  1797. IL_000f: dup
  1798. IL_0010: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  1799. IL_0015: dup
  1800. IL_0016: ldc.i4.1
  1801. IL_0017: ldc.i4.2
  1802. IL_0018: callvirt ""void System.Collections.Generic.IDictionary<int, int>.Add(int, int)""
  1803. IL_001d: dup
  1804. IL_001e: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  1805. IL_0023: ldc.i4.s 21
  1806. IL_0025: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  1807. IL_002a: pop
  1808. IL_002b: dup
  1809. IL_002c: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Count.get""
  1810. IL_0031: box ""int""
  1811. IL_0036: ldc.i4.1
  1812. IL_0037: box ""int""
  1813. IL_003c: call ""bool AllMembers.ValidateValue(object, object)""
  1814. IL_0041: pop
  1815. IL_0042: dup
  1816. IL_0043: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  1817. IL_0048: dup
  1818. IL_0049: ldc.i4.1
  1819. IL_004a: callvirt ""bool System.Collections.Generic.IDictionary<int, int>.ContainsKey(int)""
  1820. IL_004f: pop
  1821. IL_0050: dup
  1822. IL_0051: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  1823. IL_0056: ldc.i4.s 19
  1824. IL_0058: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  1825. IL_005d: pop
  1826. IL_005e: dup
  1827. IL_005f: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  1828. IL_0064: dup
  1829. IL_0065: ldc.i4.1
  1830. IL_0066: callvirt ""int System.Collections.Generic.IDictionary<int, int>.this[int].get""
  1831. IL_006b: stloc.0
  1832. IL_006c: dup
  1833. IL_006d: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  1834. IL_0072: ldc.i4.s 17
  1835. IL_0074: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  1836. IL_0079: pop
  1837. IL_007a: ldloc.0
  1838. IL_007b: box ""int""
  1839. IL_0080: ldc.i4.2
  1840. IL_0081: box ""int""
  1841. IL_0086: call ""bool AllMembers.ValidateValue(object, object)""
  1842. IL_008b: pop
  1843. IL_008c: dup
  1844. IL_008d: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  1845. IL_0092: dup
  1846. IL_0093: callvirt ""System.Collections.Generic.ICollection<int> System.Collections.Generic.IDictionary<int, int>.Keys.get""
  1847. IL_0098: pop
  1848. IL_0099: dup
  1849. IL_009a: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  1850. IL_009f: ldc.i4.0
  1851. IL_00a0: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  1852. IL_00a5: pop
  1853. IL_00a6: dup
  1854. IL_00a7: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  1855. IL_00ac: dup
  1856. IL_00ad: callvirt ""System.Collections.Generic.ICollection<int> System.Collections.Generic.IDictionary<int, int>.Values.get""
  1857. IL_00b2: pop
  1858. IL_00b3: dup
  1859. IL_00b4: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  1860. IL_00b9: ldc.i4.0
  1861. IL_00ba: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  1862. IL_00bf: pop
  1863. IL_00c0: dup
  1864. IL_00c1: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  1865. IL_00c6: dup
  1866. IL_00c7: ldc.i4.1
  1867. IL_00c8: ldloca.s V_1
  1868. IL_00ca: callvirt ""bool System.Collections.Generic.IDictionary<int, int>.TryGetValue(int, out int)""
  1869. IL_00cf: stloc.2
  1870. IL_00d0: dup
  1871. IL_00d1: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  1872. IL_00d6: ldc.i4.s 17
  1873. IL_00d8: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  1874. IL_00dd: pop
  1875. IL_00de: ldloc.1
  1876. IL_00df: box ""int""
  1877. IL_00e4: ldc.i4.2
  1878. IL_00e5: box ""int""
  1879. IL_00ea: call ""bool AllMembers.ValidateValue(object, object)""
  1880. IL_00ef: pop
  1881. IL_00f0: ldloc.2
  1882. IL_00f1: box ""bool""
  1883. IL_00f6: ldc.i4.1
  1884. IL_00f7: box ""bool""
  1885. IL_00fc: call ""bool AllMembers.ValidateValue(object, object)""
  1886. IL_0101: pop
  1887. IL_0102: dup
  1888. IL_0103: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  1889. IL_0108: dup
  1890. IL_0109: ldc.i4.3
  1891. IL_010a: ldc.i4.4
  1892. IL_010b: newobj ""System.Collections.Generic.KeyValuePair<int, int>..ctor(int, int)""
  1893. IL_0110: callvirt ""void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Add(System.Collections.Generic.KeyValuePair<int, int>)""
  1894. IL_0115: dup
  1895. IL_0116: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  1896. IL_011b: ldc.i4.s 21
  1897. IL_011d: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  1898. IL_0122: pop
  1899. IL_0123: dup
  1900. IL_0124: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Count.get""
  1901. IL_0129: box ""int""
  1902. IL_012e: ldc.i4.2
  1903. IL_012f: box ""int""
  1904. IL_0134: call ""bool AllMembers.ValidateValue(object, object)""
  1905. IL_0139: pop
  1906. IL_013a: dup
  1907. IL_013b: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  1908. IL_0140: dup
  1909. IL_0141: ldc.i4.3
  1910. IL_0142: ldc.i4.4
  1911. IL_0143: newobj ""System.Collections.Generic.KeyValuePair<int, int>..ctor(int, int)""
  1912. IL_0148: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Contains(System.Collections.Generic.KeyValuePair<int, int>)""
  1913. IL_014d: stloc.3
  1914. IL_014e: dup
  1915. IL_014f: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  1916. IL_0154: ldc.i4.s 17
  1917. IL_0156: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  1918. IL_015b: pop
  1919. IL_015c: ldloc.3
  1920. IL_015d: box ""bool""
  1921. IL_0162: ldc.i4.1
  1922. IL_0163: box ""bool""
  1923. IL_0168: call ""bool AllMembers.ValidateValue(object, object)""
  1924. IL_016d: pop
  1925. IL_016e: dup
  1926. IL_016f: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  1927. IL_0174: dup
  1928. IL_0175: ldc.i4.8
  1929. IL_0176: ldc.i4.s 9
  1930. IL_0178: newobj ""System.Collections.Generic.KeyValuePair<int, int>..ctor(int, int)""
  1931. IL_017d: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Contains(System.Collections.Generic.KeyValuePair<int, int>)""
  1932. IL_0182: stloc.3
  1933. IL_0183: dup
  1934. IL_0184: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  1935. IL_0189: ldc.i4.s 19
  1936. IL_018b: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  1937. IL_0190: pop
  1938. IL_0191: ldloc.3
  1939. IL_0192: box ""bool""
  1940. IL_0197: ldc.i4.0
  1941. IL_0198: box ""bool""
  1942. IL_019d: call ""bool AllMembers.ValidateValue(object, object)""
  1943. IL_01a2: pop
  1944. IL_01a3: dup
  1945. IL_01a4: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  1946. IL_01a9: dup
  1947. IL_01aa: ldc.i4.1
  1948. IL_01ab: callvirt ""bool System.Collections.Generic.IDictionary<int, int>.Remove(int)""
  1949. IL_01b0: stloc.s V_4
  1950. IL_01b2: dup
  1951. IL_01b3: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  1952. IL_01b8: ldc.i4.s 22
  1953. IL_01ba: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  1954. IL_01bf: pop
  1955. IL_01c0: dup
  1956. IL_01c1: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Count.get""
  1957. IL_01c6: box ""int""
  1958. IL_01cb: ldc.i4.1
  1959. IL_01cc: box ""int""
  1960. IL_01d1: call ""bool AllMembers.ValidateValue(object, object)""
  1961. IL_01d6: pop
  1962. IL_01d7: ldloc.s V_4
  1963. IL_01d9: box ""bool""
  1964. IL_01de: ldc.i4.1
  1965. IL_01df: box ""bool""
  1966. IL_01e4: call ""bool AllMembers.ValidateValue(object, object)""
  1967. IL_01e9: pop
  1968. IL_01ea: dup
  1969. IL_01eb: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  1970. IL_01f0: dup
  1971. IL_01f1: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Count.get""
  1972. IL_01f6: stloc.s V_5
  1973. IL_01f8: dup
  1974. IL_01f9: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  1975. IL_01fe: ldc.i4.s 18
  1976. IL_0200: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  1977. IL_0205: pop
  1978. IL_0206: ldloc.s V_5
  1979. IL_0208: box ""int""
  1980. IL_020d: ldc.i4.1
  1981. IL_020e: box ""int""
  1982. IL_0213: call ""bool AllMembers.ValidateValue(object, object)""
  1983. IL_0218: pop
  1984. IL_0219: dup
  1985. IL_021a: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  1986. IL_021f: dup
  1987. IL_0220: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.IsReadOnly.get""
  1988. IL_0225: stloc.s V_6
  1989. IL_0227: dup
  1990. IL_0228: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  1991. IL_022d: ldc.i4.0
  1992. IL_022e: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  1993. IL_0233: pop
  1994. IL_0234: ldloc.s V_6
  1995. IL_0236: box ""bool""
  1996. IL_023b: ldc.i4.0
  1997. IL_023c: box ""bool""
  1998. IL_0241: call ""bool AllMembers.ValidateValue(object, object)""
  1999. IL_0246: pop
  2000. IL_0247: dup
  2001. IL_0248: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  2002. IL_024d: dup
  2003. IL_024e: ldc.i4.3
  2004. IL_024f: ldc.i4.4
  2005. IL_0250: newobj ""System.Collections.Generic.KeyValuePair<int, int>..ctor(int, int)""
  2006. IL_0255: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Remove(System.Collections.Generic.KeyValuePair<int, int>)""
  2007. IL_025a: stloc.s V_7
  2008. IL_025c: dup
  2009. IL_025d: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  2010. IL_0262: ldc.i4.s 22
  2011. IL_0264: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2012. IL_0269: pop
  2013. IL_026a: ldloc.s V_7
  2014. IL_026c: box ""bool""
  2015. IL_0271: ldc.i4.1
  2016. IL_0272: box ""bool""
  2017. IL_0277: call ""bool AllMembers.ValidateValue(object, object)""
  2018. IL_027c: pop
  2019. IL_027d: dup
  2020. IL_027e: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  2021. IL_0283: dup
  2022. IL_0284: ldc.i4.2
  2023. IL_0285: ldc.i4.3
  2024. IL_0286: newobj ""System.Collections.Generic.KeyValuePair<int, int>..ctor(int, int)""
  2025. IL_028b: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Remove(System.Collections.Generic.KeyValuePair<int, int>)""
  2026. IL_0290: stloc.s V_7
  2027. IL_0292: dup
  2028. IL_0293: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  2029. IL_0298: ldc.i4.s 19
  2030. IL_029a: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2031. IL_029f: pop
  2032. IL_02a0: ldloc.s V_7
  2033. IL_02a2: box ""bool""
  2034. IL_02a7: ldc.i4.0
  2035. IL_02a8: box ""bool""
  2036. IL_02ad: call ""bool AllMembers.ValidateValue(object, object)""
  2037. IL_02b2: pop
  2038. IL_02b3: dup
  2039. IL_02b4: ldc.i4.1
  2040. IL_02b5: ldc.i4.2
  2041. IL_02b6: callvirt ""void System.Collections.Generic.IDictionary<int, int>.Add(int, int)""
  2042. IL_02bb: dup
  2043. IL_02bc: ldc.i4.2
  2044. IL_02bd: ldc.i4.3
  2045. IL_02be: callvirt ""void System.Collections.Generic.IDictionary<int, int>.Add(int, int)""
  2046. IL_02c3: dup
  2047. IL_02c4: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  2048. IL_02c9: dup
  2049. IL_02ca: callvirt ""void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Clear()""
  2050. IL_02cf: dup
  2051. IL_02d0: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  2052. IL_02d5: ldc.i4.s 23
  2053. IL_02d7: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2054. IL_02dc: pop
  2055. IL_02dd: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Count.get""
  2056. IL_02e2: box ""int""
  2057. IL_02e7: ldc.i4.0
  2058. IL_02e8: box ""int""
  2059. IL_02ed: call ""bool AllMembers.ValidateValue(object, object)""
  2060. IL_02f2: pop
  2061. IL_02f3: ret
  2062. }");
  2063. verifier.VerifyIL("AllMembers.TestIMapIntStructMembers",
  2064. @"
  2065. {
  2066. // Code size 790 (0x316)
  2067. .maxstack 5
  2068. .locals init (Windows.Languages.WinRTTest.UserDefinedStruct V_0, //ud
  2069. Windows.Languages.WinRTTest.UserDefinedStruct V_1, //val
  2070. Windows.Languages.WinRTTest.UserDefinedStruct V_2, //outVal
  2071. bool V_3, //success
  2072. bool V_4, //contains
  2073. bool V_5, //remove
  2074. int V_6, //count
  2075. bool V_7, //isReadOnly
  2076. bool V_8, //rez
  2077. Windows.Languages.WinRTTest.UserDefinedStruct V_9)
  2078. IL_0000: ldstr ""=== IMapIntStruct ===""
  2079. IL_0005: call ""void System.Console.WriteLine(string)""
  2080. IL_000a: newobj ""Windows.Languages.WinRTTest.IMapIntStruct..ctor()""
  2081. IL_000f: ldloca.s V_9
  2082. IL_0011: initobj ""Windows.Languages.WinRTTest.UserDefinedStruct""
  2083. IL_0017: ldloca.s V_9
  2084. IL_0019: ldc.i4.s 10
  2085. IL_001b: stfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  2086. IL_0020: ldloc.s V_9
  2087. IL_0022: stloc.0
  2088. IL_0023: dup
  2089. IL_0024: callvirt ""void Windows.Languages.WinRTTest.IMapIntStruct.ClearFlag()""
  2090. IL_0029: dup
  2091. IL_002a: ldc.i4.1
  2092. IL_002b: ldloc.0
  2093. IL_002c: callvirt ""void System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Add(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  2094. IL_0031: dup
  2095. IL_0032: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntStruct.GetFlagState()""
  2096. IL_0037: ldc.i4.s 21
  2097. IL_0039: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2098. IL_003e: pop
  2099. IL_003f: dup
  2100. IL_0040: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  2101. IL_0045: box ""int""
  2102. IL_004a: ldc.i4.1
  2103. IL_004b: box ""int""
  2104. IL_0050: call ""bool AllMembers.ValidateValue(object, object)""
  2105. IL_0055: pop
  2106. IL_0056: dup
  2107. IL_0057: callvirt ""void Windows.Languages.WinRTTest.IMapIntStruct.ClearFlag()""
  2108. IL_005c: dup
  2109. IL_005d: ldc.i4.1
  2110. IL_005e: callvirt ""bool System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.ContainsKey(int)""
  2111. IL_0063: pop
  2112. IL_0064: dup
  2113. IL_0065: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntStruct.GetFlagState()""
  2114. IL_006a: ldc.i4.s 19
  2115. IL_006c: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2116. IL_0071: pop
  2117. IL_0072: dup
  2118. IL_0073: callvirt ""void Windows.Languages.WinRTTest.IMapIntStruct.ClearFlag()""
  2119. IL_0078: dup
  2120. IL_0079: ldc.i4.1
  2121. IL_007a: callvirt ""Windows.Languages.WinRTTest.UserDefinedStruct System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.this[int].get""
  2122. IL_007f: stloc.1
  2123. IL_0080: dup
  2124. IL_0081: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntStruct.GetFlagState()""
  2125. IL_0086: ldc.i4.s 17
  2126. IL_0088: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2127. IL_008d: pop
  2128. IL_008e: ldloc.1
  2129. IL_008f: ldfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  2130. IL_0094: box ""uint""
  2131. IL_0099: ldc.i4.s 10
  2132. IL_009b: box ""int""
  2133. IL_00a0: call ""bool AllMembers.ValidateValue(object, object)""
  2134. IL_00a5: pop
  2135. IL_00a6: dup
  2136. IL_00a7: callvirt ""void Windows.Languages.WinRTTest.IMapIntStruct.ClearFlag()""
  2137. IL_00ac: dup
  2138. IL_00ad: callvirt ""System.Collections.Generic.ICollection<int> System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Keys.get""
  2139. IL_00b2: pop
  2140. IL_00b3: dup
  2141. IL_00b4: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntStruct.GetFlagState()""
  2142. IL_00b9: ldc.i4.0
  2143. IL_00ba: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2144. IL_00bf: pop
  2145. IL_00c0: dup
  2146. IL_00c1: callvirt ""void Windows.Languages.WinRTTest.IMapIntStruct.ClearFlag()""
  2147. IL_00c6: dup
  2148. IL_00c7: callvirt ""System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct> System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Values.get""
  2149. IL_00cc: pop
  2150. IL_00cd: dup
  2151. IL_00ce: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntStruct.GetFlagState()""
  2152. IL_00d3: ldc.i4.0
  2153. IL_00d4: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2154. IL_00d9: pop
  2155. IL_00da: dup
  2156. IL_00db: callvirt ""void Windows.Languages.WinRTTest.IMapIntStruct.ClearFlag()""
  2157. IL_00e0: dup
  2158. IL_00e1: ldc.i4.1
  2159. IL_00e2: ldloca.s V_2
  2160. IL_00e4: callvirt ""bool System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.TryGetValue(int, out Windows.Languages.WinRTTest.UserDefinedStruct)""
  2161. IL_00e9: stloc.3
  2162. IL_00ea: dup
  2163. IL_00eb: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntStruct.GetFlagState()""
  2164. IL_00f0: ldc.i4.s 17
  2165. IL_00f2: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2166. IL_00f7: pop
  2167. IL_00f8: ldloc.2
  2168. IL_00f9: ldfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  2169. IL_00fe: box ""uint""
  2170. IL_0103: ldloc.0
  2171. IL_0104: ldfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  2172. IL_0109: box ""uint""
  2173. IL_010e: call ""bool AllMembers.ValidateValue(object, object)""
  2174. IL_0113: pop
  2175. IL_0114: ldloc.3
  2176. IL_0115: box ""bool""
  2177. IL_011a: ldc.i4.1
  2178. IL_011b: box ""bool""
  2179. IL_0120: call ""bool AllMembers.ValidateValue(object, object)""
  2180. IL_0125: pop
  2181. IL_0126: dup
  2182. IL_0127: callvirt ""void Windows.Languages.WinRTTest.IMapIntStruct.ClearFlag()""
  2183. IL_012c: dup
  2184. IL_012d: ldc.i4.3
  2185. IL_012e: ldloca.s V_9
  2186. IL_0130: initobj ""Windows.Languages.WinRTTest.UserDefinedStruct""
  2187. IL_0136: ldloca.s V_9
  2188. IL_0138: ldc.i4.4
  2189. IL_0139: stfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  2190. IL_013e: ldloc.s V_9
  2191. IL_0140: newobj ""System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>..ctor(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  2192. IL_0145: callvirt ""void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Add(System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>)""
  2193. IL_014a: dup
  2194. IL_014b: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntStruct.GetFlagState()""
  2195. IL_0150: ldc.i4.s 21
  2196. IL_0152: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2197. IL_0157: pop
  2198. IL_0158: dup
  2199. IL_0159: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  2200. IL_015e: box ""int""
  2201. IL_0163: ldc.i4.2
  2202. IL_0164: box ""int""
  2203. IL_0169: call ""bool AllMembers.ValidateValue(object, object)""
  2204. IL_016e: pop
  2205. IL_016f: dup
  2206. IL_0170: callvirt ""void Windows.Languages.WinRTTest.IMapIntStruct.ClearFlag()""
  2207. IL_0175: dup
  2208. IL_0176: ldc.i4.1
  2209. IL_0177: ldloc.0
  2210. IL_0178: newobj ""System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>..ctor(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  2211. IL_017d: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Contains(System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>)""
  2212. IL_0182: stloc.s V_4
  2213. IL_0184: dup
  2214. IL_0185: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntStruct.GetFlagState()""
  2215. IL_018a: ldc.i4.s 17
  2216. IL_018c: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2217. IL_0191: pop
  2218. IL_0192: ldloc.s V_4
  2219. IL_0194: box ""bool""
  2220. IL_0199: ldc.i4.1
  2221. IL_019a: box ""bool""
  2222. IL_019f: call ""bool AllMembers.ValidateValue(object, object)""
  2223. IL_01a4: pop
  2224. IL_01a5: dup
  2225. IL_01a6: callvirt ""void Windows.Languages.WinRTTest.IMapIntStruct.ClearFlag()""
  2226. IL_01ab: dup
  2227. IL_01ac: ldc.i4.8
  2228. IL_01ad: ldloca.s V_9
  2229. IL_01af: initobj ""Windows.Languages.WinRTTest.UserDefinedStruct""
  2230. IL_01b5: ldloc.s V_9
  2231. IL_01b7: newobj ""System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>..ctor(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  2232. IL_01bc: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Contains(System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>)""
  2233. IL_01c1: stloc.s V_4
  2234. IL_01c3: dup
  2235. IL_01c4: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntStruct.GetFlagState()""
  2236. IL_01c9: ldc.i4.s 19
  2237. IL_01cb: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2238. IL_01d0: pop
  2239. IL_01d1: ldloc.s V_4
  2240. IL_01d3: box ""bool""
  2241. IL_01d8: ldc.i4.0
  2242. IL_01d9: box ""bool""
  2243. IL_01de: call ""bool AllMembers.ValidateValue(object, object)""
  2244. IL_01e3: pop
  2245. IL_01e4: dup
  2246. IL_01e5: callvirt ""void Windows.Languages.WinRTTest.IMapIntStruct.ClearFlag()""
  2247. IL_01ea: dup
  2248. IL_01eb: ldc.i4.3
  2249. IL_01ec: callvirt ""bool System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Remove(int)""
  2250. IL_01f1: stloc.s V_5
  2251. IL_01f3: dup
  2252. IL_01f4: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntStruct.GetFlagState()""
  2253. IL_01f9: ldc.i4.s 22
  2254. IL_01fb: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2255. IL_0200: pop
  2256. IL_0201: dup
  2257. IL_0202: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  2258. IL_0207: box ""int""
  2259. IL_020c: ldc.i4.1
  2260. IL_020d: box ""int""
  2261. IL_0212: call ""bool AllMembers.ValidateValue(object, object)""
  2262. IL_0217: pop
  2263. IL_0218: ldloc.s V_5
  2264. IL_021a: box ""bool""
  2265. IL_021f: ldc.i4.1
  2266. IL_0220: box ""bool""
  2267. IL_0225: call ""bool AllMembers.ValidateValue(object, object)""
  2268. IL_022a: pop
  2269. IL_022b: dup
  2270. IL_022c: callvirt ""void Windows.Languages.WinRTTest.IMapIntStruct.ClearFlag()""
  2271. IL_0231: dup
  2272. IL_0232: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  2273. IL_0237: stloc.s V_6
  2274. IL_0239: dup
  2275. IL_023a: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntStruct.GetFlagState()""
  2276. IL_023f: ldc.i4.s 18
  2277. IL_0241: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2278. IL_0246: pop
  2279. IL_0247: ldloc.s V_6
  2280. IL_0249: box ""int""
  2281. IL_024e: ldc.i4.1
  2282. IL_024f: box ""int""
  2283. IL_0254: call ""bool AllMembers.ValidateValue(object, object)""
  2284. IL_0259: pop
  2285. IL_025a: dup
  2286. IL_025b: callvirt ""void Windows.Languages.WinRTTest.IMapIntStruct.ClearFlag()""
  2287. IL_0260: dup
  2288. IL_0261: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.IsReadOnly.get""
  2289. IL_0266: stloc.s V_7
  2290. IL_0268: dup
  2291. IL_0269: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntStruct.GetFlagState()""
  2292. IL_026e: ldc.i4.0
  2293. IL_026f: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2294. IL_0274: pop
  2295. IL_0275: ldloc.s V_7
  2296. IL_0277: box ""bool""
  2297. IL_027c: ldc.i4.0
  2298. IL_027d: box ""bool""
  2299. IL_0282: call ""bool AllMembers.ValidateValue(object, object)""
  2300. IL_0287: pop
  2301. IL_0288: dup
  2302. IL_0289: callvirt ""void Windows.Languages.WinRTTest.IMapIntStruct.ClearFlag()""
  2303. IL_028e: dup
  2304. IL_028f: ldc.i4.1
  2305. IL_0290: ldloc.0
  2306. IL_0291: newobj ""System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>..ctor(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  2307. IL_0296: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Remove(System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>)""
  2308. IL_029b: stloc.s V_8
  2309. IL_029d: dup
  2310. IL_029e: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntStruct.GetFlagState()""
  2311. IL_02a3: ldc.i4.s 22
  2312. IL_02a5: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2313. IL_02aa: pop
  2314. IL_02ab: ldloc.s V_8
  2315. IL_02ad: box ""bool""
  2316. IL_02b2: ldc.i4.1
  2317. IL_02b3: box ""bool""
  2318. IL_02b8: call ""bool AllMembers.ValidateValue(object, object)""
  2319. IL_02bd: pop
  2320. IL_02be: dup
  2321. IL_02bf: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  2322. IL_02c4: box ""int""
  2323. IL_02c9: ldc.i4.0
  2324. IL_02ca: box ""int""
  2325. IL_02cf: call ""bool AllMembers.ValidateValue(object, object)""
  2326. IL_02d4: pop
  2327. IL_02d5: dup
  2328. IL_02d6: ldc.i4.1
  2329. IL_02d7: ldloc.0
  2330. IL_02d8: callvirt ""void System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Add(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  2331. IL_02dd: dup
  2332. IL_02de: ldc.i4.2
  2333. IL_02df: ldloc.0
  2334. IL_02e0: callvirt ""void System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Add(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  2335. IL_02e5: dup
  2336. IL_02e6: callvirt ""void Windows.Languages.WinRTTest.IMapIntStruct.ClearFlag()""
  2337. IL_02eb: dup
  2338. IL_02ec: callvirt ""void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Clear()""
  2339. IL_02f1: dup
  2340. IL_02f2: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntStruct.GetFlagState()""
  2341. IL_02f7: ldc.i4.s 23
  2342. IL_02f9: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2343. IL_02fe: pop
  2344. IL_02ff: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  2345. IL_0304: box ""int""
  2346. IL_0309: ldc.i4.0
  2347. IL_030a: box ""int""
  2348. IL_030f: call ""bool AllMembers.ValidateValue(object, object)""
  2349. IL_0314: pop
  2350. IL_0315: ret
  2351. }
  2352. ");
  2353. verifier.VerifyIL("AllMembers.TestIMapExplicitAddMembers",
  2354. @"{
  2355. // Code size 112 (0x70)
  2356. .maxstack 4
  2357. IL_0000: newobj ""Windows.Languages.WinRTTest.IMapExplicitAdd..ctor()""
  2358. IL_0005: dup
  2359. IL_0006: callvirt ""void Windows.Languages.WinRTTest.IMapExplicitAdd.ClearFlag()""
  2360. IL_000b: dup
  2361. IL_000c: ldc.i4.1
  2362. IL_000d: ldc.i4.1
  2363. IL_000e: callvirt ""void Windows.Languages.WinRTTest.IMemberAdd2Args.Add(int, int)""
  2364. IL_0013: dup
  2365. IL_0014: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapExplicitAdd.GetFlagState()""
  2366. IL_0019: ldc.i4.s 25
  2367. IL_001b: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2368. IL_0020: pop
  2369. IL_0021: dup
  2370. IL_0022: callvirt ""void Windows.Languages.WinRTTest.IMapExplicitAdd.ClearFlag()""
  2371. IL_0027: dup
  2372. IL_0028: ldc.i4.2
  2373. IL_0029: ldc.i4.2
  2374. IL_002a: callvirt ""void Windows.Languages.WinRTTest.IMemberAdd2Args.Add(int, int)""
  2375. IL_002f: dup
  2376. IL_0030: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapExplicitAdd.GetFlagState()""
  2377. IL_0035: ldc.i4.s 25
  2378. IL_0037: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2379. IL_003c: pop
  2380. IL_003d: dup
  2381. IL_003e: callvirt ""void Windows.Languages.WinRTTest.IMapExplicitAdd.ClearFlag()""
  2382. IL_0043: dup
  2383. IL_0044: ldc.i4.3
  2384. IL_0045: ldc.i4.3
  2385. IL_0046: callvirt ""void System.Collections.Generic.IDictionary<int, int>.Add(int, int)""
  2386. IL_004b: dup
  2387. IL_004c: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapExplicitAdd.GetFlagState()""
  2388. IL_0051: ldc.i4.s 21
  2389. IL_0053: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2390. IL_0058: pop
  2391. IL_0059: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Count.get""
  2392. IL_005e: box ""int""
  2393. IL_0063: ldc.i4.3
  2394. IL_0064: box ""int""
  2395. IL_0069: call ""bool AllMembers.ValidateValue(object, object)""
  2396. IL_006e: pop
  2397. IL_006f: ret
  2398. }");
  2399. verifier.VerifyIL("AllMembers.TestIMapViewMembers",
  2400. @"{
  2401. // Code size 32 (0x20)
  2402. .maxstack 2
  2403. IL_0000: newobj ""Windows.Languages.WinRTTest.IMapViewIntInt..ctor()""
  2404. IL_0005: dup
  2405. IL_0006: callvirt ""void Windows.Languages.WinRTTest.IMapViewIntInt.ClearFlag()""
  2406. IL_000b: dup
  2407. IL_000c: callvirt ""int System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<int, int>>.Count.get""
  2408. IL_0011: pop
  2409. IL_0012: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapViewIntInt.GetFlagState()""
  2410. IL_0017: ldc.i4.s 18
  2411. IL_0019: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2412. IL_001e: pop
  2413. IL_001f: ret
  2414. }");
  2415. verifier.VerifyIL("AllMembers.TestIMapIntIMapViewIntStructMembers",
  2416. @"
  2417. {
  2418. // Code size 790 (0x316)
  2419. .maxstack 5
  2420. .locals init (Windows.Languages.WinRTTest.UserDefinedStruct V_0, //ud
  2421. Windows.Languages.WinRTTest.UserDefinedStruct V_1, //val
  2422. Windows.Languages.WinRTTest.UserDefinedStruct V_2, //outVal
  2423. bool V_3, //success
  2424. bool V_4, //contains
  2425. bool V_5, //remove
  2426. int V_6, //count
  2427. bool V_7, //isReadOnly
  2428. bool V_8, //rez
  2429. Windows.Languages.WinRTTest.UserDefinedStruct V_9)
  2430. IL_0000: ldstr ""=== IMapIMapViewIntStruct ===""
  2431. IL_0005: call ""void System.Console.WriteLine(string)""
  2432. IL_000a: newobj ""Windows.Languages.WinRTTest.IMapIMapViewIntStruct..ctor()""
  2433. IL_000f: ldloca.s V_9
  2434. IL_0011: initobj ""Windows.Languages.WinRTTest.UserDefinedStruct""
  2435. IL_0017: ldloca.s V_9
  2436. IL_0019: ldc.i4.s 10
  2437. IL_001b: stfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  2438. IL_0020: ldloc.s V_9
  2439. IL_0022: stloc.0
  2440. IL_0023: dup
  2441. IL_0024: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2442. IL_0029: dup
  2443. IL_002a: ldc.i4.1
  2444. IL_002b: ldloc.0
  2445. IL_002c: callvirt ""void System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Add(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  2446. IL_0031: dup
  2447. IL_0032: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2448. IL_0037: ldc.i4.s 21
  2449. IL_0039: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2450. IL_003e: pop
  2451. IL_003f: dup
  2452. IL_0040: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  2453. IL_0045: box ""int""
  2454. IL_004a: ldc.i4.1
  2455. IL_004b: box ""int""
  2456. IL_0050: call ""bool AllMembers.ValidateValue(object, object)""
  2457. IL_0055: pop
  2458. IL_0056: dup
  2459. IL_0057: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2460. IL_005c: dup
  2461. IL_005d: ldc.i4.1
  2462. IL_005e: callvirt ""bool System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.ContainsKey(int)""
  2463. IL_0063: pop
  2464. IL_0064: dup
  2465. IL_0065: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2466. IL_006a: ldc.i4.s 19
  2467. IL_006c: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2468. IL_0071: pop
  2469. IL_0072: dup
  2470. IL_0073: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2471. IL_0078: dup
  2472. IL_0079: ldc.i4.1
  2473. IL_007a: callvirt ""Windows.Languages.WinRTTest.UserDefinedStruct System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.this[int].get""
  2474. IL_007f: stloc.1
  2475. IL_0080: dup
  2476. IL_0081: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2477. IL_0086: ldc.i4.s 17
  2478. IL_0088: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2479. IL_008d: pop
  2480. IL_008e: ldloc.1
  2481. IL_008f: ldfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  2482. IL_0094: box ""uint""
  2483. IL_0099: ldc.i4.s 10
  2484. IL_009b: box ""int""
  2485. IL_00a0: call ""bool AllMembers.ValidateValue(object, object)""
  2486. IL_00a5: pop
  2487. IL_00a6: dup
  2488. IL_00a7: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2489. IL_00ac: dup
  2490. IL_00ad: callvirt ""System.Collections.Generic.ICollection<int> System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Keys.get""
  2491. IL_00b2: pop
  2492. IL_00b3: dup
  2493. IL_00b4: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2494. IL_00b9: ldc.i4.0
  2495. IL_00ba: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2496. IL_00bf: pop
  2497. IL_00c0: dup
  2498. IL_00c1: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2499. IL_00c6: dup
  2500. IL_00c7: callvirt ""System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct> System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Values.get""
  2501. IL_00cc: pop
  2502. IL_00cd: dup
  2503. IL_00ce: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2504. IL_00d3: ldc.i4.0
  2505. IL_00d4: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2506. IL_00d9: pop
  2507. IL_00da: dup
  2508. IL_00db: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2509. IL_00e0: dup
  2510. IL_00e1: ldc.i4.1
  2511. IL_00e2: ldloca.s V_2
  2512. IL_00e4: callvirt ""bool System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.TryGetValue(int, out Windows.Languages.WinRTTest.UserDefinedStruct)""
  2513. IL_00e9: stloc.3
  2514. IL_00ea: dup
  2515. IL_00eb: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2516. IL_00f0: ldc.i4.s 17
  2517. IL_00f2: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2518. IL_00f7: pop
  2519. IL_00f8: ldloc.3
  2520. IL_00f9: box ""bool""
  2521. IL_00fe: ldc.i4.1
  2522. IL_00ff: box ""bool""
  2523. IL_0104: call ""bool AllMembers.ValidateValue(object, object)""
  2524. IL_0109: pop
  2525. IL_010a: dup
  2526. IL_010b: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2527. IL_0110: dup
  2528. IL_0111: ldc.i4.3
  2529. IL_0112: ldloca.s V_9
  2530. IL_0114: initobj ""Windows.Languages.WinRTTest.UserDefinedStruct""
  2531. IL_011a: ldloca.s V_9
  2532. IL_011c: ldc.i4.4
  2533. IL_011d: stfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  2534. IL_0122: ldloc.s V_9
  2535. IL_0124: newobj ""System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>..ctor(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  2536. IL_0129: callvirt ""void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Add(System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>)""
  2537. IL_012e: dup
  2538. IL_012f: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2539. IL_0134: ldc.i4.s 21
  2540. IL_0136: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2541. IL_013b: pop
  2542. IL_013c: dup
  2543. IL_013d: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  2544. IL_0142: box ""int""
  2545. IL_0147: ldc.i4.2
  2546. IL_0148: box ""int""
  2547. IL_014d: call ""bool AllMembers.ValidateValue(object, object)""
  2548. IL_0152: pop
  2549. IL_0153: dup
  2550. IL_0154: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2551. IL_0159: dup
  2552. IL_015a: ldc.i4.1
  2553. IL_015b: ldloc.0
  2554. IL_015c: newobj ""System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>..ctor(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  2555. IL_0161: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Contains(System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>)""
  2556. IL_0166: stloc.s V_4
  2557. IL_0168: dup
  2558. IL_0169: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2559. IL_016e: ldc.i4.s 17
  2560. IL_0170: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2561. IL_0175: pop
  2562. IL_0176: ldloc.s V_4
  2563. IL_0178: box ""bool""
  2564. IL_017d: ldc.i4.1
  2565. IL_017e: box ""bool""
  2566. IL_0183: call ""bool AllMembers.ValidateValue(object, object)""
  2567. IL_0188: pop
  2568. IL_0189: dup
  2569. IL_018a: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2570. IL_018f: dup
  2571. IL_0190: ldc.i4.8
  2572. IL_0191: ldloca.s V_9
  2573. IL_0193: initobj ""Windows.Languages.WinRTTest.UserDefinedStruct""
  2574. IL_0199: ldloc.s V_9
  2575. IL_019b: newobj ""System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>..ctor(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  2576. IL_01a0: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Contains(System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>)""
  2577. IL_01a5: stloc.s V_4
  2578. IL_01a7: dup
  2579. IL_01a8: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2580. IL_01ad: ldc.i4.s 19
  2581. IL_01af: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2582. IL_01b4: pop
  2583. IL_01b5: ldloc.s V_4
  2584. IL_01b7: box ""bool""
  2585. IL_01bc: ldc.i4.0
  2586. IL_01bd: box ""bool""
  2587. IL_01c2: call ""bool AllMembers.ValidateValue(object, object)""
  2588. IL_01c7: pop
  2589. IL_01c8: dup
  2590. IL_01c9: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2591. IL_01ce: dup
  2592. IL_01cf: ldc.i4.3
  2593. IL_01d0: callvirt ""bool System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Remove(int)""
  2594. IL_01d5: stloc.s V_5
  2595. IL_01d7: dup
  2596. IL_01d8: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2597. IL_01dd: ldc.i4.s 22
  2598. IL_01df: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2599. IL_01e4: pop
  2600. IL_01e5: dup
  2601. IL_01e6: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  2602. IL_01eb: box ""int""
  2603. IL_01f0: ldc.i4.1
  2604. IL_01f1: box ""int""
  2605. IL_01f6: call ""bool AllMembers.ValidateValue(object, object)""
  2606. IL_01fb: pop
  2607. IL_01fc: ldloc.s V_5
  2608. IL_01fe: box ""bool""
  2609. IL_0203: ldc.i4.1
  2610. IL_0204: box ""bool""
  2611. IL_0209: call ""bool AllMembers.ValidateValue(object, object)""
  2612. IL_020e: pop
  2613. IL_020f: dup
  2614. IL_0210: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2615. IL_0215: dup
  2616. IL_0216: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  2617. IL_021b: stloc.s V_6
  2618. IL_021d: dup
  2619. IL_021e: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2620. IL_0223: ldc.i4.s 18
  2621. IL_0225: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2622. IL_022a: pop
  2623. IL_022b: ldloc.s V_6
  2624. IL_022d: box ""int""
  2625. IL_0232: ldc.i4.1
  2626. IL_0233: box ""int""
  2627. IL_0238: call ""bool AllMembers.ValidateValue(object, object)""
  2628. IL_023d: pop
  2629. IL_023e: dup
  2630. IL_023f: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2631. IL_0244: dup
  2632. IL_0245: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.IsReadOnly.get""
  2633. IL_024a: stloc.s V_7
  2634. IL_024c: dup
  2635. IL_024d: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2636. IL_0252: ldc.i4.0
  2637. IL_0253: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2638. IL_0258: pop
  2639. IL_0259: ldloc.s V_7
  2640. IL_025b: box ""bool""
  2641. IL_0260: ldc.i4.0
  2642. IL_0261: box ""bool""
  2643. IL_0266: call ""bool AllMembers.ValidateValue(object, object)""
  2644. IL_026b: pop
  2645. IL_026c: dup
  2646. IL_026d: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2647. IL_0272: dup
  2648. IL_0273: ldc.i4.1
  2649. IL_0274: ldloc.0
  2650. IL_0275: newobj ""System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>..ctor(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  2651. IL_027a: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Remove(System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>)""
  2652. IL_027f: stloc.s V_8
  2653. IL_0281: dup
  2654. IL_0282: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2655. IL_0287: ldc.i4.s 22
  2656. IL_0289: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2657. IL_028e: pop
  2658. IL_028f: ldloc.s V_8
  2659. IL_0291: box ""bool""
  2660. IL_0296: ldc.i4.1
  2661. IL_0297: box ""bool""
  2662. IL_029c: call ""bool AllMembers.ValidateValue(object, object)""
  2663. IL_02a1: pop
  2664. IL_02a2: dup
  2665. IL_02a3: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  2666. IL_02a8: box ""int""
  2667. IL_02ad: ldc.i4.0
  2668. IL_02ae: box ""int""
  2669. IL_02b3: call ""bool AllMembers.ValidateValue(object, object)""
  2670. IL_02b8: pop
  2671. IL_02b9: dup
  2672. IL_02ba: ldc.i4.1
  2673. IL_02bb: ldloc.0
  2674. IL_02bc: callvirt ""void System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Add(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  2675. IL_02c1: dup
  2676. IL_02c2: ldc.i4.2
  2677. IL_02c3: ldloc.0
  2678. IL_02c4: callvirt ""void System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Add(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  2679. IL_02c9: dup
  2680. IL_02ca: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2681. IL_02cf: dup
  2682. IL_02d0: callvirt ""void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Clear()""
  2683. IL_02d5: dup
  2684. IL_02d6: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2685. IL_02db: ldc.i4.s 23
  2686. IL_02dd: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2687. IL_02e2: pop
  2688. IL_02e3: dup
  2689. IL_02e4: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  2690. IL_02e9: box ""int""
  2691. IL_02ee: ldc.i4.0
  2692. IL_02ef: box ""int""
  2693. IL_02f4: call ""bool AllMembers.ValidateValue(object, object)""
  2694. IL_02f9: pop
  2695. IL_02fa: dup
  2696. IL_02fb: callvirt ""void Windows.Languages.WinRTTest.IMapIMapViewIntStruct.ClearFlag()""
  2697. IL_0300: dup
  2698. IL_0301: callvirt ""int System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  2699. IL_0306: stloc.s V_6
  2700. IL_0308: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIMapViewIntStruct.GetFlagState()""
  2701. IL_030d: ldc.i4.s 18
  2702. IL_030f: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  2703. IL_0314: pop
  2704. IL_0315: ret
  2705. }
  2706. ");
  2707. }
  2708. [Fact]
  2709. public void LegacyCollectionTest04()
  2710. {
  2711. var source =
  2712. @"using Windows.Languages.WinRTTest;
  2713. using System.Collections.Generic;
  2714. using System.Reflection;
  2715. using System.Linq.Expressions;
  2716. using System;
  2717. using System.Linq;
  2718. class AllMembers
  2719. {
  2720. private static int FailedCount = 0;
  2721. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  2722. {
  2723. var temp = Console.ForegroundColor;
  2724. if (actual != expected)
  2725. {
  2726. FailedCount++;
  2727. Console.ForegroundColor = ConsoleColor.Red;
  2728. Console.Write(""FAIL: "");
  2729. }
  2730. else
  2731. {
  2732. Console.ForegroundColor = ConsoleColor.Green;
  2733. Console.Write(""PASS: "");
  2734. }
  2735. Console.ForegroundColor = temp;
  2736. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  2737. return actual == expected;
  2738. }
  2739. private static bool ValidateValue(object actual, object expected)
  2740. {
  2741. var temp = Console.ForegroundColor;
  2742. if (actual.ToString() != expected.ToString())
  2743. {
  2744. FailedCount++;
  2745. Console.ForegroundColor = ConsoleColor.Red;
  2746. Console.Write(""FAIL: "");
  2747. }
  2748. else
  2749. {
  2750. Console.ForegroundColor = ConsoleColor.Green;
  2751. Console.Write(""PASS: "");
  2752. }
  2753. Console.ForegroundColor = temp;
  2754. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  2755. return actual.ToString() == expected.ToString();
  2756. }
  2757. static void TestIVectorIntIVectorViewIntIMapIntIntIMapViewIntIntMembers()
  2758. {
  2759. var v = new IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt();
  2760. //Add
  2761. v.ClearFlag();
  2762. v.Add(1);
  2763. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  2764. ValidateValue((v as IList<int>)[0], 1);
  2765. //Contains
  2766. v.ClearFlag();
  2767. bool b = v.Contains(1);
  2768. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  2769. ValidateValue(b, true);
  2770. //CopyTo
  2771. v.ClearFlag();
  2772. int[] arr = new int[10];
  2773. v.CopyTo(arr, 0);
  2774. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  2775. ValidateValue(arr[0], 1);
  2776. ValidateValue(arr[1], 0); //there should be nothing there! :)
  2777. //GetEnumerator
  2778. v.ClearFlag();
  2779. int count = ((IList<int>)v).Count;
  2780. IEnumerator<int> enumerator = ((IList<int>)v).GetEnumerator();
  2781. ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First);
  2782. int index = 0;
  2783. foreach (var e in ((IList<int>)v))
  2784. {
  2785. index = index + 1;
  2786. ValidateValue(e, index);
  2787. }
  2788. ValidateValue(index, 1); //there should only be 1 element there
  2789. //IndexOf
  2790. v.ClearFlag();
  2791. var rez = v.IndexOf(1);
  2792. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  2793. ValidateValue(rez, 0); // 1 is on the first line :)
  2794. //Insert
  2795. v.ClearFlag();
  2796. v.Insert(1, 2);
  2797. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
  2798. ValidateValue((v as IList<int>)[1], 2);
  2799. //IsReadOnly
  2800. v.ClearFlag();
  2801. bool isReadOnly = ((IList<int>)v).IsReadOnly;
  2802. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  2803. ValidateValue(isReadOnly, false);
  2804. //Indexing
  2805. v.ClearFlag();
  2806. int val = ((int)(v as IList<int>)[0]);
  2807. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  2808. ValidateValue(val, 1);
  2809. v.ClearFlag();
  2810. val = ((IList<int>)v)[1];
  2811. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  2812. ValidateValue(val, 2);
  2813. //Remove
  2814. v.ClearFlag();
  2815. ((IList<int>)v).Remove(1);
  2816. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  2817. ValidateValue(((IList<int>)v).Count, 1);
  2818. //RemoveAt
  2819. v.ClearFlag();
  2820. v.RemoveAt(0);
  2821. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  2822. ValidateValue(((IList<int>)v).Count, 0);
  2823. //Clear
  2824. v.Add(1);
  2825. v.Add(2);
  2826. v.ClearFlag();
  2827. ((IList<int>)v).Clear();
  2828. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
  2829. ValidateValue(((IList<int>)v).Count, 0);
  2830. //IVectorView
  2831. v.ClearFlag();
  2832. count = ((IReadOnlyList<int>)v).Count;
  2833. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_get_Size);
  2834. var m = v;
  2835. //Add
  2836. m.ClearFlag();
  2837. m.Add(1, 2);
  2838. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
  2839. ValidateValue(((IDictionary<int, int>)m).Count, 1);
  2840. //ContainsKey
  2841. m.ClearFlag();
  2842. bool key = ((IDictionary<int, int>)m).ContainsKey(1);
  2843. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  2844. //Lookup
  2845. m.ClearFlag();
  2846. val = ((int)(m as IDictionary<int, int>)[1]);
  2847. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  2848. ValidateValue(val, 2);
  2849. //Keys
  2850. m.ClearFlag();
  2851. var keys = ((IDictionary<int, int>)m).Keys;
  2852. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  2853. //Values
  2854. m.ClearFlag();
  2855. var values = ((IDictionary<int, int>)m).Values;
  2856. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  2857. //Lookup
  2858. m.ClearFlag();
  2859. int outVal;
  2860. bool success = ((IDictionary<int, int>)m).TryGetValue(1, out outVal);
  2861. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  2862. ValidateValue(outVal, 2);
  2863. ValidateValue(success, true);
  2864. //Add
  2865. m.ClearFlag();
  2866. m.Add(new KeyValuePair<int, int>(3, 4));
  2867. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
  2868. ValidateValue(((IDictionary<int, int>)m).Count, 2);
  2869. //Contains
  2870. m.ClearFlag();
  2871. bool contains = m.Contains(new KeyValuePair<int, int>(3, 4));
  2872. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  2873. ValidateValue(contains, true);
  2874. //non-existant pair
  2875. m.ClearFlag();
  2876. contains = m.Contains(new KeyValuePair<int, int>(8, 9));
  2877. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  2878. ValidateValue(contains, false);
  2879. //Remove
  2880. m.ClearFlag();
  2881. bool remove = ((IDictionary<int, int>)m).Remove(1);
  2882. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Remove);
  2883. ValidateValue(((IDictionary<int, int>)m).Count, 1);
  2884. ValidateValue(remove, true);
  2885. //CopyTo
  2886. //m.ClearFlag()
  2887. //Dim arr As KeyValuePair(Of Integer, Integer)()
  2888. //ReDim arr(10)
  2889. //m.CopyTo(arr, 1)
  2890. //ValidateMethod(m.GetFlagState(), TestMethodCalled.IVector_GetAt)
  2891. //ValidateValue(arr[0].Value, 2)
  2892. //Count
  2893. m.ClearFlag();
  2894. count = ((IDictionary<int, int>)m).Count;
  2895. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_get_Size);
  2896. ValidateValue(count, 1);
  2897. //isReadOnly
  2898. m.ClearFlag();
  2899. isReadOnly = ((IDictionary<int, int>)m).IsReadOnly;
  2900. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  2901. ValidateValue(isReadOnly, false);
  2902. //Remove
  2903. m.ClearFlag();
  2904. var rez2 = m.Remove(new KeyValuePair<int, int>(3, 4));
  2905. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Remove);
  2906. ValidateValue(rez2, true);
  2907. m.ClearFlag();
  2908. rez2 = m.Remove(new KeyValuePair<int, int>(2, 3));
  2909. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  2910. ValidateValue(rez2, false);
  2911. m.Add(1, 2);
  2912. m.Add(2, 3);
  2913. m.ClearFlag();
  2914. ((IDictionary<int, int>)m).Clear();
  2915. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Clear);
  2916. ValidateValue(((IDictionary<int, int>)m).Count, 0);
  2917. //IMapView
  2918. m.ClearFlag();
  2919. count = ((IReadOnlyDictionary<int, int>)m).Count;
  2920. ValidateMethod(m.GetFlagState(), TestMethodCalled.IVector_get_Size);
  2921. }
  2922. static void TestIVectorStructIVectorViewStructIMapIntStructIMapViewIntStructMembers()
  2923. {
  2924. var v = new IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct();
  2925. var ud = new UserDefinedStruct()
  2926. {
  2927. Id = 1
  2928. }
  2929. ;
  2930. //Add
  2931. v.ClearFlag();
  2932. v.Add(ud);
  2933. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  2934. //Contains
  2935. v.ClearFlag();
  2936. bool b = v.Contains(ud);
  2937. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  2938. ValidateValue(b, true);
  2939. //CopyTo
  2940. v.ClearFlag();
  2941. UserDefinedStruct[] arr = new UserDefinedStruct[10];
  2942. v.CopyTo(arr, 0);
  2943. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  2944. ValidateValue(arr[0].Id, ud.Id);
  2945. //GetEnumerator
  2946. v.ClearFlag();
  2947. int count = ((IList<UserDefinedStruct>)v).Count;
  2948. IEnumerator<UserDefinedStruct> enumerator = ((IList<UserDefinedStruct>)v).GetEnumerator();
  2949. ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First);
  2950. enumerator.MoveNext();
  2951. ValidateValue((enumerator.Current).Id, 1);
  2952. int index = 0;
  2953. foreach (var e in ((IList<UserDefinedStruct>)v))
  2954. {
  2955. index = index + 1;
  2956. ValidateValue(e.Id, index);
  2957. }
  2958. ValidateValue(index, 1); //there should only be 1 element there
  2959. //IndexOf
  2960. v.ClearFlag();
  2961. var rez = v.IndexOf(ud);
  2962. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  2963. ValidateValue(rez, 0); // 1 is on the first line :)
  2964. //Insert
  2965. v.ClearFlag();
  2966. v.Insert(1, new UserDefinedStruct()
  2967. {
  2968. Id = 4
  2969. }
  2970. );
  2971. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
  2972. //IsReadOnly
  2973. v.ClearFlag();
  2974. bool isReadOnly = ((IList<UserDefinedStruct>)v).IsReadOnly;
  2975. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  2976. ValidateValue(isReadOnly, false);
  2977. //Indexing
  2978. v.ClearFlag();
  2979. var val = (v as IList<UserDefinedStruct>)[0];
  2980. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  2981. v.ClearFlag();
  2982. val = ((IList<UserDefinedStruct>)v)[1];
  2983. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  2984. //Remove
  2985. v.ClearFlag();
  2986. v.Remove(ud);
  2987. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  2988. ValidateValue(((IList<UserDefinedStruct>)v).Count, 1);
  2989. //RemoveAt
  2990. v.ClearFlag();
  2991. v.RemoveAt(0);
  2992. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  2993. ValidateValue(((IList<UserDefinedStruct>)v).Count, 0);
  2994. //Clear
  2995. v.Add(ud);
  2996. v.Add(new UserDefinedStruct()
  2997. {
  2998. Id = 4
  2999. }
  3000. );
  3001. v.ClearFlag();
  3002. ((IList<UserDefinedStruct>)v).Clear();
  3003. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
  3004. ValidateValue(((IList<UserDefinedStruct>)v).Count, 0);
  3005. //IVectorView
  3006. v.ClearFlag();
  3007. count = ((IReadOnlyList<UserDefinedStruct>)v).Count;
  3008. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_get_Size);
  3009. var m = v;
  3010. ud = new UserDefinedStruct()
  3011. {
  3012. Id = 10
  3013. }
  3014. ;
  3015. //Add
  3016. m.ClearFlag();
  3017. m.Add(1, ud);
  3018. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
  3019. ValidateValue(((IDictionary<int, UserDefinedStruct>)m).Count, 1);
  3020. //ContainsKey
  3021. m.ClearFlag();
  3022. bool key = ((IDictionary<int, UserDefinedStruct>)m).ContainsKey(1);
  3023. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  3024. //Lookup
  3025. m.ClearFlag();
  3026. val = ((IDictionary<int, UserDefinedStruct>)m)[1];
  3027. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  3028. //Keys
  3029. m.ClearFlag();
  3030. var keys = ((IDictionary<int, UserDefinedStruct>)m).Keys;
  3031. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  3032. //Values
  3033. m.ClearFlag();
  3034. var values = ((IDictionary<int, UserDefinedStruct>)m).Values;
  3035. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  3036. //Lookup
  3037. m.ClearFlag();
  3038. UserDefinedStruct outVal;
  3039. bool success = ((IDictionary<int, UserDefinedStruct>)m).TryGetValue(1, out outVal);
  3040. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  3041. ValidateValue(success, true);
  3042. //Add
  3043. m.ClearFlag();
  3044. m.Add(new KeyValuePair<int, UserDefinedStruct>(3, new UserDefinedStruct()
  3045. {
  3046. Id = 4
  3047. }
  3048. ));
  3049. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
  3050. ValidateValue(((IDictionary<int, UserDefinedStruct>)m).Count, 2);
  3051. //Contains
  3052. m.ClearFlag();
  3053. bool contains = m.Contains(new KeyValuePair<int, UserDefinedStruct>(1, ud));
  3054. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Lookup);
  3055. ValidateValue(contains, true);
  3056. //non-existant pair
  3057. m.ClearFlag();
  3058. contains = m.Contains(new KeyValuePair<int, UserDefinedStruct>(8, new UserDefinedStruct()));
  3059. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey);
  3060. ValidateValue(contains, false);
  3061. //Remove
  3062. m.ClearFlag();
  3063. //bool remove = m.Remove(3);
  3064. //ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Remove);
  3065. //ValidateValue(((IDictionary<int, UserDefinedStruct>)m).Count, 1);
  3066. //ValidateValue(remove, true);
  3067. //'CopyTo
  3068. //m.ClearFlag()
  3069. //Dim arr As KeyValuePair(Of Integer, UserDefinedStruct)()
  3070. //ReDim arr(10)
  3071. //m.CopyTo(arr, 1)
  3072. //ValidateMethod(m.GetFlagState(), TestMethodCalled.IVector_GetAt)
  3073. //Count
  3074. m.ClearFlag();
  3075. count = ((IDictionary<int, UserDefinedStruct>)m).Count;
  3076. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_get_Size);
  3077. ValidateValue(count, 1);
  3078. //isReadOnly
  3079. m.ClearFlag();
  3080. isReadOnly = ((IDictionary<int, UserDefinedStruct>)m).IsReadOnly;
  3081. ValidateMethod(m.GetFlagState(), TestMethodCalled.NotSet);
  3082. ValidateValue(isReadOnly, false);
  3083. //Remove
  3084. m.ClearFlag();
  3085. m.Remove(new KeyValuePair<int, UserDefinedStruct>(1, ud));
  3086. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Remove);
  3087. ValidateValue(((IDictionary<int, UserDefinedStruct>)m).Count, 0);
  3088. //m.ClearFlag()
  3089. //rez = m.Remove(New KeyValuePair(Of Integer, UserDefinedStruct)(3, ud))
  3090. //ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_HasKey)
  3091. //ValidateValue(rez, False)
  3092. //Clear
  3093. m.Add(1, ud);
  3094. m.Add(2, ud);
  3095. m.ClearFlag();
  3096. ((IDictionary<int, UserDefinedStruct>)m).Clear();
  3097. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Clear);
  3098. ValidateValue(((IDictionary<int, UserDefinedStruct>)m).Count, 0);
  3099. //ImapView
  3100. m.ClearFlag();
  3101. count = ((IDictionary<int, UserDefinedStruct>)m).Count;
  3102. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_get_Size);
  3103. }
  3104. static int Main()
  3105. {
  3106. TestIVectorIntIVectorViewIntIMapIntIntIMapViewIntIntMembers();
  3107. TestIVectorStructIVectorViewStructIMapIntStructIMapViewIntStructMembers();
  3108. Console.WriteLine(FailedCount);
  3109. return FailedCount;
  3110. }
  3111. }";
  3112. var verifier = CompileAndVerify(source,
  3113. emitOptions: EmitOptions.RefEmitBug,
  3114. additionalRefs: LegacyRefs,
  3115. verify: false);
  3116. verifier.VerifyDiagnostics(
  3117. // (3,1): info CS8019: Unnecessary using directive.
  3118. // using System.Reflection;
  3119. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  3120. // (4,1): info CS8019: Unnecessary using directive.
  3121. // using System.Linq.Expressions;
  3122. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  3123. // (6,1): info CS8019: Unnecessary using directive.
  3124. // using System.Linq;
  3125. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"));
  3126. verifier.VerifyIL("AllMembers.TestIVectorIntIVectorViewIntIMapIntIntIMapViewIntIntMembers",
  3127. @"{
  3128. // Code size 1497 (0x5d9)
  3129. .maxstack 4
  3130. .locals init (Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt V_0, //v
  3131. bool V_1, //b
  3132. int[] V_2, //arr
  3133. int V_3, //count
  3134. int V_4, //index
  3135. int V_5, //rez
  3136. bool V_6, //isReadOnly
  3137. int V_7, //val
  3138. int V_8, //outVal
  3139. bool V_9, //success
  3140. bool V_10, //contains
  3141. bool V_11, //remove
  3142. bool V_12, //rez2
  3143. System.Collections.Generic.IEnumerator<int> V_13)
  3144. IL_0000: newobj ""Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt..ctor()""
  3145. IL_0005: stloc.0
  3146. IL_0006: ldloc.0
  3147. IL_0007: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3148. IL_000c: ldloc.0
  3149. IL_000d: ldc.i4.1
  3150. IL_000e: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  3151. IL_0013: ldloc.0
  3152. IL_0014: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3153. IL_0019: ldc.i4.s 9
  3154. IL_001b: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3155. IL_0020: pop
  3156. IL_0021: ldloc.0
  3157. IL_0022: ldc.i4.0
  3158. IL_0023: callvirt ""int System.Collections.Generic.IList<int>.this[int].get""
  3159. IL_0028: box ""int""
  3160. IL_002d: ldc.i4.1
  3161. IL_002e: box ""int""
  3162. IL_0033: call ""bool AllMembers.ValidateValue(object, object)""
  3163. IL_0038: pop
  3164. IL_0039: ldloc.0
  3165. IL_003a: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3166. IL_003f: ldloc.0
  3167. IL_0040: ldc.i4.1
  3168. IL_0041: callvirt ""bool System.Collections.Generic.ICollection<int>.Contains(int)""
  3169. IL_0046: stloc.1
  3170. IL_0047: ldloc.0
  3171. IL_0048: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3172. IL_004d: ldc.i4.5
  3173. IL_004e: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3174. IL_0053: pop
  3175. IL_0054: ldloc.1
  3176. IL_0055: box ""bool""
  3177. IL_005a: ldc.i4.1
  3178. IL_005b: box ""bool""
  3179. IL_0060: call ""bool AllMembers.ValidateValue(object, object)""
  3180. IL_0065: pop
  3181. IL_0066: ldloc.0
  3182. IL_0067: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3183. IL_006c: ldc.i4.s 10
  3184. IL_006e: newarr ""int""
  3185. IL_0073: stloc.2
  3186. IL_0074: ldloc.0
  3187. IL_0075: ldloc.2
  3188. IL_0076: ldc.i4.0
  3189. IL_0077: callvirt ""void System.Collections.Generic.ICollection<int>.CopyTo(int[], int)""
  3190. IL_007c: ldloc.0
  3191. IL_007d: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3192. IL_0082: ldc.i4.2
  3193. IL_0083: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3194. IL_0088: pop
  3195. IL_0089: ldloc.2
  3196. IL_008a: ldc.i4.0
  3197. IL_008b: ldelem.i4
  3198. IL_008c: box ""int""
  3199. IL_0091: ldc.i4.1
  3200. IL_0092: box ""int""
  3201. IL_0097: call ""bool AllMembers.ValidateValue(object, object)""
  3202. IL_009c: pop
  3203. IL_009d: ldloc.2
  3204. IL_009e: ldc.i4.1
  3205. IL_009f: ldelem.i4
  3206. IL_00a0: box ""int""
  3207. IL_00a5: ldc.i4.0
  3208. IL_00a6: box ""int""
  3209. IL_00ab: call ""bool AllMembers.ValidateValue(object, object)""
  3210. IL_00b0: pop
  3211. IL_00b1: ldloc.0
  3212. IL_00b2: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3213. IL_00b7: ldloc.0
  3214. IL_00b8: callvirt ""int System.Collections.Generic.ICollection<int>.Count.get""
  3215. IL_00bd: stloc.3
  3216. IL_00be: ldloc.0
  3217. IL_00bf: callvirt ""System.Collections.Generic.IEnumerator<int> System.Collections.Generic.IEnumerable<int>.GetEnumerator()""
  3218. IL_00c4: pop
  3219. IL_00c5: ldloc.0
  3220. IL_00c6: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3221. IL_00cb: ldc.i4.1
  3222. IL_00cc: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3223. IL_00d1: pop
  3224. IL_00d2: ldc.i4.0
  3225. IL_00d3: stloc.s V_4
  3226. IL_00d5: ldloc.0
  3227. IL_00d6: callvirt ""System.Collections.Generic.IEnumerator<int> System.Collections.Generic.IEnumerable<int>.GetEnumerator()""
  3228. IL_00db: stloc.s V_13
  3229. .try
  3230. {
  3231. IL_00dd: br.s IL_00fe
  3232. IL_00df: ldloc.s V_13
  3233. IL_00e1: callvirt ""int System.Collections.Generic.IEnumerator<int>.Current.get""
  3234. IL_00e6: ldloc.s V_4
  3235. IL_00e8: ldc.i4.1
  3236. IL_00e9: add
  3237. IL_00ea: stloc.s V_4
  3238. IL_00ec: box ""int""
  3239. IL_00f1: ldloc.s V_4
  3240. IL_00f3: box ""int""
  3241. IL_00f8: call ""bool AllMembers.ValidateValue(object, object)""
  3242. IL_00fd: pop
  3243. IL_00fe: ldloc.s V_13
  3244. IL_0100: callvirt ""bool System.Collections.IEnumerator.MoveNext()""
  3245. IL_0105: brtrue.s IL_00df
  3246. IL_0107: leave.s IL_0115
  3247. }
  3248. finally
  3249. {
  3250. IL_0109: ldloc.s V_13
  3251. IL_010b: brfalse.s IL_0114
  3252. IL_010d: ldloc.s V_13
  3253. IL_010f: callvirt ""void System.IDisposable.Dispose()""
  3254. IL_0114: endfinally
  3255. }
  3256. IL_0115: ldloc.s V_4
  3257. IL_0117: box ""int""
  3258. IL_011c: ldc.i4.1
  3259. IL_011d: box ""int""
  3260. IL_0122: call ""bool AllMembers.ValidateValue(object, object)""
  3261. IL_0127: pop
  3262. IL_0128: ldloc.0
  3263. IL_0129: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3264. IL_012e: ldloc.0
  3265. IL_012f: ldc.i4.1
  3266. IL_0130: callvirt ""int System.Collections.Generic.IList<int>.IndexOf(int)""
  3267. IL_0135: stloc.s V_5
  3268. IL_0137: ldloc.0
  3269. IL_0138: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3270. IL_013d: ldc.i4.5
  3271. IL_013e: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3272. IL_0143: pop
  3273. IL_0144: ldloc.s V_5
  3274. IL_0146: box ""int""
  3275. IL_014b: ldc.i4.0
  3276. IL_014c: box ""int""
  3277. IL_0151: call ""bool AllMembers.ValidateValue(object, object)""
  3278. IL_0156: pop
  3279. IL_0157: ldloc.0
  3280. IL_0158: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3281. IL_015d: ldloc.0
  3282. IL_015e: ldc.i4.1
  3283. IL_015f: ldc.i4.2
  3284. IL_0160: callvirt ""void System.Collections.Generic.IList<int>.Insert(int, int)""
  3285. IL_0165: ldloc.0
  3286. IL_0166: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3287. IL_016b: ldc.i4.7
  3288. IL_016c: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3289. IL_0171: pop
  3290. IL_0172: ldloc.0
  3291. IL_0173: ldc.i4.1
  3292. IL_0174: callvirt ""int System.Collections.Generic.IList<int>.this[int].get""
  3293. IL_0179: box ""int""
  3294. IL_017e: ldc.i4.2
  3295. IL_017f: box ""int""
  3296. IL_0184: call ""bool AllMembers.ValidateValue(object, object)""
  3297. IL_0189: pop
  3298. IL_018a: ldloc.0
  3299. IL_018b: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3300. IL_0190: ldloc.0
  3301. IL_0191: callvirt ""bool System.Collections.Generic.ICollection<int>.IsReadOnly.get""
  3302. IL_0196: stloc.s V_6
  3303. IL_0198: ldloc.0
  3304. IL_0199: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3305. IL_019e: ldc.i4.0
  3306. IL_019f: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3307. IL_01a4: pop
  3308. IL_01a5: ldloc.s V_6
  3309. IL_01a7: box ""bool""
  3310. IL_01ac: ldc.i4.0
  3311. IL_01ad: box ""bool""
  3312. IL_01b2: call ""bool AllMembers.ValidateValue(object, object)""
  3313. IL_01b7: pop
  3314. IL_01b8: ldloc.0
  3315. IL_01b9: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3316. IL_01be: ldloc.0
  3317. IL_01bf: ldc.i4.0
  3318. IL_01c0: callvirt ""int System.Collections.Generic.IList<int>.this[int].get""
  3319. IL_01c5: stloc.s V_7
  3320. IL_01c7: ldloc.0
  3321. IL_01c8: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3322. IL_01cd: ldc.i4.2
  3323. IL_01ce: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3324. IL_01d3: pop
  3325. IL_01d4: ldloc.s V_7
  3326. IL_01d6: box ""int""
  3327. IL_01db: ldc.i4.1
  3328. IL_01dc: box ""int""
  3329. IL_01e1: call ""bool AllMembers.ValidateValue(object, object)""
  3330. IL_01e6: pop
  3331. IL_01e7: ldloc.0
  3332. IL_01e8: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3333. IL_01ed: ldloc.0
  3334. IL_01ee: ldc.i4.1
  3335. IL_01ef: callvirt ""int System.Collections.Generic.IList<int>.this[int].get""
  3336. IL_01f4: stloc.s V_7
  3337. IL_01f6: ldloc.0
  3338. IL_01f7: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3339. IL_01fc: ldc.i4.2
  3340. IL_01fd: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3341. IL_0202: pop
  3342. IL_0203: ldloc.s V_7
  3343. IL_0205: box ""int""
  3344. IL_020a: ldc.i4.2
  3345. IL_020b: box ""int""
  3346. IL_0210: call ""bool AllMembers.ValidateValue(object, object)""
  3347. IL_0215: pop
  3348. IL_0216: ldloc.0
  3349. IL_0217: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3350. IL_021c: ldloc.0
  3351. IL_021d: ldc.i4.1
  3352. IL_021e: callvirt ""bool System.Collections.Generic.ICollection<int>.Remove(int)""
  3353. IL_0223: pop
  3354. IL_0224: ldloc.0
  3355. IL_0225: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3356. IL_022a: ldc.i4.8
  3357. IL_022b: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3358. IL_0230: pop
  3359. IL_0231: ldloc.0
  3360. IL_0232: callvirt ""int System.Collections.Generic.ICollection<int>.Count.get""
  3361. IL_0237: box ""int""
  3362. IL_023c: ldc.i4.1
  3363. IL_023d: box ""int""
  3364. IL_0242: call ""bool AllMembers.ValidateValue(object, object)""
  3365. IL_0247: pop
  3366. IL_0248: ldloc.0
  3367. IL_0249: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3368. IL_024e: ldloc.0
  3369. IL_024f: ldc.i4.0
  3370. IL_0250: callvirt ""void System.Collections.Generic.IList<int>.RemoveAt(int)""
  3371. IL_0255: ldloc.0
  3372. IL_0256: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3373. IL_025b: ldc.i4.8
  3374. IL_025c: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3375. IL_0261: pop
  3376. IL_0262: ldloc.0
  3377. IL_0263: callvirt ""int System.Collections.Generic.ICollection<int>.Count.get""
  3378. IL_0268: box ""int""
  3379. IL_026d: ldc.i4.0
  3380. IL_026e: box ""int""
  3381. IL_0273: call ""bool AllMembers.ValidateValue(object, object)""
  3382. IL_0278: pop
  3383. IL_0279: ldloc.0
  3384. IL_027a: ldc.i4.1
  3385. IL_027b: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  3386. IL_0280: ldloc.0
  3387. IL_0281: ldc.i4.2
  3388. IL_0282: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  3389. IL_0287: ldloc.0
  3390. IL_0288: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3391. IL_028d: ldloc.0
  3392. IL_028e: callvirt ""void System.Collections.Generic.ICollection<int>.Clear()""
  3393. IL_0293: ldloc.0
  3394. IL_0294: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3395. IL_0299: ldc.i4.s 11
  3396. IL_029b: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3397. IL_02a0: pop
  3398. IL_02a1: ldloc.0
  3399. IL_02a2: callvirt ""int System.Collections.Generic.ICollection<int>.Count.get""
  3400. IL_02a7: box ""int""
  3401. IL_02ac: ldc.i4.0
  3402. IL_02ad: box ""int""
  3403. IL_02b2: call ""bool AllMembers.ValidateValue(object, object)""
  3404. IL_02b7: pop
  3405. IL_02b8: ldloc.0
  3406. IL_02b9: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3407. IL_02be: ldloc.0
  3408. IL_02bf: callvirt ""int System.Collections.Generic.IReadOnlyCollection<int>.Count.get""
  3409. IL_02c4: stloc.3
  3410. IL_02c5: ldloc.0
  3411. IL_02c6: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3412. IL_02cb: ldc.i4.3
  3413. IL_02cc: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3414. IL_02d1: pop
  3415. IL_02d2: ldloc.0
  3416. IL_02d3: dup
  3417. IL_02d4: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3418. IL_02d9: dup
  3419. IL_02da: ldc.i4.1
  3420. IL_02db: ldc.i4.2
  3421. IL_02dc: callvirt ""void System.Collections.Generic.IDictionary<int, int>.Add(int, int)""
  3422. IL_02e1: dup
  3423. IL_02e2: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3424. IL_02e7: ldc.i4.s 21
  3425. IL_02e9: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3426. IL_02ee: pop
  3427. IL_02ef: dup
  3428. IL_02f0: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Count.get""
  3429. IL_02f5: box ""int""
  3430. IL_02fa: ldc.i4.1
  3431. IL_02fb: box ""int""
  3432. IL_0300: call ""bool AllMembers.ValidateValue(object, object)""
  3433. IL_0305: pop
  3434. IL_0306: dup
  3435. IL_0307: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3436. IL_030c: dup
  3437. IL_030d: ldc.i4.1
  3438. IL_030e: callvirt ""bool System.Collections.Generic.IDictionary<int, int>.ContainsKey(int)""
  3439. IL_0313: pop
  3440. IL_0314: dup
  3441. IL_0315: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3442. IL_031a: ldc.i4.s 19
  3443. IL_031c: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3444. IL_0321: pop
  3445. IL_0322: dup
  3446. IL_0323: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3447. IL_0328: dup
  3448. IL_0329: ldc.i4.1
  3449. IL_032a: callvirt ""int System.Collections.Generic.IDictionary<int, int>.this[int].get""
  3450. IL_032f: stloc.s V_7
  3451. IL_0331: dup
  3452. IL_0332: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3453. IL_0337: ldc.i4.s 17
  3454. IL_0339: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3455. IL_033e: pop
  3456. IL_033f: ldloc.s V_7
  3457. IL_0341: box ""int""
  3458. IL_0346: ldc.i4.2
  3459. IL_0347: box ""int""
  3460. IL_034c: call ""bool AllMembers.ValidateValue(object, object)""
  3461. IL_0351: pop
  3462. IL_0352: dup
  3463. IL_0353: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3464. IL_0358: dup
  3465. IL_0359: callvirt ""System.Collections.Generic.ICollection<int> System.Collections.Generic.IDictionary<int, int>.Keys.get""
  3466. IL_035e: pop
  3467. IL_035f: dup
  3468. IL_0360: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3469. IL_0365: ldc.i4.0
  3470. IL_0366: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3471. IL_036b: pop
  3472. IL_036c: dup
  3473. IL_036d: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3474. IL_0372: dup
  3475. IL_0373: callvirt ""System.Collections.Generic.ICollection<int> System.Collections.Generic.IDictionary<int, int>.Values.get""
  3476. IL_0378: pop
  3477. IL_0379: dup
  3478. IL_037a: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3479. IL_037f: ldc.i4.0
  3480. IL_0380: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3481. IL_0385: pop
  3482. IL_0386: dup
  3483. IL_0387: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3484. IL_038c: dup
  3485. IL_038d: ldc.i4.1
  3486. IL_038e: ldloca.s V_8
  3487. IL_0390: callvirt ""bool System.Collections.Generic.IDictionary<int, int>.TryGetValue(int, out int)""
  3488. IL_0395: stloc.s V_9
  3489. IL_0397: dup
  3490. IL_0398: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3491. IL_039d: ldc.i4.s 17
  3492. IL_039f: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3493. IL_03a4: pop
  3494. IL_03a5: ldloc.s V_8
  3495. IL_03a7: box ""int""
  3496. IL_03ac: ldc.i4.2
  3497. IL_03ad: box ""int""
  3498. IL_03b2: call ""bool AllMembers.ValidateValue(object, object)""
  3499. IL_03b7: pop
  3500. IL_03b8: ldloc.s V_9
  3501. IL_03ba: box ""bool""
  3502. IL_03bf: ldc.i4.1
  3503. IL_03c0: box ""bool""
  3504. IL_03c5: call ""bool AllMembers.ValidateValue(object, object)""
  3505. IL_03ca: pop
  3506. IL_03cb: dup
  3507. IL_03cc: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3508. IL_03d1: dup
  3509. IL_03d2: ldc.i4.3
  3510. IL_03d3: ldc.i4.4
  3511. IL_03d4: newobj ""System.Collections.Generic.KeyValuePair<int, int>..ctor(int, int)""
  3512. IL_03d9: callvirt ""void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Add(System.Collections.Generic.KeyValuePair<int, int>)""
  3513. IL_03de: dup
  3514. IL_03df: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3515. IL_03e4: ldc.i4.s 21
  3516. IL_03e6: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3517. IL_03eb: pop
  3518. IL_03ec: dup
  3519. IL_03ed: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Count.get""
  3520. IL_03f2: box ""int""
  3521. IL_03f7: ldc.i4.2
  3522. IL_03f8: box ""int""
  3523. IL_03fd: call ""bool AllMembers.ValidateValue(object, object)""
  3524. IL_0402: pop
  3525. IL_0403: dup
  3526. IL_0404: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3527. IL_0409: dup
  3528. IL_040a: ldc.i4.3
  3529. IL_040b: ldc.i4.4
  3530. IL_040c: newobj ""System.Collections.Generic.KeyValuePair<int, int>..ctor(int, int)""
  3531. IL_0411: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Contains(System.Collections.Generic.KeyValuePair<int, int>)""
  3532. IL_0416: stloc.s V_10
  3533. IL_0418: dup
  3534. IL_0419: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3535. IL_041e: ldc.i4.s 17
  3536. IL_0420: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3537. IL_0425: pop
  3538. IL_0426: ldloc.s V_10
  3539. IL_0428: box ""bool""
  3540. IL_042d: ldc.i4.1
  3541. IL_042e: box ""bool""
  3542. IL_0433: call ""bool AllMembers.ValidateValue(object, object)""
  3543. IL_0438: pop
  3544. IL_0439: dup
  3545. IL_043a: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3546. IL_043f: dup
  3547. IL_0440: ldc.i4.8
  3548. IL_0441: ldc.i4.s 9
  3549. IL_0443: newobj ""System.Collections.Generic.KeyValuePair<int, int>..ctor(int, int)""
  3550. IL_0448: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Contains(System.Collections.Generic.KeyValuePair<int, int>)""
  3551. IL_044d: stloc.s V_10
  3552. IL_044f: dup
  3553. IL_0450: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3554. IL_0455: ldc.i4.s 19
  3555. IL_0457: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3556. IL_045c: pop
  3557. IL_045d: ldloc.s V_10
  3558. IL_045f: box ""bool""
  3559. IL_0464: ldc.i4.0
  3560. IL_0465: box ""bool""
  3561. IL_046a: call ""bool AllMembers.ValidateValue(object, object)""
  3562. IL_046f: pop
  3563. IL_0470: dup
  3564. IL_0471: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3565. IL_0476: dup
  3566. IL_0477: ldc.i4.1
  3567. IL_0478: callvirt ""bool System.Collections.Generic.IDictionary<int, int>.Remove(int)""
  3568. IL_047d: stloc.s V_11
  3569. IL_047f: dup
  3570. IL_0480: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3571. IL_0485: ldc.i4.s 22
  3572. IL_0487: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3573. IL_048c: pop
  3574. IL_048d: dup
  3575. IL_048e: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Count.get""
  3576. IL_0493: box ""int""
  3577. IL_0498: ldc.i4.1
  3578. IL_0499: box ""int""
  3579. IL_049e: call ""bool AllMembers.ValidateValue(object, object)""
  3580. IL_04a3: pop
  3581. IL_04a4: ldloc.s V_11
  3582. IL_04a6: box ""bool""
  3583. IL_04ab: ldc.i4.1
  3584. IL_04ac: box ""bool""
  3585. IL_04b1: call ""bool AllMembers.ValidateValue(object, object)""
  3586. IL_04b6: pop
  3587. IL_04b7: dup
  3588. IL_04b8: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3589. IL_04bd: dup
  3590. IL_04be: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Count.get""
  3591. IL_04c3: stloc.3
  3592. IL_04c4: dup
  3593. IL_04c5: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3594. IL_04ca: ldc.i4.s 18
  3595. IL_04cc: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3596. IL_04d1: pop
  3597. IL_04d2: ldloc.3
  3598. IL_04d3: box ""int""
  3599. IL_04d8: ldc.i4.1
  3600. IL_04d9: box ""int""
  3601. IL_04de: call ""bool AllMembers.ValidateValue(object, object)""
  3602. IL_04e3: pop
  3603. IL_04e4: dup
  3604. IL_04e5: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3605. IL_04ea: dup
  3606. IL_04eb: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.IsReadOnly.get""
  3607. IL_04f0: stloc.s V_6
  3608. IL_04f2: dup
  3609. IL_04f3: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3610. IL_04f8: ldc.i4.0
  3611. IL_04f9: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3612. IL_04fe: pop
  3613. IL_04ff: ldloc.s V_6
  3614. IL_0501: box ""bool""
  3615. IL_0506: ldc.i4.0
  3616. IL_0507: box ""bool""
  3617. IL_050c: call ""bool AllMembers.ValidateValue(object, object)""
  3618. IL_0511: pop
  3619. IL_0512: dup
  3620. IL_0513: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3621. IL_0518: dup
  3622. IL_0519: ldc.i4.3
  3623. IL_051a: ldc.i4.4
  3624. IL_051b: newobj ""System.Collections.Generic.KeyValuePair<int, int>..ctor(int, int)""
  3625. IL_0520: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Remove(System.Collections.Generic.KeyValuePair<int, int>)""
  3626. IL_0525: stloc.s V_12
  3627. IL_0527: dup
  3628. IL_0528: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3629. IL_052d: ldc.i4.s 22
  3630. IL_052f: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3631. IL_0534: pop
  3632. IL_0535: ldloc.s V_12
  3633. IL_0537: box ""bool""
  3634. IL_053c: ldc.i4.1
  3635. IL_053d: box ""bool""
  3636. IL_0542: call ""bool AllMembers.ValidateValue(object, object)""
  3637. IL_0547: pop
  3638. IL_0548: dup
  3639. IL_0549: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3640. IL_054e: dup
  3641. IL_054f: ldc.i4.2
  3642. IL_0550: ldc.i4.3
  3643. IL_0551: newobj ""System.Collections.Generic.KeyValuePair<int, int>..ctor(int, int)""
  3644. IL_0556: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Remove(System.Collections.Generic.KeyValuePair<int, int>)""
  3645. IL_055b: stloc.s V_12
  3646. IL_055d: dup
  3647. IL_055e: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3648. IL_0563: ldc.i4.s 19
  3649. IL_0565: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3650. IL_056a: pop
  3651. IL_056b: ldloc.s V_12
  3652. IL_056d: box ""bool""
  3653. IL_0572: ldc.i4.0
  3654. IL_0573: box ""bool""
  3655. IL_0578: call ""bool AllMembers.ValidateValue(object, object)""
  3656. IL_057d: pop
  3657. IL_057e: dup
  3658. IL_057f: ldc.i4.1
  3659. IL_0580: ldc.i4.2
  3660. IL_0581: callvirt ""void System.Collections.Generic.IDictionary<int, int>.Add(int, int)""
  3661. IL_0586: dup
  3662. IL_0587: ldc.i4.2
  3663. IL_0588: ldc.i4.3
  3664. IL_0589: callvirt ""void System.Collections.Generic.IDictionary<int, int>.Add(int, int)""
  3665. IL_058e: dup
  3666. IL_058f: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3667. IL_0594: dup
  3668. IL_0595: callvirt ""void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Clear()""
  3669. IL_059a: dup
  3670. IL_059b: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3671. IL_05a0: ldc.i4.s 23
  3672. IL_05a2: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3673. IL_05a7: pop
  3674. IL_05a8: dup
  3675. IL_05a9: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Count.get""
  3676. IL_05ae: box ""int""
  3677. IL_05b3: ldc.i4.0
  3678. IL_05b4: box ""int""
  3679. IL_05b9: call ""bool AllMembers.ValidateValue(object, object)""
  3680. IL_05be: pop
  3681. IL_05bf: dup
  3682. IL_05c0: callvirt ""void Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.ClearFlag()""
  3683. IL_05c5: dup
  3684. IL_05c6: callvirt ""int System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<int, int>>.Count.get""
  3685. IL_05cb: stloc.3
  3686. IL_05cc: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorIntIVectorViewIntIMapIntIntIMapViewIntInt.GetFlagState()""
  3687. IL_05d1: ldc.i4.3
  3688. IL_05d2: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3689. IL_05d7: pop
  3690. IL_05d8: ret
  3691. }");
  3692. verifier.VerifyIL("AllMembers.TestIVectorStructIVectorViewStructIMapIntStructIMapViewIntStructMembers",
  3693. @"{
  3694. // Code size 1395 (0x573)
  3695. .maxstack 5
  3696. .locals init (Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct V_0, //v
  3697. Windows.Languages.WinRTTest.UserDefinedStruct V_1, //ud
  3698. bool V_2, //b
  3699. Windows.Languages.WinRTTest.UserDefinedStruct[] V_3, //arr
  3700. int V_4, //count
  3701. System.Collections.Generic.IEnumerator<Windows.Languages.WinRTTest.UserDefinedStruct> V_5, //enumerator
  3702. int V_6, //index
  3703. int V_7, //rez
  3704. bool V_8, //isReadOnly
  3705. Windows.Languages.WinRTTest.UserDefinedStruct V_9, //outVal
  3706. bool V_10, //success
  3707. bool V_11, //contains
  3708. Windows.Languages.WinRTTest.UserDefinedStruct V_12,
  3709. System.Collections.Generic.IEnumerator<Windows.Languages.WinRTTest.UserDefinedStruct> V_13)
  3710. IL_0000: newobj ""Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct..ctor()""
  3711. IL_0005: stloc.0
  3712. IL_0006: ldloca.s V_12
  3713. IL_0008: initobj ""Windows.Languages.WinRTTest.UserDefinedStruct""
  3714. IL_000e: ldloca.s V_12
  3715. IL_0010: ldc.i4.1
  3716. IL_0011: stfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  3717. IL_0016: ldloc.s V_12
  3718. IL_0018: stloc.1
  3719. IL_0019: ldloc.0
  3720. IL_001a: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  3721. IL_001f: ldloc.0
  3722. IL_0020: ldloc.1
  3723. IL_0021: callvirt ""void System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct>.Add(Windows.Languages.WinRTTest.UserDefinedStruct)""
  3724. IL_0026: ldloc.0
  3725. IL_0027: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  3726. IL_002c: ldc.i4.s 9
  3727. IL_002e: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3728. IL_0033: pop
  3729. IL_0034: ldloc.0
  3730. IL_0035: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  3731. IL_003a: ldloc.0
  3732. IL_003b: ldloc.1
  3733. IL_003c: callvirt ""bool System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct>.Contains(Windows.Languages.WinRTTest.UserDefinedStruct)""
  3734. IL_0041: stloc.2
  3735. IL_0042: ldloc.0
  3736. IL_0043: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  3737. IL_0048: ldc.i4.5
  3738. IL_0049: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3739. IL_004e: pop
  3740. IL_004f: ldloc.2
  3741. IL_0050: box ""bool""
  3742. IL_0055: ldc.i4.1
  3743. IL_0056: box ""bool""
  3744. IL_005b: call ""bool AllMembers.ValidateValue(object, object)""
  3745. IL_0060: pop
  3746. IL_0061: ldloc.0
  3747. IL_0062: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  3748. IL_0067: ldc.i4.s 10
  3749. IL_0069: newarr ""Windows.Languages.WinRTTest.UserDefinedStruct""
  3750. IL_006e: stloc.3
  3751. IL_006f: ldloc.0
  3752. IL_0070: ldloc.3
  3753. IL_0071: ldc.i4.0
  3754. IL_0072: callvirt ""void System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct>.CopyTo(Windows.Languages.WinRTTest.UserDefinedStruct[], int)""
  3755. IL_0077: ldloc.0
  3756. IL_0078: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  3757. IL_007d: ldc.i4.2
  3758. IL_007e: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3759. IL_0083: pop
  3760. IL_0084: ldloc.3
  3761. IL_0085: ldc.i4.0
  3762. IL_0086: ldelema ""Windows.Languages.WinRTTest.UserDefinedStruct""
  3763. IL_008b: ldfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  3764. IL_0090: box ""uint""
  3765. IL_0095: ldloc.1
  3766. IL_0096: ldfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  3767. IL_009b: box ""uint""
  3768. IL_00a0: call ""bool AllMembers.ValidateValue(object, object)""
  3769. IL_00a5: pop
  3770. IL_00a6: ldloc.0
  3771. IL_00a7: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  3772. IL_00ac: ldloc.0
  3773. IL_00ad: callvirt ""int System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct>.Count.get""
  3774. IL_00b2: stloc.s V_4
  3775. IL_00b4: ldloc.0
  3776. IL_00b5: callvirt ""System.Collections.Generic.IEnumerator<Windows.Languages.WinRTTest.UserDefinedStruct> System.Collections.Generic.IEnumerable<Windows.Languages.WinRTTest.UserDefinedStruct>.GetEnumerator()""
  3777. IL_00ba: stloc.s V_5
  3778. IL_00bc: ldloc.0
  3779. IL_00bd: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  3780. IL_00c2: ldc.i4.1
  3781. IL_00c3: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3782. IL_00c8: pop
  3783. IL_00c9: ldloc.s V_5
  3784. IL_00cb: callvirt ""bool System.Collections.IEnumerator.MoveNext()""
  3785. IL_00d0: pop
  3786. IL_00d1: ldloc.s V_5
  3787. IL_00d3: callvirt ""Windows.Languages.WinRTTest.UserDefinedStruct System.Collections.Generic.IEnumerator<Windows.Languages.WinRTTest.UserDefinedStruct>.Current.get""
  3788. IL_00d8: ldfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  3789. IL_00dd: box ""uint""
  3790. IL_00e2: ldc.i4.1
  3791. IL_00e3: box ""int""
  3792. IL_00e8: call ""bool AllMembers.ValidateValue(object, object)""
  3793. IL_00ed: pop
  3794. IL_00ee: ldc.i4.0
  3795. IL_00ef: stloc.s V_6
  3796. IL_00f1: ldloc.0
  3797. IL_00f2: callvirt ""System.Collections.Generic.IEnumerator<Windows.Languages.WinRTTest.UserDefinedStruct> System.Collections.Generic.IEnumerable<Windows.Languages.WinRTTest.UserDefinedStruct>.GetEnumerator()""
  3798. IL_00f7: stloc.s V_13
  3799. .try
  3800. {
  3801. IL_00f9: br.s IL_011f
  3802. IL_00fb: ldloc.s V_13
  3803. IL_00fd: callvirt ""Windows.Languages.WinRTTest.UserDefinedStruct System.Collections.Generic.IEnumerator<Windows.Languages.WinRTTest.UserDefinedStruct>.Current.get""
  3804. IL_0102: ldloc.s V_6
  3805. IL_0104: ldc.i4.1
  3806. IL_0105: add
  3807. IL_0106: stloc.s V_6
  3808. IL_0108: ldfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  3809. IL_010d: box ""uint""
  3810. IL_0112: ldloc.s V_6
  3811. IL_0114: box ""int""
  3812. IL_0119: call ""bool AllMembers.ValidateValue(object, object)""
  3813. IL_011e: pop
  3814. IL_011f: ldloc.s V_13
  3815. IL_0121: callvirt ""bool System.Collections.IEnumerator.MoveNext()""
  3816. IL_0126: brtrue.s IL_00fb
  3817. IL_0128: leave.s IL_0136
  3818. }
  3819. finally
  3820. {
  3821. IL_012a: ldloc.s V_13
  3822. IL_012c: brfalse.s IL_0135
  3823. IL_012e: ldloc.s V_13
  3824. IL_0130: callvirt ""void System.IDisposable.Dispose()""
  3825. IL_0135: endfinally
  3826. }
  3827. IL_0136: ldloc.s V_6
  3828. IL_0138: box ""int""
  3829. IL_013d: ldc.i4.1
  3830. IL_013e: box ""int""
  3831. IL_0143: call ""bool AllMembers.ValidateValue(object, object)""
  3832. IL_0148: pop
  3833. IL_0149: ldloc.0
  3834. IL_014a: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  3835. IL_014f: ldloc.0
  3836. IL_0150: ldloc.1
  3837. IL_0151: callvirt ""int System.Collections.Generic.IList<Windows.Languages.WinRTTest.UserDefinedStruct>.IndexOf(Windows.Languages.WinRTTest.UserDefinedStruct)""
  3838. IL_0156: stloc.s V_7
  3839. IL_0158: ldloc.0
  3840. IL_0159: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  3841. IL_015e: ldc.i4.5
  3842. IL_015f: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3843. IL_0164: pop
  3844. IL_0165: ldloc.s V_7
  3845. IL_0167: box ""int""
  3846. IL_016c: ldc.i4.0
  3847. IL_016d: box ""int""
  3848. IL_0172: call ""bool AllMembers.ValidateValue(object, object)""
  3849. IL_0177: pop
  3850. IL_0178: ldloc.0
  3851. IL_0179: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  3852. IL_017e: ldloc.0
  3853. IL_017f: ldc.i4.1
  3854. IL_0180: ldloca.s V_12
  3855. IL_0182: initobj ""Windows.Languages.WinRTTest.UserDefinedStruct""
  3856. IL_0188: ldloca.s V_12
  3857. IL_018a: ldc.i4.4
  3858. IL_018b: stfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  3859. IL_0190: ldloc.s V_12
  3860. IL_0192: callvirt ""void System.Collections.Generic.IList<Windows.Languages.WinRTTest.UserDefinedStruct>.Insert(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  3861. IL_0197: ldloc.0
  3862. IL_0198: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  3863. IL_019d: ldc.i4.7
  3864. IL_019e: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3865. IL_01a3: pop
  3866. IL_01a4: ldloc.0
  3867. IL_01a5: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  3868. IL_01aa: ldloc.0
  3869. IL_01ab: callvirt ""bool System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct>.IsReadOnly.get""
  3870. IL_01b0: stloc.s V_8
  3871. IL_01b2: ldloc.0
  3872. IL_01b3: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  3873. IL_01b8: ldc.i4.0
  3874. IL_01b9: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3875. IL_01be: pop
  3876. IL_01bf: ldloc.s V_8
  3877. IL_01c1: box ""bool""
  3878. IL_01c6: ldc.i4.0
  3879. IL_01c7: box ""bool""
  3880. IL_01cc: call ""bool AllMembers.ValidateValue(object, object)""
  3881. IL_01d1: pop
  3882. IL_01d2: ldloc.0
  3883. IL_01d3: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  3884. IL_01d8: ldloc.0
  3885. IL_01d9: ldc.i4.0
  3886. IL_01da: callvirt ""Windows.Languages.WinRTTest.UserDefinedStruct System.Collections.Generic.IList<Windows.Languages.WinRTTest.UserDefinedStruct>.this[int].get""
  3887. IL_01df: pop
  3888. IL_01e0: ldloc.0
  3889. IL_01e1: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  3890. IL_01e6: ldc.i4.2
  3891. IL_01e7: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3892. IL_01ec: pop
  3893. IL_01ed: ldloc.0
  3894. IL_01ee: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  3895. IL_01f3: ldloc.0
  3896. IL_01f4: ldc.i4.1
  3897. IL_01f5: callvirt ""Windows.Languages.WinRTTest.UserDefinedStruct System.Collections.Generic.IList<Windows.Languages.WinRTTest.UserDefinedStruct>.this[int].get""
  3898. IL_01fa: pop
  3899. IL_01fb: ldloc.0
  3900. IL_01fc: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  3901. IL_0201: ldc.i4.2
  3902. IL_0202: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3903. IL_0207: pop
  3904. IL_0208: ldloc.0
  3905. IL_0209: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  3906. IL_020e: ldloc.0
  3907. IL_020f: ldloc.1
  3908. IL_0210: callvirt ""bool System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct>.Remove(Windows.Languages.WinRTTest.UserDefinedStruct)""
  3909. IL_0215: pop
  3910. IL_0216: ldloc.0
  3911. IL_0217: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  3912. IL_021c: ldc.i4.8
  3913. IL_021d: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3914. IL_0222: pop
  3915. IL_0223: ldloc.0
  3916. IL_0224: callvirt ""int System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct>.Count.get""
  3917. IL_0229: box ""int""
  3918. IL_022e: ldc.i4.1
  3919. IL_022f: box ""int""
  3920. IL_0234: call ""bool AllMembers.ValidateValue(object, object)""
  3921. IL_0239: pop
  3922. IL_023a: ldloc.0
  3923. IL_023b: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  3924. IL_0240: ldloc.0
  3925. IL_0241: ldc.i4.0
  3926. IL_0242: callvirt ""void System.Collections.Generic.IList<Windows.Languages.WinRTTest.UserDefinedStruct>.RemoveAt(int)""
  3927. IL_0247: ldloc.0
  3928. IL_0248: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  3929. IL_024d: ldc.i4.8
  3930. IL_024e: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3931. IL_0253: pop
  3932. IL_0254: ldloc.0
  3933. IL_0255: callvirt ""int System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct>.Count.get""
  3934. IL_025a: box ""int""
  3935. IL_025f: ldc.i4.0
  3936. IL_0260: box ""int""
  3937. IL_0265: call ""bool AllMembers.ValidateValue(object, object)""
  3938. IL_026a: pop
  3939. IL_026b: ldloc.0
  3940. IL_026c: ldloc.1
  3941. IL_026d: callvirt ""void System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct>.Add(Windows.Languages.WinRTTest.UserDefinedStruct)""
  3942. IL_0272: ldloc.0
  3943. IL_0273: ldloca.s V_12
  3944. IL_0275: initobj ""Windows.Languages.WinRTTest.UserDefinedStruct""
  3945. IL_027b: ldloca.s V_12
  3946. IL_027d: ldc.i4.4
  3947. IL_027e: stfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  3948. IL_0283: ldloc.s V_12
  3949. IL_0285: callvirt ""void System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct>.Add(Windows.Languages.WinRTTest.UserDefinedStruct)""
  3950. IL_028a: ldloc.0
  3951. IL_028b: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  3952. IL_0290: ldloc.0
  3953. IL_0291: callvirt ""void System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct>.Clear()""
  3954. IL_0296: ldloc.0
  3955. IL_0297: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  3956. IL_029c: ldc.i4.s 11
  3957. IL_029e: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3958. IL_02a3: pop
  3959. IL_02a4: ldloc.0
  3960. IL_02a5: callvirt ""int System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct>.Count.get""
  3961. IL_02aa: box ""int""
  3962. IL_02af: ldc.i4.0
  3963. IL_02b0: box ""int""
  3964. IL_02b5: call ""bool AllMembers.ValidateValue(object, object)""
  3965. IL_02ba: pop
  3966. IL_02bb: ldloc.0
  3967. IL_02bc: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  3968. IL_02c1: ldloc.0
  3969. IL_02c2: callvirt ""int System.Collections.Generic.IReadOnlyCollection<Windows.Languages.WinRTTest.UserDefinedStruct>.Count.get""
  3970. IL_02c7: stloc.s V_4
  3971. IL_02c9: ldloc.0
  3972. IL_02ca: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  3973. IL_02cf: ldc.i4.3
  3974. IL_02d0: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3975. IL_02d5: pop
  3976. IL_02d6: ldloc.0
  3977. IL_02d7: ldloca.s V_12
  3978. IL_02d9: initobj ""Windows.Languages.WinRTTest.UserDefinedStruct""
  3979. IL_02df: ldloca.s V_12
  3980. IL_02e1: ldc.i4.s 10
  3981. IL_02e3: stfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  3982. IL_02e8: ldloc.s V_12
  3983. IL_02ea: stloc.1
  3984. IL_02eb: dup
  3985. IL_02ec: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  3986. IL_02f1: dup
  3987. IL_02f2: ldc.i4.1
  3988. IL_02f3: ldloc.1
  3989. IL_02f4: callvirt ""void System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Add(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  3990. IL_02f9: dup
  3991. IL_02fa: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  3992. IL_02ff: ldc.i4.s 21
  3993. IL_0301: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  3994. IL_0306: pop
  3995. IL_0307: dup
  3996. IL_0308: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  3997. IL_030d: box ""int""
  3998. IL_0312: ldc.i4.1
  3999. IL_0313: box ""int""
  4000. IL_0318: call ""bool AllMembers.ValidateValue(object, object)""
  4001. IL_031d: pop
  4002. IL_031e: dup
  4003. IL_031f: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  4004. IL_0324: dup
  4005. IL_0325: ldc.i4.1
  4006. IL_0326: callvirt ""bool System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.ContainsKey(int)""
  4007. IL_032b: pop
  4008. IL_032c: dup
  4009. IL_032d: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  4010. IL_0332: ldc.i4.s 19
  4011. IL_0334: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4012. IL_0339: pop
  4013. IL_033a: dup
  4014. IL_033b: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  4015. IL_0340: dup
  4016. IL_0341: ldc.i4.1
  4017. IL_0342: callvirt ""Windows.Languages.WinRTTest.UserDefinedStruct System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.this[int].get""
  4018. IL_0347: pop
  4019. IL_0348: dup
  4020. IL_0349: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  4021. IL_034e: ldc.i4.s 17
  4022. IL_0350: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4023. IL_0355: pop
  4024. IL_0356: dup
  4025. IL_0357: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  4026. IL_035c: dup
  4027. IL_035d: callvirt ""System.Collections.Generic.ICollection<int> System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Keys.get""
  4028. IL_0362: pop
  4029. IL_0363: dup
  4030. IL_0364: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  4031. IL_0369: ldc.i4.0
  4032. IL_036a: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4033. IL_036f: pop
  4034. IL_0370: dup
  4035. IL_0371: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  4036. IL_0376: dup
  4037. IL_0377: callvirt ""System.Collections.Generic.ICollection<Windows.Languages.WinRTTest.UserDefinedStruct> System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Values.get""
  4038. IL_037c: pop
  4039. IL_037d: dup
  4040. IL_037e: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  4041. IL_0383: ldc.i4.0
  4042. IL_0384: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4043. IL_0389: pop
  4044. IL_038a: dup
  4045. IL_038b: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  4046. IL_0390: dup
  4047. IL_0391: ldc.i4.1
  4048. IL_0392: ldloca.s V_9
  4049. IL_0394: callvirt ""bool System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.TryGetValue(int, out Windows.Languages.WinRTTest.UserDefinedStruct)""
  4050. IL_0399: stloc.s V_10
  4051. IL_039b: dup
  4052. IL_039c: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  4053. IL_03a1: ldc.i4.s 17
  4054. IL_03a3: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4055. IL_03a8: pop
  4056. IL_03a9: ldloc.s V_10
  4057. IL_03ab: box ""bool""
  4058. IL_03b0: ldc.i4.1
  4059. IL_03b1: box ""bool""
  4060. IL_03b6: call ""bool AllMembers.ValidateValue(object, object)""
  4061. IL_03bb: pop
  4062. IL_03bc: dup
  4063. IL_03bd: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  4064. IL_03c2: dup
  4065. IL_03c3: ldc.i4.3
  4066. IL_03c4: ldloca.s V_12
  4067. IL_03c6: initobj ""Windows.Languages.WinRTTest.UserDefinedStruct""
  4068. IL_03cc: ldloca.s V_12
  4069. IL_03ce: ldc.i4.4
  4070. IL_03cf: stfld ""uint Windows.Languages.WinRTTest.UserDefinedStruct.Id""
  4071. IL_03d4: ldloc.s V_12
  4072. IL_03d6: newobj ""System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>..ctor(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  4073. IL_03db: callvirt ""void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Add(System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>)""
  4074. IL_03e0: dup
  4075. IL_03e1: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  4076. IL_03e6: ldc.i4.s 21
  4077. IL_03e8: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4078. IL_03ed: pop
  4079. IL_03ee: dup
  4080. IL_03ef: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  4081. IL_03f4: box ""int""
  4082. IL_03f9: ldc.i4.2
  4083. IL_03fa: box ""int""
  4084. IL_03ff: call ""bool AllMembers.ValidateValue(object, object)""
  4085. IL_0404: pop
  4086. IL_0405: dup
  4087. IL_0406: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  4088. IL_040b: dup
  4089. IL_040c: ldc.i4.1
  4090. IL_040d: ldloc.1
  4091. IL_040e: newobj ""System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>..ctor(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  4092. IL_0413: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Contains(System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>)""
  4093. IL_0418: stloc.s V_11
  4094. IL_041a: dup
  4095. IL_041b: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  4096. IL_0420: ldc.i4.s 17
  4097. IL_0422: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4098. IL_0427: pop
  4099. IL_0428: ldloc.s V_11
  4100. IL_042a: box ""bool""
  4101. IL_042f: ldc.i4.1
  4102. IL_0430: box ""bool""
  4103. IL_0435: call ""bool AllMembers.ValidateValue(object, object)""
  4104. IL_043a: pop
  4105. IL_043b: dup
  4106. IL_043c: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  4107. IL_0441: dup
  4108. IL_0442: ldc.i4.8
  4109. IL_0443: ldloca.s V_12
  4110. IL_0445: initobj ""Windows.Languages.WinRTTest.UserDefinedStruct""
  4111. IL_044b: ldloc.s V_12
  4112. IL_044d: newobj ""System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>..ctor(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  4113. IL_0452: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Contains(System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>)""
  4114. IL_0457: stloc.s V_11
  4115. IL_0459: dup
  4116. IL_045a: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  4117. IL_045f: ldc.i4.s 19
  4118. IL_0461: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4119. IL_0466: pop
  4120. IL_0467: ldloc.s V_11
  4121. IL_0469: box ""bool""
  4122. IL_046e: ldc.i4.0
  4123. IL_046f: box ""bool""
  4124. IL_0474: call ""bool AllMembers.ValidateValue(object, object)""
  4125. IL_0479: pop
  4126. IL_047a: dup
  4127. IL_047b: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  4128. IL_0480: dup
  4129. IL_0481: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  4130. IL_0486: dup
  4131. IL_0487: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  4132. IL_048c: stloc.s V_4
  4133. IL_048e: dup
  4134. IL_048f: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  4135. IL_0494: ldc.i4.s 18
  4136. IL_0496: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4137. IL_049b: pop
  4138. IL_049c: ldloc.s V_4
  4139. IL_049e: box ""int""
  4140. IL_04a3: ldc.i4.1
  4141. IL_04a4: box ""int""
  4142. IL_04a9: call ""bool AllMembers.ValidateValue(object, object)""
  4143. IL_04ae: pop
  4144. IL_04af: dup
  4145. IL_04b0: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  4146. IL_04b5: dup
  4147. IL_04b6: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.IsReadOnly.get""
  4148. IL_04bb: stloc.s V_8
  4149. IL_04bd: dup
  4150. IL_04be: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  4151. IL_04c3: ldc.i4.0
  4152. IL_04c4: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4153. IL_04c9: pop
  4154. IL_04ca: ldloc.s V_8
  4155. IL_04cc: box ""bool""
  4156. IL_04d1: ldc.i4.0
  4157. IL_04d2: box ""bool""
  4158. IL_04d7: call ""bool AllMembers.ValidateValue(object, object)""
  4159. IL_04dc: pop
  4160. IL_04dd: dup
  4161. IL_04de: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  4162. IL_04e3: dup
  4163. IL_04e4: ldc.i4.1
  4164. IL_04e5: ldloc.1
  4165. IL_04e6: newobj ""System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>..ctor(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  4166. IL_04eb: callvirt ""bool System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Remove(System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>)""
  4167. IL_04f0: pop
  4168. IL_04f1: dup
  4169. IL_04f2: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  4170. IL_04f7: ldc.i4.s 22
  4171. IL_04f9: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4172. IL_04fe: pop
  4173. IL_04ff: dup
  4174. IL_0500: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  4175. IL_0505: box ""int""
  4176. IL_050a: ldc.i4.0
  4177. IL_050b: box ""int""
  4178. IL_0510: call ""bool AllMembers.ValidateValue(object, object)""
  4179. IL_0515: pop
  4180. IL_0516: dup
  4181. IL_0517: ldc.i4.1
  4182. IL_0518: ldloc.1
  4183. IL_0519: callvirt ""void System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Add(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  4184. IL_051e: dup
  4185. IL_051f: ldc.i4.2
  4186. IL_0520: ldloc.1
  4187. IL_0521: callvirt ""void System.Collections.Generic.IDictionary<int, Windows.Languages.WinRTTest.UserDefinedStruct>.Add(int, Windows.Languages.WinRTTest.UserDefinedStruct)""
  4188. IL_0526: dup
  4189. IL_0527: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  4190. IL_052c: dup
  4191. IL_052d: callvirt ""void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Clear()""
  4192. IL_0532: dup
  4193. IL_0533: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  4194. IL_0538: ldc.i4.s 23
  4195. IL_053a: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4196. IL_053f: pop
  4197. IL_0540: dup
  4198. IL_0541: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  4199. IL_0546: box ""int""
  4200. IL_054b: ldc.i4.0
  4201. IL_054c: box ""int""
  4202. IL_0551: call ""bool AllMembers.ValidateValue(object, object)""
  4203. IL_0556: pop
  4204. IL_0557: dup
  4205. IL_0558: callvirt ""void Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.ClearFlag()""
  4206. IL_055d: dup
  4207. IL_055e: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, Windows.Languages.WinRTTest.UserDefinedStruct>>.Count.get""
  4208. IL_0563: stloc.s V_4
  4209. IL_0565: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorStructIVectorViewStructIMapIntStructIMapViewIntStruct.GetFlagState()""
  4210. IL_056a: ldc.i4.s 18
  4211. IL_056c: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4212. IL_0571: pop
  4213. IL_0572: ret
  4214. }
  4215. ");
  4216. }
  4217. [Fact]
  4218. public void LegacyCollectionTest05()
  4219. {
  4220. var source =
  4221. @"using Windows.Languages.WinRTTest;
  4222. using System.Collections.Generic;
  4223. using System.Reflection;
  4224. using System.Linq.Expressions;
  4225. using System;
  4226. using System.Linq;
  4227. class AllMembers
  4228. {
  4229. private static int FailedCount = 0;
  4230. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  4231. {
  4232. var temp = Console.ForegroundColor;
  4233. if (actual != expected)
  4234. {
  4235. FailedCount++;
  4236. Console.ForegroundColor = ConsoleColor.Red;
  4237. Console.Write(""FAIL: "");
  4238. }
  4239. else
  4240. {
  4241. Console.ForegroundColor = ConsoleColor.Green;
  4242. Console.Write(""PASS: "");
  4243. }
  4244. Console.ForegroundColor = temp;
  4245. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  4246. return actual == expected;
  4247. }
  4248. private static bool ValidateValue(object actual, object expected)
  4249. {
  4250. var temp = Console.ForegroundColor;
  4251. if (actual.ToString() != expected.ToString())
  4252. {
  4253. FailedCount++;
  4254. Console.ForegroundColor = ConsoleColor.Red;
  4255. Console.Write(""FAIL: "");
  4256. }
  4257. else
  4258. {
  4259. Console.ForegroundColor = ConsoleColor.Green;
  4260. Console.Write(""PASS: "");
  4261. }
  4262. Console.ForegroundColor = temp;
  4263. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  4264. return actual.ToString() == expected.ToString();
  4265. }
  4266. static void TestISimpleInterfaceImplMembers()
  4267. {
  4268. ISimpleInterfaceImpl v = new ISimpleInterfaceImpl();
  4269. //Add
  4270. v.ClearFlag();
  4271. v.Add(1);
  4272. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  4273. ValidateValue((v as IList<int>)[0], 1);
  4274. //Contains
  4275. v.ClearFlag();
  4276. bool b = v.Contains(1);
  4277. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  4278. ValidateValue(b, true);
  4279. //CopyTo
  4280. v.ClearFlag();
  4281. int[] arr = new int[10];
  4282. v.CopyTo(arr, 0);
  4283. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  4284. ValidateValue(arr[0], 1);
  4285. ValidateValue(arr[1], 0); //there should be nothing there! :)
  4286. //GetEnumerator
  4287. v.ClearFlag();
  4288. int count = (v as IList<int>).Count;
  4289. IEnumerator<int> enumerator = ((IEnumerable<int>)v).GetEnumerator();
  4290. ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First);
  4291. int index = 0;
  4292. foreach (var e in v)
  4293. {
  4294. index = index + 1;
  4295. ValidateValue(e, index);
  4296. }
  4297. ValidateValue(index, 1); //there should only be 1 element there
  4298. //IndexOf
  4299. v.ClearFlag();
  4300. var rez = v.IndexOf(1);
  4301. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  4302. ValidateValue(rez, 0); // 1 is on the first line :)
  4303. //Insert
  4304. v.ClearFlag();
  4305. v.Insert(1, 2);
  4306. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
  4307. ValidateValue((v as IList<int>)[1], 2);
  4308. //IsReadOnly
  4309. v.ClearFlag();
  4310. bool isReadOnly = v.IsReadOnly;
  4311. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  4312. ValidateValue(isReadOnly, false);
  4313. //Indexing
  4314. v.ClearFlag();
  4315. int val = (v as IList<int>)[0];
  4316. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  4317. ValidateValue(val, 1);
  4318. v.ClearFlag();
  4319. val = ((IList<int>)v)[1];
  4320. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  4321. ValidateValue(val, 2);
  4322. //Remove
  4323. v.ClearFlag();
  4324. v.Remove(1);
  4325. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  4326. ValidateValue((v as IList<int>).Count, 1);
  4327. //RemoveAt
  4328. v.ClearFlag();
  4329. v.RemoveAt(0);
  4330. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_RemoveAt);
  4331. ValidateValue((v as IList<int>).Count, 0);
  4332. //Clear
  4333. v.Add(1);
  4334. v.Add(2);
  4335. v.ClearFlag();
  4336. //v.Clear();
  4337. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Clear);
  4338. ValidateValue((v as IList<int>).Count, 0);
  4339. }
  4340. static int Main()
  4341. {
  4342. TestISimpleInterfaceImplMembers();
  4343. Console.WriteLine(FailedCount);
  4344. return FailedCount;
  4345. }
  4346. }";
  4347. var verifier = CompileAndVerify(source,
  4348. additionalRefs: LegacyRefs,
  4349. emitOptions: EmitOptions.RefEmitBug,
  4350. verify: false);
  4351. verifier.VerifyDiagnostics(
  4352. // (3,1): info CS8019: Unnecessary using directive.
  4353. // using System.Reflection;
  4354. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  4355. // (4,1): info CS8019: Unnecessary using directive.
  4356. // using System.Linq.Expressions;
  4357. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  4358. // (6,1): info CS8019: Unnecessary using directive.
  4359. // using System.Linq;
  4360. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"));
  4361. verifier.VerifyIL("AllMembers.TestISimpleInterfaceImplMembers",
  4362. @"{
  4363. // Code size 686 (0x2ae)
  4364. .maxstack 3
  4365. .locals init (Windows.Languages.WinRTTest.ISimpleInterfaceImpl V_0, //v
  4366. bool V_1, //b
  4367. int[] V_2, //arr
  4368. int V_3, //index
  4369. int V_4, //rez
  4370. bool V_5, //isReadOnly
  4371. int V_6, //val
  4372. System.Collections.Generic.IEnumerator<int> V_7)
  4373. IL_0000: newobj ""Windows.Languages.WinRTTest.ISimpleInterfaceImpl..ctor()""
  4374. IL_0005: stloc.0
  4375. IL_0006: ldloc.0
  4376. IL_0007: callvirt ""void Windows.Languages.WinRTTest.ISimpleInterfaceImpl.ClearFlag()""
  4377. IL_000c: ldloc.0
  4378. IL_000d: ldc.i4.1
  4379. IL_000e: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4380. IL_0013: ldloc.0
  4381. IL_0014: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.ISimpleInterfaceImpl.GetFlagState()""
  4382. IL_0019: ldc.i4.s 9
  4383. IL_001b: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4384. IL_0020: pop
  4385. IL_0021: ldloc.0
  4386. IL_0022: ldc.i4.0
  4387. IL_0023: callvirt ""int System.Collections.Generic.IList<int>.this[int].get""
  4388. IL_0028: box ""int""
  4389. IL_002d: ldc.i4.1
  4390. IL_002e: box ""int""
  4391. IL_0033: call ""bool AllMembers.ValidateValue(object, object)""
  4392. IL_0038: pop
  4393. IL_0039: ldloc.0
  4394. IL_003a: callvirt ""void Windows.Languages.WinRTTest.ISimpleInterfaceImpl.ClearFlag()""
  4395. IL_003f: ldloc.0
  4396. IL_0040: ldc.i4.1
  4397. IL_0041: callvirt ""bool System.Collections.Generic.ICollection<int>.Contains(int)""
  4398. IL_0046: stloc.1
  4399. IL_0047: ldloc.0
  4400. IL_0048: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.ISimpleInterfaceImpl.GetFlagState()""
  4401. IL_004d: ldc.i4.5
  4402. IL_004e: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4403. IL_0053: pop
  4404. IL_0054: ldloc.1
  4405. IL_0055: box ""bool""
  4406. IL_005a: ldc.i4.1
  4407. IL_005b: box ""bool""
  4408. IL_0060: call ""bool AllMembers.ValidateValue(object, object)""
  4409. IL_0065: pop
  4410. IL_0066: ldloc.0
  4411. IL_0067: callvirt ""void Windows.Languages.WinRTTest.ISimpleInterfaceImpl.ClearFlag()""
  4412. IL_006c: ldc.i4.s 10
  4413. IL_006e: newarr ""int""
  4414. IL_0073: stloc.2
  4415. IL_0074: ldloc.0
  4416. IL_0075: ldloc.2
  4417. IL_0076: ldc.i4.0
  4418. IL_0077: callvirt ""void System.Collections.Generic.ICollection<int>.CopyTo(int[], int)""
  4419. IL_007c: ldloc.0
  4420. IL_007d: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.ISimpleInterfaceImpl.GetFlagState()""
  4421. IL_0082: ldc.i4.2
  4422. IL_0083: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4423. IL_0088: pop
  4424. IL_0089: ldloc.2
  4425. IL_008a: ldc.i4.0
  4426. IL_008b: ldelem.i4
  4427. IL_008c: box ""int""
  4428. IL_0091: ldc.i4.1
  4429. IL_0092: box ""int""
  4430. IL_0097: call ""bool AllMembers.ValidateValue(object, object)""
  4431. IL_009c: pop
  4432. IL_009d: ldloc.2
  4433. IL_009e: ldc.i4.1
  4434. IL_009f: ldelem.i4
  4435. IL_00a0: box ""int""
  4436. IL_00a5: ldc.i4.0
  4437. IL_00a6: box ""int""
  4438. IL_00ab: call ""bool AllMembers.ValidateValue(object, object)""
  4439. IL_00b0: pop
  4440. IL_00b1: ldloc.0
  4441. IL_00b2: callvirt ""void Windows.Languages.WinRTTest.ISimpleInterfaceImpl.ClearFlag()""
  4442. IL_00b7: ldloc.0
  4443. IL_00b8: callvirt ""int System.Collections.Generic.ICollection<int>.Count.get""
  4444. IL_00bd: pop
  4445. IL_00be: ldloc.0
  4446. IL_00bf: callvirt ""System.Collections.Generic.IEnumerator<int> System.Collections.Generic.IEnumerable<int>.GetEnumerator()""
  4447. IL_00c4: pop
  4448. IL_00c5: ldloc.0
  4449. IL_00c6: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.ISimpleInterfaceImpl.GetFlagState()""
  4450. IL_00cb: ldc.i4.1
  4451. IL_00cc: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4452. IL_00d1: pop
  4453. IL_00d2: ldc.i4.0
  4454. IL_00d3: stloc.3
  4455. IL_00d4: ldloc.0
  4456. IL_00d5: callvirt ""System.Collections.Generic.IEnumerator<int> System.Collections.Generic.IEnumerable<int>.GetEnumerator()""
  4457. IL_00da: stloc.s V_7
  4458. .try
  4459. {
  4460. IL_00dc: br.s IL_00fa
  4461. IL_00de: ldloc.s V_7
  4462. IL_00e0: callvirt ""int System.Collections.Generic.IEnumerator<int>.Current.get""
  4463. IL_00e5: ldloc.3
  4464. IL_00e6: ldc.i4.1
  4465. IL_00e7: add
  4466. IL_00e8: stloc.3
  4467. IL_00e9: box ""int""
  4468. IL_00ee: ldloc.3
  4469. IL_00ef: box ""int""
  4470. IL_00f4: call ""bool AllMembers.ValidateValue(object, object)""
  4471. IL_00f9: pop
  4472. IL_00fa: ldloc.s V_7
  4473. IL_00fc: callvirt ""bool System.Collections.IEnumerator.MoveNext()""
  4474. IL_0101: brtrue.s IL_00de
  4475. IL_0103: leave.s IL_0111
  4476. }
  4477. finally
  4478. {
  4479. IL_0105: ldloc.s V_7
  4480. IL_0107: brfalse.s IL_0110
  4481. IL_0109: ldloc.s V_7
  4482. IL_010b: callvirt ""void System.IDisposable.Dispose()""
  4483. IL_0110: endfinally
  4484. }
  4485. IL_0111: ldloc.3
  4486. IL_0112: box ""int""
  4487. IL_0117: ldc.i4.1
  4488. IL_0118: box ""int""
  4489. IL_011d: call ""bool AllMembers.ValidateValue(object, object)""
  4490. IL_0122: pop
  4491. IL_0123: ldloc.0
  4492. IL_0124: callvirt ""void Windows.Languages.WinRTTest.ISimpleInterfaceImpl.ClearFlag()""
  4493. IL_0129: ldloc.0
  4494. IL_012a: ldc.i4.1
  4495. IL_012b: callvirt ""int System.Collections.Generic.IList<int>.IndexOf(int)""
  4496. IL_0130: stloc.s V_4
  4497. IL_0132: ldloc.0
  4498. IL_0133: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.ISimpleInterfaceImpl.GetFlagState()""
  4499. IL_0138: ldc.i4.5
  4500. IL_0139: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4501. IL_013e: pop
  4502. IL_013f: ldloc.s V_4
  4503. IL_0141: box ""int""
  4504. IL_0146: ldc.i4.0
  4505. IL_0147: box ""int""
  4506. IL_014c: call ""bool AllMembers.ValidateValue(object, object)""
  4507. IL_0151: pop
  4508. IL_0152: ldloc.0
  4509. IL_0153: callvirt ""void Windows.Languages.WinRTTest.ISimpleInterfaceImpl.ClearFlag()""
  4510. IL_0158: ldloc.0
  4511. IL_0159: ldc.i4.1
  4512. IL_015a: ldc.i4.2
  4513. IL_015b: callvirt ""void System.Collections.Generic.IList<int>.Insert(int, int)""
  4514. IL_0160: ldloc.0
  4515. IL_0161: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.ISimpleInterfaceImpl.GetFlagState()""
  4516. IL_0166: ldc.i4.7
  4517. IL_0167: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4518. IL_016c: pop
  4519. IL_016d: ldloc.0
  4520. IL_016e: ldc.i4.1
  4521. IL_016f: callvirt ""int System.Collections.Generic.IList<int>.this[int].get""
  4522. IL_0174: box ""int""
  4523. IL_0179: ldc.i4.2
  4524. IL_017a: box ""int""
  4525. IL_017f: call ""bool AllMembers.ValidateValue(object, object)""
  4526. IL_0184: pop
  4527. IL_0185: ldloc.0
  4528. IL_0186: callvirt ""void Windows.Languages.WinRTTest.ISimpleInterfaceImpl.ClearFlag()""
  4529. IL_018b: ldloc.0
  4530. IL_018c: callvirt ""bool System.Collections.Generic.ICollection<int>.IsReadOnly.get""
  4531. IL_0191: stloc.s V_5
  4532. IL_0193: ldloc.0
  4533. IL_0194: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.ISimpleInterfaceImpl.GetFlagState()""
  4534. IL_0199: ldc.i4.0
  4535. IL_019a: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4536. IL_019f: pop
  4537. IL_01a0: ldloc.s V_5
  4538. IL_01a2: box ""bool""
  4539. IL_01a7: ldc.i4.0
  4540. IL_01a8: box ""bool""
  4541. IL_01ad: call ""bool AllMembers.ValidateValue(object, object)""
  4542. IL_01b2: pop
  4543. IL_01b3: ldloc.0
  4544. IL_01b4: callvirt ""void Windows.Languages.WinRTTest.ISimpleInterfaceImpl.ClearFlag()""
  4545. IL_01b9: ldloc.0
  4546. IL_01ba: ldc.i4.0
  4547. IL_01bb: callvirt ""int System.Collections.Generic.IList<int>.this[int].get""
  4548. IL_01c0: stloc.s V_6
  4549. IL_01c2: ldloc.0
  4550. IL_01c3: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.ISimpleInterfaceImpl.GetFlagState()""
  4551. IL_01c8: ldc.i4.2
  4552. IL_01c9: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4553. IL_01ce: pop
  4554. IL_01cf: ldloc.s V_6
  4555. IL_01d1: box ""int""
  4556. IL_01d6: ldc.i4.1
  4557. IL_01d7: box ""int""
  4558. IL_01dc: call ""bool AllMembers.ValidateValue(object, object)""
  4559. IL_01e1: pop
  4560. IL_01e2: ldloc.0
  4561. IL_01e3: callvirt ""void Windows.Languages.WinRTTest.ISimpleInterfaceImpl.ClearFlag()""
  4562. IL_01e8: ldloc.0
  4563. IL_01e9: ldc.i4.1
  4564. IL_01ea: callvirt ""int System.Collections.Generic.IList<int>.this[int].get""
  4565. IL_01ef: stloc.s V_6
  4566. IL_01f1: ldloc.0
  4567. IL_01f2: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.ISimpleInterfaceImpl.GetFlagState()""
  4568. IL_01f7: ldc.i4.2
  4569. IL_01f8: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4570. IL_01fd: pop
  4571. IL_01fe: ldloc.s V_6
  4572. IL_0200: box ""int""
  4573. IL_0205: ldc.i4.2
  4574. IL_0206: box ""int""
  4575. IL_020b: call ""bool AllMembers.ValidateValue(object, object)""
  4576. IL_0210: pop
  4577. IL_0211: ldloc.0
  4578. IL_0212: callvirt ""void Windows.Languages.WinRTTest.ISimpleInterfaceImpl.ClearFlag()""
  4579. IL_0217: ldloc.0
  4580. IL_0218: ldc.i4.1
  4581. IL_0219: callvirt ""bool System.Collections.Generic.ICollection<int>.Remove(int)""
  4582. IL_021e: pop
  4583. IL_021f: ldloc.0
  4584. IL_0220: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.ISimpleInterfaceImpl.GetFlagState()""
  4585. IL_0225: ldc.i4.8
  4586. IL_0226: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4587. IL_022b: pop
  4588. IL_022c: ldloc.0
  4589. IL_022d: callvirt ""int System.Collections.Generic.ICollection<int>.Count.get""
  4590. IL_0232: box ""int""
  4591. IL_0237: ldc.i4.1
  4592. IL_0238: box ""int""
  4593. IL_023d: call ""bool AllMembers.ValidateValue(object, object)""
  4594. IL_0242: pop
  4595. IL_0243: ldloc.0
  4596. IL_0244: callvirt ""void Windows.Languages.WinRTTest.ISimpleInterfaceImpl.ClearFlag()""
  4597. IL_0249: ldloc.0
  4598. IL_024a: ldc.i4.0
  4599. IL_024b: callvirt ""void System.Collections.Generic.IList<int>.RemoveAt(int)""
  4600. IL_0250: ldloc.0
  4601. IL_0251: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.ISimpleInterfaceImpl.GetFlagState()""
  4602. IL_0256: ldc.i4.8
  4603. IL_0257: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4604. IL_025c: pop
  4605. IL_025d: ldloc.0
  4606. IL_025e: callvirt ""int System.Collections.Generic.ICollection<int>.Count.get""
  4607. IL_0263: box ""int""
  4608. IL_0268: ldc.i4.0
  4609. IL_0269: box ""int""
  4610. IL_026e: call ""bool AllMembers.ValidateValue(object, object)""
  4611. IL_0273: pop
  4612. IL_0274: ldloc.0
  4613. IL_0275: ldc.i4.1
  4614. IL_0276: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4615. IL_027b: ldloc.0
  4616. IL_027c: ldc.i4.2
  4617. IL_027d: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4618. IL_0282: ldloc.0
  4619. IL_0283: callvirt ""void Windows.Languages.WinRTTest.ISimpleInterfaceImpl.ClearFlag()""
  4620. IL_0288: ldloc.0
  4621. IL_0289: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.ISimpleInterfaceImpl.GetFlagState()""
  4622. IL_028e: ldc.i4.s 11
  4623. IL_0290: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4624. IL_0295: pop
  4625. IL_0296: ldloc.0
  4626. IL_0297: callvirt ""int System.Collections.Generic.ICollection<int>.Count.get""
  4627. IL_029c: box ""int""
  4628. IL_02a1: ldc.i4.0
  4629. IL_02a2: box ""int""
  4630. IL_02a7: call ""bool AllMembers.ValidateValue(object, object)""
  4631. IL_02ac: pop
  4632. IL_02ad: ret
  4633. }");
  4634. }
  4635. [Fact]
  4636. public void LegacyCollectionTest06()
  4637. {
  4638. var source =
  4639. @"using Windows.Languages.WinRTTest;
  4640. using System.Collections.Generic;
  4641. using System.Reflection;
  4642. using System.Linq.Expressions;
  4643. using System;
  4644. using System.Linq;
  4645. class AllMembers
  4646. {
  4647. private static int FailedCount = 0;
  4648. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  4649. {
  4650. var temp = Console.ForegroundColor;
  4651. if (actual != expected)
  4652. {
  4653. FailedCount++;
  4654. Console.ForegroundColor = ConsoleColor.Red;
  4655. Console.Write(""FAIL: "");
  4656. }
  4657. else
  4658. {
  4659. Console.ForegroundColor = ConsoleColor.Green;
  4660. Console.Write(""PASS: "");
  4661. }
  4662. Console.ForegroundColor = temp;
  4663. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  4664. return actual == expected;
  4665. }
  4666. private static bool ValidateValue(object actual, object expected)
  4667. {
  4668. var temp = Console.ForegroundColor;
  4669. if (actual.ToString() != expected.ToString())
  4670. {
  4671. FailedCount++;
  4672. Console.ForegroundColor = ConsoleColor.Red;
  4673. Console.Write(""FAIL: "");
  4674. }
  4675. else
  4676. {
  4677. Console.ForegroundColor = ConsoleColor.Green;
  4678. Console.Write(""PASS: "");
  4679. }
  4680. Console.ForegroundColor = temp;
  4681. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  4682. return actual.ToString() == expected.ToString();
  4683. }
  4684. static void TestCollectionInitializers()
  4685. {
  4686. var v = new IVectorInt() { 1, 2, 3, 4, 5 };
  4687. ValidateValue(v.Count, 5);
  4688. var m = new IMapIntInt() { { 1, 2 }, { 2, 3 } };
  4689. ValidateValue(m.Count, 2);
  4690. var t = new Dictionary<int, IVectorInt>()
  4691. {
  4692. {1, new IVectorInt(){1, 2, 3}},
  4693. {2, new IVectorInt(){4, 5, 6}}
  4694. };
  4695. ValidateValue(t[1][2], 3);
  4696. ValidateValue(t[2][2], 6);
  4697. }
  4698. static int Main()
  4699. {
  4700. TestCollectionInitializers();
  4701. Console.WriteLine(FailedCount);
  4702. return FailedCount;
  4703. }
  4704. }";
  4705. var verifier = CompileAndVerify(source,
  4706. additionalRefs: LegacyRefs,
  4707. emitOptions: EmitOptions.RefEmitBug,
  4708. verify: false);
  4709. verifier.VerifyDiagnostics(
  4710. // (3,1): info CS8019: Unnecessary using directive.
  4711. // using System.Reflection;
  4712. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  4713. // (4,1): info CS8019: Unnecessary using directive.
  4714. // using System.Linq.Expressions;
  4715. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  4716. // (6,1): info CS8019: Unnecessary using directive.
  4717. // using System.Linq;
  4718. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"));
  4719. verifier.VerifyIL("AllMembers.TestCollectionInitializers",
  4720. @"{
  4721. // Code size 236 (0xec)
  4722. .maxstack 6
  4723. IL_0000: newobj ""Windows.Languages.WinRTTest.IVectorInt..ctor()""
  4724. IL_0005: dup
  4725. IL_0006: ldc.i4.1
  4726. IL_0007: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4727. IL_000c: dup
  4728. IL_000d: ldc.i4.2
  4729. IL_000e: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4730. IL_0013: dup
  4731. IL_0014: ldc.i4.3
  4732. IL_0015: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4733. IL_001a: dup
  4734. IL_001b: ldc.i4.4
  4735. IL_001c: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4736. IL_0021: dup
  4737. IL_0022: ldc.i4.5
  4738. IL_0023: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4739. IL_0028: callvirt ""int System.Collections.Generic.ICollection<int>.Count.get""
  4740. IL_002d: box ""int""
  4741. IL_0032: ldc.i4.5
  4742. IL_0033: box ""int""
  4743. IL_0038: call ""bool AllMembers.ValidateValue(object, object)""
  4744. IL_003d: pop
  4745. IL_003e: newobj ""Windows.Languages.WinRTTest.IMapIntInt..ctor()""
  4746. IL_0043: dup
  4747. IL_0044: ldc.i4.1
  4748. IL_0045: ldc.i4.2
  4749. IL_0046: callvirt ""void System.Collections.Generic.IDictionary<int, int>.Add(int, int)""
  4750. IL_004b: dup
  4751. IL_004c: ldc.i4.2
  4752. IL_004d: ldc.i4.3
  4753. IL_004e: callvirt ""void System.Collections.Generic.IDictionary<int, int>.Add(int, int)""
  4754. IL_0053: callvirt ""int System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<int, int>>.Count.get""
  4755. IL_0058: box ""int""
  4756. IL_005d: ldc.i4.2
  4757. IL_005e: box ""int""
  4758. IL_0063: call ""bool AllMembers.ValidateValue(object, object)""
  4759. IL_0068: pop
  4760. IL_0069: newobj ""System.Collections.Generic.Dictionary<int, Windows.Languages.WinRTTest.IVectorInt>..ctor()""
  4761. IL_006e: dup
  4762. IL_006f: ldc.i4.1
  4763. IL_0070: newobj ""Windows.Languages.WinRTTest.IVectorInt..ctor()""
  4764. IL_0075: dup
  4765. IL_0076: ldc.i4.1
  4766. IL_0077: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4767. IL_007c: dup
  4768. IL_007d: ldc.i4.2
  4769. IL_007e: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4770. IL_0083: dup
  4771. IL_0084: ldc.i4.3
  4772. IL_0085: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4773. IL_008a: callvirt ""void System.Collections.Generic.Dictionary<int, Windows.Languages.WinRTTest.IVectorInt>.Add(int, Windows.Languages.WinRTTest.IVectorInt)""
  4774. IL_008f: dup
  4775. IL_0090: ldc.i4.2
  4776. IL_0091: newobj ""Windows.Languages.WinRTTest.IVectorInt..ctor()""
  4777. IL_0096: dup
  4778. IL_0097: ldc.i4.4
  4779. IL_0098: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4780. IL_009d: dup
  4781. IL_009e: ldc.i4.5
  4782. IL_009f: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4783. IL_00a4: dup
  4784. IL_00a5: ldc.i4.6
  4785. IL_00a6: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4786. IL_00ab: callvirt ""void System.Collections.Generic.Dictionary<int, Windows.Languages.WinRTTest.IVectorInt>.Add(int, Windows.Languages.WinRTTest.IVectorInt)""
  4787. IL_00b0: dup
  4788. IL_00b1: ldc.i4.1
  4789. IL_00b2: callvirt ""Windows.Languages.WinRTTest.IVectorInt System.Collections.Generic.Dictionary<int, Windows.Languages.WinRTTest.IVectorInt>.this[int].get""
  4790. IL_00b7: ldc.i4.2
  4791. IL_00b8: callvirt ""int System.Collections.Generic.IList<int>.this[int].get""
  4792. IL_00bd: box ""int""
  4793. IL_00c2: ldc.i4.3
  4794. IL_00c3: box ""int""
  4795. IL_00c8: call ""bool AllMembers.ValidateValue(object, object)""
  4796. IL_00cd: pop
  4797. IL_00ce: ldc.i4.2
  4798. IL_00cf: callvirt ""Windows.Languages.WinRTTest.IVectorInt System.Collections.Generic.Dictionary<int, Windows.Languages.WinRTTest.IVectorInt>.this[int].get""
  4799. IL_00d4: ldc.i4.2
  4800. IL_00d5: callvirt ""int System.Collections.Generic.IList<int>.this[int].get""
  4801. IL_00da: box ""int""
  4802. IL_00df: ldc.i4.6
  4803. IL_00e0: box ""int""
  4804. IL_00e5: call ""bool AllMembers.ValidateValue(object, object)""
  4805. IL_00ea: pop
  4806. IL_00eb: ret
  4807. }");
  4808. }
  4809. [Fact]
  4810. public void LegacyCollectionTest07()
  4811. {
  4812. var source =
  4813. @"using Windows.Languages.WinRTTest;
  4814. using System.Collections.Generic;
  4815. using System.Reflection;
  4816. using System.Linq.Expressions;
  4817. using System;
  4818. using System.Linq;
  4819. class AllMembers
  4820. {
  4821. private static int FailedCount = 0;
  4822. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  4823. {
  4824. var temp = Console.ForegroundColor;
  4825. if (actual != expected)
  4826. {
  4827. FailedCount++;
  4828. Console.ForegroundColor = ConsoleColor.Red;
  4829. Console.Write(""FAIL: "");
  4830. }
  4831. else
  4832. {
  4833. Console.ForegroundColor = ConsoleColor.Green;
  4834. Console.Write(""PASS: "");
  4835. }
  4836. Console.ForegroundColor = temp;
  4837. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  4838. return actual == expected;
  4839. }
  4840. private static bool ValidateValue(object actual, object expected)
  4841. {
  4842. var temp = Console.ForegroundColor;
  4843. if (actual.ToString() != expected.ToString())
  4844. {
  4845. FailedCount++;
  4846. Console.ForegroundColor = ConsoleColor.Red;
  4847. Console.Write(""FAIL: "");
  4848. }
  4849. else
  4850. {
  4851. Console.ForegroundColor = ConsoleColor.Green;
  4852. Console.Write(""PASS: "");
  4853. }
  4854. Console.ForegroundColor = temp;
  4855. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  4856. return actual.ToString() == expected.ToString();
  4857. }
  4858. static void TestExpressionTreeCompiler()
  4859. {
  4860. var v = new IVectorInt();
  4861. try
  4862. {
  4863. // Dev11:205875
  4864. Console.WriteLine(""Dev11:205875"");
  4865. ValidateValue(true, true);
  4866. Expression<Action<int>> expr = (val) => v.Add(val);
  4867. v.ClearFlag();
  4868. expr.Compile()(1);
  4869. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  4870. }
  4871. catch (Exception e)
  4872. {
  4873. Console.WriteLine(""ExprTree compiler"");
  4874. Console.WriteLine(e.Message);
  4875. }
  4876. }
  4877. static int Main()
  4878. {
  4879. TestExpressionTreeCompiler();
  4880. Console.WriteLine(FailedCount);
  4881. return FailedCount;
  4882. }
  4883. }";
  4884. var verifier = CompileAndVerify(source,
  4885. additionalRefs: LegacyRefs,
  4886. emitOptions: EmitOptions.RefEmitBug,
  4887. verify: false);
  4888. verifier.VerifyDiagnostics(
  4889. // (2,1): info CS8019: Unnecessary using directive.
  4890. // using System.Collections.Generic;
  4891. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections.Generic;"),
  4892. // (3,1): info CS8019: Unnecessary using directive.
  4893. // using System.Reflection;
  4894. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  4895. // (6,1): info CS8019: Unnecessary using directive.
  4896. // using System.Linq;
  4897. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"));
  4898. verifier.VerifyIL("AllMembers.TestExpressionTreeCompiler",
  4899. @"
  4900. {
  4901. // Code size 213 (0xd5)
  4902. .maxstack 6
  4903. .locals init (AllMembers.<>c__DisplayClass0 V_0, //CS$<>8__locals0
  4904. System.Linq.Expressions.ParameterExpression V_1)
  4905. IL_0000: newobj ""AllMembers.<>c__DisplayClass0..ctor()""
  4906. IL_0005: stloc.0
  4907. IL_0006: ldloc.0
  4908. IL_0007: newobj ""Windows.Languages.WinRTTest.IVectorInt..ctor()""
  4909. IL_000c: stfld ""Windows.Languages.WinRTTest.IVectorInt AllMembers.<>c__DisplayClass0.v""
  4910. .try
  4911. {
  4912. IL_0011: ldstr ""Dev11:205875""
  4913. IL_0016: call ""void System.Console.WriteLine(string)""
  4914. IL_001b: ldc.i4.1
  4915. IL_001c: box ""bool""
  4916. IL_0021: ldc.i4.1
  4917. IL_0022: box ""bool""
  4918. IL_0027: call ""bool AllMembers.ValidateValue(object, object)""
  4919. IL_002c: pop
  4920. IL_002d: ldtoken ""int""
  4921. IL_0032: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
  4922. IL_0037: ldstr ""val""
  4923. IL_003c: call ""System.Linq.Expressions.ParameterExpression System.Linq.Expressions.Expression.Parameter(System.Type, string)""
  4924. IL_0041: stloc.1
  4925. IL_0042: ldloc.0
  4926. IL_0043: ldtoken ""AllMembers.<>c__DisplayClass0""
  4927. IL_0048: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
  4928. IL_004d: call ""System.Linq.Expressions.ConstantExpression System.Linq.Expressions.Expression.Constant(object, System.Type)""
  4929. IL_0052: ldtoken ""Windows.Languages.WinRTTest.IVectorInt AllMembers.<>c__DisplayClass0.v""
  4930. IL_0057: call ""System.Reflection.FieldInfo System.Reflection.FieldInfo.GetFieldFromHandle(System.RuntimeFieldHandle)""
  4931. IL_005c: call ""System.Linq.Expressions.MemberExpression System.Linq.Expressions.Expression.Field(System.Linq.Expressions.Expression, System.Reflection.FieldInfo)""
  4932. IL_0061: ldtoken ""void System.Collections.Generic.ICollection<int>.Add(int)""
  4933. IL_0066: ldtoken ""System.Collections.Generic.ICollection<int>""
  4934. IL_006b: call ""System.Reflection.MethodBase System.Reflection.MethodBase.GetMethodFromHandle(System.RuntimeMethodHandle, System.RuntimeTypeHandle)""
  4935. IL_0070: castclass ""System.Reflection.MethodInfo""
  4936. IL_0075: ldc.i4.1
  4937. IL_0076: newarr ""System.Linq.Expressions.Expression""
  4938. IL_007b: dup
  4939. IL_007c: ldc.i4.0
  4940. IL_007d: ldloc.1
  4941. IL_007e: stelem.ref
  4942. IL_007f: call ""System.Linq.Expressions.MethodCallExpression System.Linq.Expressions.Expression.Call(System.Linq.Expressions.Expression, System.Reflection.MethodInfo, params System.Linq.Expressions.Expression[])""
  4943. IL_0084: ldc.i4.1
  4944. IL_0085: newarr ""System.Linq.Expressions.ParameterExpression""
  4945. IL_008a: dup
  4946. IL_008b: ldc.i4.0
  4947. IL_008c: ldloc.1
  4948. IL_008d: stelem.ref
  4949. IL_008e: call ""System.Linq.Expressions.Expression<System.Action<int>> System.Linq.Expressions.Expression.Lambda<System.Action<int>>(System.Linq.Expressions.Expression, params System.Linq.Expressions.ParameterExpression[])""
  4950. IL_0093: ldloc.0
  4951. IL_0094: ldfld ""Windows.Languages.WinRTTest.IVectorInt AllMembers.<>c__DisplayClass0.v""
  4952. IL_0099: callvirt ""void Windows.Languages.WinRTTest.IVectorInt.ClearFlag()""
  4953. IL_009e: callvirt ""System.Action<int> System.Linq.Expressions.Expression<System.Action<int>>.Compile()""
  4954. IL_00a3: ldc.i4.1
  4955. IL_00a4: callvirt ""void System.Action<int>.Invoke(int)""
  4956. IL_00a9: ldloc.0
  4957. IL_00aa: ldfld ""Windows.Languages.WinRTTest.IVectorInt AllMembers.<>c__DisplayClass0.v""
  4958. IL_00af: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorInt.GetFlagState()""
  4959. IL_00b4: ldc.i4.s 9
  4960. IL_00b6: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  4961. IL_00bb: pop
  4962. IL_00bc: leave.s IL_00d4
  4963. }
  4964. catch System.Exception
  4965. {
  4966. IL_00be: ldstr ""ExprTree compiler""
  4967. IL_00c3: call ""void System.Console.WriteLine(string)""
  4968. IL_00c8: callvirt ""string System.Exception.Message.get""
  4969. IL_00cd: call ""void System.Console.WriteLine(string)""
  4970. IL_00d2: leave.s IL_00d4
  4971. }
  4972. IL_00d4: ret
  4973. }");
  4974. }
  4975. [Fact]
  4976. public void LegacyCollectionTest09()
  4977. {
  4978. var source =
  4979. @"using Windows.Languages.WinRTTest;
  4980. using System.Collections.Generic;
  4981. using System.Reflection;
  4982. using System.Linq.Expressions;
  4983. using System;
  4984. using System.Linq;
  4985. class AllMembers
  4986. {
  4987. private static int FailedCount = 0;
  4988. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  4989. {
  4990. var temp = Console.ForegroundColor;
  4991. if (actual != expected)
  4992. {
  4993. FailedCount++;
  4994. Console.ForegroundColor = ConsoleColor.Red;
  4995. Console.Write(""FAIL: "");
  4996. }
  4997. else
  4998. {
  4999. Console.ForegroundColor = ConsoleColor.Green;
  5000. Console.Write(""PASS: "");
  5001. }
  5002. Console.ForegroundColor = temp;
  5003. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  5004. return actual == expected;
  5005. }
  5006. private static bool ValidateValue(object actual, object expected)
  5007. {
  5008. var temp = Console.ForegroundColor;
  5009. if (actual.ToString() != expected.ToString())
  5010. {
  5011. FailedCount++;
  5012. Console.ForegroundColor = ConsoleColor.Red;
  5013. Console.Write(""FAIL: "");
  5014. }
  5015. else
  5016. {
  5017. Console.ForegroundColor = ConsoleColor.Green;
  5018. Console.Write(""PASS: "");
  5019. }
  5020. Console.ForegroundColor = temp;
  5021. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  5022. return actual.ToString() == expected.ToString();
  5023. }
  5024. static void TestLINQ()
  5025. {
  5026. var v = new IVectorInt() { 1, 2, 3, 4, 5 };
  5027. ValidateValue(v.Count, 5);
  5028. // Use methods on v inside query operator
  5029. v.ClearFlag();
  5030. var rez = from e in new int[] { 2, 4, 6, 10, 12 }
  5031. where v.Contains(e)
  5032. select e;
  5033. rez = rez.ToList();
  5034. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  5035. ValidateValue(rez.Count(), 2);
  5036. ValidateValue(rez.ToArray()[0], 2);
  5037. ValidateValue(rez.ToArray()[1], 4);
  5038. //Use v as source to linq query
  5039. rez = from e in v
  5040. where e % 2 == 0
  5041. select e;
  5042. rez = rez.ToList();
  5043. ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First);
  5044. ValidateValue(rez.Count(), 2);
  5045. //over IQueryable
  5046. try
  5047. {
  5048. Console.WriteLine(""Dev11:205875"");
  5049. ValidateValue(false, false);
  5050. //var list = new List<int>() { 1, 2, 3, 4, 5 };
  5051. //var otherRez = from e in list.AsQueryable()
  5052. // where v.Contains(e)
  5053. // select e;
  5054. //var vals = otherRez.ToArray();
  5055. }
  5056. catch (ArgumentException e)
  5057. {
  5058. Console.WriteLine(""TestLINQ"");
  5059. Console.WriteLine(e.Message);
  5060. }
  5061. }
  5062. static int Main()
  5063. {
  5064. TestLINQ();
  5065. Console.WriteLine(FailedCount);
  5066. return FailedCount;
  5067. }
  5068. }";
  5069. var verifier = CompileAndVerify(source,
  5070. additionalRefs: LegacyRefs,
  5071. emitOptions: EmitOptions.RefEmitBug,
  5072. verify: false);
  5073. verifier.VerifyDiagnostics(
  5074. // (2,1): info CS8019: Unnecessary using directive.
  5075. // using System.Collections.Generic;
  5076. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections.Generic;"),
  5077. // (3,1): info CS8019: Unnecessary using directive.
  5078. // using System.Reflection;
  5079. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  5080. // (4,1): info CS8019: Unnecessary using directive.
  5081. // using System.Linq.Expressions;
  5082. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"));
  5083. verifier.VerifyIL("AllMembers.TestLINQ",
  5084. @"
  5085. {
  5086. // Code size 356 (0x164)
  5087. .maxstack 4
  5088. .locals init (AllMembers.<>c__DisplayClass0 V_0) //CS$<>8__locals0
  5089. IL_0000: newobj ""AllMembers.<>c__DisplayClass0..ctor()""
  5090. IL_0005: stloc.0
  5091. IL_0006: ldloc.0
  5092. IL_0007: newobj ""Windows.Languages.WinRTTest.IVectorInt..ctor()""
  5093. IL_000c: dup
  5094. IL_000d: ldc.i4.1
  5095. IL_000e: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  5096. IL_0013: dup
  5097. IL_0014: ldc.i4.2
  5098. IL_0015: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  5099. IL_001a: dup
  5100. IL_001b: ldc.i4.3
  5101. IL_001c: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  5102. IL_0021: dup
  5103. IL_0022: ldc.i4.4
  5104. IL_0023: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  5105. IL_0028: dup
  5106. IL_0029: ldc.i4.5
  5107. IL_002a: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  5108. IL_002f: stfld ""Windows.Languages.WinRTTest.IVectorInt AllMembers.<>c__DisplayClass0.v""
  5109. IL_0034: ldloc.0
  5110. IL_0035: ldfld ""Windows.Languages.WinRTTest.IVectorInt AllMembers.<>c__DisplayClass0.v""
  5111. IL_003a: callvirt ""int System.Collections.Generic.ICollection<int>.Count.get""
  5112. IL_003f: box ""int""
  5113. IL_0044: ldc.i4.5
  5114. IL_0045: box ""int""
  5115. IL_004a: call ""bool AllMembers.ValidateValue(object, object)""
  5116. IL_004f: pop
  5117. IL_0050: ldloc.0
  5118. IL_0051: ldfld ""Windows.Languages.WinRTTest.IVectorInt AllMembers.<>c__DisplayClass0.v""
  5119. IL_0056: callvirt ""void Windows.Languages.WinRTTest.IVectorInt.ClearFlag()""
  5120. IL_005b: ldc.i4.5
  5121. IL_005c: newarr ""int""
  5122. IL_0061: dup
  5123. IL_0062: ldtoken ""<PrivateImplementationDetails>.__StaticArrayInitTypeSize=20 <PrivateImplementationDetails>.$$method0x6000001-0""
  5124. IL_0067: call ""void System.Runtime.CompilerServices.RuntimeHelpers.InitializeArray(System.Array, System.RuntimeFieldHandle)""
  5125. IL_006c: ldloc.0
  5126. IL_006d: ldftn ""bool AllMembers.<>c__DisplayClass0.<TestLINQ>b__1(int)""
  5127. IL_0073: newobj ""System.Func<int, bool>..ctor(object, System.IntPtr)""
  5128. IL_0078: call ""System.Collections.Generic.IEnumerable<int> System.Linq.Enumerable.Where<int>(System.Collections.Generic.IEnumerable<int>, System.Func<int, bool>)""
  5129. IL_007d: call ""System.Collections.Generic.List<int> System.Linq.Enumerable.ToList<int>(System.Collections.Generic.IEnumerable<int>)""
  5130. IL_0082: ldloc.0
  5131. IL_0083: ldfld ""Windows.Languages.WinRTTest.IVectorInt AllMembers.<>c__DisplayClass0.v""
  5132. IL_0088: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorInt.GetFlagState()""
  5133. IL_008d: ldc.i4.5
  5134. IL_008e: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5135. IL_0093: pop
  5136. IL_0094: dup
  5137. IL_0095: call ""int System.Linq.Enumerable.Count<int>(System.Collections.Generic.IEnumerable<int>)""
  5138. IL_009a: box ""int""
  5139. IL_009f: ldc.i4.2
  5140. IL_00a0: box ""int""
  5141. IL_00a5: call ""bool AllMembers.ValidateValue(object, object)""
  5142. IL_00aa: pop
  5143. IL_00ab: dup
  5144. IL_00ac: call ""int[] System.Linq.Enumerable.ToArray<int>(System.Collections.Generic.IEnumerable<int>)""
  5145. IL_00b1: ldc.i4.0
  5146. IL_00b2: ldelem.i4
  5147. IL_00b3: box ""int""
  5148. IL_00b8: ldc.i4.2
  5149. IL_00b9: box ""int""
  5150. IL_00be: call ""bool AllMembers.ValidateValue(object, object)""
  5151. IL_00c3: pop
  5152. IL_00c4: call ""int[] System.Linq.Enumerable.ToArray<int>(System.Collections.Generic.IEnumerable<int>)""
  5153. IL_00c9: ldc.i4.1
  5154. IL_00ca: ldelem.i4
  5155. IL_00cb: box ""int""
  5156. IL_00d0: ldc.i4.4
  5157. IL_00d1: box ""int""
  5158. IL_00d6: call ""bool AllMembers.ValidateValue(object, object)""
  5159. IL_00db: pop
  5160. IL_00dc: ldloc.0
  5161. IL_00dd: ldfld ""Windows.Languages.WinRTTest.IVectorInt AllMembers.<>c__DisplayClass0.v""
  5162. IL_00e2: ldsfld ""System.Func<int, bool> AllMembers.CS$<>9__CachedAnonymousMethodDelegate3""
  5163. IL_00e7: dup
  5164. IL_00e8: brtrue.s IL_00fd
  5165. IL_00ea: pop
  5166. IL_00eb: ldnull
  5167. IL_00ec: ldftn ""bool AllMembers.<TestLINQ>b__2(object, int)""
  5168. IL_00f2: newobj ""System.Func<int, bool>..ctor(object, System.IntPtr)""
  5169. IL_00f7: dup
  5170. IL_00f8: stsfld ""System.Func<int, bool> AllMembers.CS$<>9__CachedAnonymousMethodDelegate3""
  5171. IL_00fd: call ""System.Collections.Generic.IEnumerable<int> System.Linq.Enumerable.Where<int>(System.Collections.Generic.IEnumerable<int>, System.Func<int, bool>)""
  5172. IL_0102: call ""System.Collections.Generic.List<int> System.Linq.Enumerable.ToList<int>(System.Collections.Generic.IEnumerable<int>)""
  5173. IL_0107: ldloc.0
  5174. IL_0108: ldfld ""Windows.Languages.WinRTTest.IVectorInt AllMembers.<>c__DisplayClass0.v""
  5175. IL_010d: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorInt.GetFlagState()""
  5176. IL_0112: ldc.i4.1
  5177. IL_0113: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5178. IL_0118: pop
  5179. IL_0119: call ""int System.Linq.Enumerable.Count<int>(System.Collections.Generic.IEnumerable<int>)""
  5180. IL_011e: box ""int""
  5181. IL_0123: ldc.i4.2
  5182. IL_0124: box ""int""
  5183. IL_0129: call ""bool AllMembers.ValidateValue(object, object)""
  5184. IL_012e: pop
  5185. .try
  5186. {
  5187. IL_012f: ldstr ""Dev11:205875""
  5188. IL_0134: call ""void System.Console.WriteLine(string)""
  5189. IL_0139: ldc.i4.0
  5190. IL_013a: box ""bool""
  5191. IL_013f: ldc.i4.0
  5192. IL_0140: box ""bool""
  5193. IL_0145: call ""bool AllMembers.ValidateValue(object, object)""
  5194. IL_014a: pop
  5195. IL_014b: leave.s IL_0163
  5196. }
  5197. catch System.ArgumentException
  5198. {
  5199. IL_014d: ldstr ""TestLINQ""
  5200. IL_0152: call ""void System.Console.WriteLine(string)""
  5201. IL_0157: callvirt ""string System.Exception.Message.get""
  5202. IL_015c: call ""void System.Console.WriteLine(string)""
  5203. IL_0161: leave.s IL_0163
  5204. }
  5205. IL_0163: ret
  5206. }
  5207. ");
  5208. }
  5209. [Fact]
  5210. public void LegacyCollectionTest10()
  5211. {
  5212. var source =
  5213. @"using Windows.Languages.WinRTTest;
  5214. using System.Collections.Generic;
  5215. using System.Reflection;
  5216. using System.Linq.Expressions;
  5217. using System;
  5218. using System.Linq;
  5219. class AllMembers
  5220. {
  5221. private static int FailedCount = 0;
  5222. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  5223. {
  5224. var temp = Console.ForegroundColor;
  5225. if (actual != expected)
  5226. {
  5227. FailedCount++;
  5228. Console.ForegroundColor = ConsoleColor.Red;
  5229. Console.Write(""FAIL: "");
  5230. }
  5231. else
  5232. {
  5233. Console.ForegroundColor = ConsoleColor.Green;
  5234. Console.Write(""PASS: "");
  5235. }
  5236. Console.ForegroundColor = temp;
  5237. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  5238. return actual == expected;
  5239. }
  5240. private static bool ValidateValue(object actual, object expected)
  5241. {
  5242. var temp = Console.ForegroundColor;
  5243. if (actual.ToString() != expected.ToString())
  5244. {
  5245. FailedCount++;
  5246. Console.ForegroundColor = ConsoleColor.Red;
  5247. Console.Write(""FAIL: "");
  5248. }
  5249. else
  5250. {
  5251. Console.ForegroundColor = ConsoleColor.Green;
  5252. Console.Write(""PASS: "");
  5253. }
  5254. Console.ForegroundColor = temp;
  5255. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  5256. return actual.ToString() == expected.ToString();
  5257. }
  5258. static void TestNamedArguments()
  5259. {
  5260. var v = new IVectorInt();
  5261. v.ClearFlag();
  5262. v.Add(item: 1);
  5263. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  5264. ValidateValue(v.Count, 1);
  5265. var m = new IMapIntInt();
  5266. m.ClearFlag();
  5267. m.Add(key: 1, value: 1);
  5268. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
  5269. m.ClearFlag();
  5270. m.Add(2, value: 2);
  5271. ValidateMethod(m.GetFlagState(), TestMethodCalled.IMap_Insert);
  5272. }
  5273. static int Main()
  5274. {
  5275. TestNamedArguments();
  5276. Console.WriteLine(FailedCount);
  5277. return FailedCount;
  5278. }
  5279. }";
  5280. var verifier = CompileAndVerify(source,
  5281. additionalRefs: LegacyRefs,
  5282. emitOptions: EmitOptions.RefEmitBug,
  5283. verify: false);
  5284. verifier.VerifyDiagnostics(
  5285. // (2,1): info CS8019: Unnecessary using directive.
  5286. // using System.Collections.Generic;
  5287. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections.Generic;"),
  5288. // (3,1): info CS8019: Unnecessary using directive.
  5289. // using System.Reflection;
  5290. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  5291. // (4,1): info CS8019: Unnecessary using directive.
  5292. // using System.Linq.Expressions;
  5293. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  5294. // (6,1): info CS8019: Unnecessary using directive.
  5295. // using System.Linq;
  5296. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"));
  5297. verifier.VerifyIL("AllMembers.TestNamedArguments",
  5298. @"{
  5299. // Code size 115 (0x73)
  5300. .maxstack 4
  5301. IL_0000: newobj ""Windows.Languages.WinRTTest.IVectorInt..ctor()""
  5302. IL_0005: dup
  5303. IL_0006: callvirt ""void Windows.Languages.WinRTTest.IVectorInt.ClearFlag()""
  5304. IL_000b: dup
  5305. IL_000c: ldc.i4.1
  5306. IL_000d: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  5307. IL_0012: dup
  5308. IL_0013: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorInt.GetFlagState()""
  5309. IL_0018: ldc.i4.s 9
  5310. IL_001a: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5311. IL_001f: pop
  5312. IL_0020: callvirt ""int System.Collections.Generic.ICollection<int>.Count.get""
  5313. IL_0025: box ""int""
  5314. IL_002a: ldc.i4.1
  5315. IL_002b: box ""int""
  5316. IL_0030: call ""bool AllMembers.ValidateValue(object, object)""
  5317. IL_0035: pop
  5318. IL_0036: newobj ""Windows.Languages.WinRTTest.IMapIntInt..ctor()""
  5319. IL_003b: dup
  5320. IL_003c: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  5321. IL_0041: dup
  5322. IL_0042: ldc.i4.1
  5323. IL_0043: ldc.i4.1
  5324. IL_0044: callvirt ""void System.Collections.Generic.IDictionary<int, int>.Add(int, int)""
  5325. IL_0049: dup
  5326. IL_004a: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  5327. IL_004f: ldc.i4.s 21
  5328. IL_0051: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5329. IL_0056: pop
  5330. IL_0057: dup
  5331. IL_0058: callvirt ""void Windows.Languages.WinRTTest.IMapIntInt.ClearFlag()""
  5332. IL_005d: dup
  5333. IL_005e: ldc.i4.2
  5334. IL_005f: ldc.i4.2
  5335. IL_0060: callvirt ""void System.Collections.Generic.IDictionary<int, int>.Add(int, int)""
  5336. IL_0065: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IMapIntInt.GetFlagState()""
  5337. IL_006a: ldc.i4.s 21
  5338. IL_006c: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5339. IL_0071: pop
  5340. IL_0072: ret
  5341. }");
  5342. }
  5343. [Fact]
  5344. public void LegacyCollectionTest11()
  5345. {
  5346. var source =
  5347. @"using Windows.Languages.WinRTTest;
  5348. using System.Collections.Generic;
  5349. using System.Reflection;
  5350. using System.Linq.Expressions;
  5351. using System;
  5352. using System.Linq;
  5353. class AllMembers
  5354. {
  5355. private static int FailedCount = 0;
  5356. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  5357. {
  5358. var temp = Console.ForegroundColor;
  5359. if (actual != expected)
  5360. {
  5361. FailedCount++;
  5362. Console.ForegroundColor = ConsoleColor.Red;
  5363. Console.Write(""FAIL: "");
  5364. }
  5365. else
  5366. {
  5367. Console.ForegroundColor = ConsoleColor.Green;
  5368. Console.Write(""PASS: "");
  5369. }
  5370. Console.ForegroundColor = temp;
  5371. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  5372. return actual == expected;
  5373. }
  5374. private static bool ValidateValue(object actual, object expected)
  5375. {
  5376. var temp = Console.ForegroundColor;
  5377. if (actual.ToString() != expected.ToString())
  5378. {
  5379. FailedCount++;
  5380. Console.ForegroundColor = ConsoleColor.Red;
  5381. Console.Write(""FAIL: "");
  5382. }
  5383. else
  5384. {
  5385. Console.ForegroundColor = ConsoleColor.Green;
  5386. Console.Write(""PASS: "");
  5387. }
  5388. Console.ForegroundColor = temp;
  5389. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  5390. return actual.ToString() == expected.ToString();
  5391. }
  5392. static void TestNullableArgs()
  5393. {
  5394. Console.WriteLine(""=== IVectorInt - nullable ==="");
  5395. var v = new IVectorInt();
  5396. //Add
  5397. v.ClearFlag();
  5398. int? x = 1;
  5399. v.Add((int)x);
  5400. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  5401. ValidateValue(v[0], 1);
  5402. }
  5403. static int Main()
  5404. {
  5405. TestNullableArgs();
  5406. Console.WriteLine(FailedCount);
  5407. return FailedCount;
  5408. }
  5409. }";
  5410. var verifier = CompileAndVerify(source,
  5411. additionalRefs: LegacyRefs,
  5412. emitOptions: EmitOptions.RefEmitBug,
  5413. verify: false);
  5414. verifier.VerifyDiagnostics(
  5415. // (2,1): info CS8019: Unnecessary using directive.
  5416. // using System.Collections.Generic;
  5417. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections.Generic;"),
  5418. // (3,1): info CS8019: Unnecessary using directive.
  5419. // using System.Reflection;
  5420. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  5421. // (4,1): info CS8019: Unnecessary using directive.
  5422. // using System.Linq.Expressions;
  5423. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  5424. // (6,1): info CS8019: Unnecessary using directive.
  5425. // using System.Linq;
  5426. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"));
  5427. verifier.VerifyIL("AllMembers.TestNullableArgs",
  5428. @"
  5429. {
  5430. // Code size 80 (0x50)
  5431. .maxstack 3
  5432. .locals init (int? V_0) //x
  5433. IL_0000: ldstr ""=== IVectorInt - nullable ===""
  5434. IL_0005: call ""void System.Console.WriteLine(string)""
  5435. IL_000a: newobj ""Windows.Languages.WinRTTest.IVectorInt..ctor()""
  5436. IL_000f: dup
  5437. IL_0010: callvirt ""void Windows.Languages.WinRTTest.IVectorInt.ClearFlag()""
  5438. IL_0015: ldloca.s V_0
  5439. IL_0017: ldc.i4.1
  5440. IL_0018: call ""int?..ctor(int)""
  5441. IL_001d: dup
  5442. IL_001e: ldloca.s V_0
  5443. IL_0020: call ""int int?.Value.get""
  5444. IL_0025: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  5445. IL_002a: dup
  5446. IL_002b: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IVectorInt.GetFlagState()""
  5447. IL_0030: ldc.i4.s 9
  5448. IL_0032: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5449. IL_0037: pop
  5450. IL_0038: ldc.i4.0
  5451. IL_0039: callvirt ""int System.Collections.Generic.IList<int>.this[int].get""
  5452. IL_003e: box ""int""
  5453. IL_0043: ldc.i4.1
  5454. IL_0044: box ""int""
  5455. IL_0049: call ""bool AllMembers.ValidateValue(object, object)""
  5456. IL_004e: pop
  5457. IL_004f: ret
  5458. }
  5459. ");
  5460. }
  5461. [Fact]
  5462. public void LegacyCollectionTest12()
  5463. {
  5464. var source =
  5465. @"using System;
  5466. using System.Reflection;
  5467. using System.Runtime.InteropServices;
  5468. using System.Threading;
  5469. using System.Collections;
  5470. using System.Collections.Generic;
  5471. using Windows.Foundation.Collections;
  5472. namespace Test
  5473. {
  5474. public class R : IObservableVector<int>
  5475. {
  5476. public event VectorChangedEventHandler<int> VectorChanged;
  5477. public int IndexOf(int item)
  5478. {
  5479. throw new NotImplementedException();
  5480. }
  5481. public void Insert(int index, int item)
  5482. {
  5483. throw new NotImplementedException();
  5484. }
  5485. public void RemoveAt(int index)
  5486. {
  5487. throw new NotImplementedException();
  5488. }
  5489. int IObservableVector<int>.this[int index]
  5490. {
  5491. get
  5492. {
  5493. throw new NotImplementedException();
  5494. }
  5495. }
  5496. int IList<int>.this[int index]
  5497. {
  5498. get
  5499. {
  5500. throw new NotImplementedException();
  5501. }
  5502. set
  5503. {
  5504. throw new NotImplementedException();
  5505. }
  5506. }
  5507. public void Add(int item)
  5508. {
  5509. throw new NotImplementedException();
  5510. }
  5511. public void Clear()
  5512. {
  5513. throw new NotImplementedException();
  5514. }
  5515. public bool Contains(int item)
  5516. {
  5517. throw new NotImplementedException();
  5518. }
  5519. public void CopyTo(int[] array, int arrayIndex)
  5520. {
  5521. throw new NotImplementedException();
  5522. }
  5523. public int Count
  5524. {
  5525. get { throw new NotImplementedException(); }
  5526. }
  5527. public bool IsReadOnly
  5528. {
  5529. get { throw new NotImplementedException(); }
  5530. }
  5531. public bool Remove(int item)
  5532. {
  5533. throw new NotImplementedException();
  5534. }
  5535. public IEnumerator<int> GetEnumerator()
  5536. {
  5537. throw new NotImplementedException();
  5538. }
  5539. IEnumerator IEnumerable.GetEnumerator()
  5540. {
  5541. throw new NotImplementedException();
  5542. }
  5543. }
  5544. }";
  5545. var comp = CreateCompilation(source, references: LegacyRefs);
  5546. comp.VerifyDiagnostics(
  5547. // (30,36): error CS0539: 'Test.R.this[int]' in explicit interface declaration is not a member of interface
  5548. // int IObservableVector<int>.this[int index]
  5549. Diagnostic(ErrorCode.ERR_InterfaceMemberNotFound, "this").WithArguments("Test.R.this[int]"),
  5550. // (13,53): warning CS0067: The event 'Test.R.VectorChanged' is never used
  5551. // public event VectorChangedEventHandler<int> VectorChanged;
  5552. Diagnostic(ErrorCode.WRN_UnreferencedEvent, "VectorChanged").WithArguments("Test.R.VectorChanged"),
  5553. // (2,1): info CS8019: Unnecessary using directive.
  5554. // using System.Reflection;
  5555. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  5556. // (3,1): info CS8019: Unnecessary using directive.
  5557. // using System.Runtime.InteropServices;
  5558. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Runtime.InteropServices;"),
  5559. // (4,1): info CS8019: Unnecessary using directive.
  5560. // using System.Threading;
  5561. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Threading;"));
  5562. }
  5563. [Fact]
  5564. public void LegacyCollectionTest13()
  5565. {
  5566. var source =
  5567. @"using Windows.Languages.WinRTTest;
  5568. using System.Collections.Generic;
  5569. using System.Reflection;
  5570. using System.Linq.Expressions;
  5571. using System;
  5572. using System.Linq;
  5573. using System.Collections;
  5574. class AllMembers
  5575. {
  5576. private static int FailedCount = 0;
  5577. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  5578. {
  5579. var temp = Console.ForegroundColor;
  5580. if (actual != expected)
  5581. {
  5582. FailedCount++;
  5583. Console.ForegroundColor = ConsoleColor.Red;
  5584. Console.Write(""FAIL: "");
  5585. }
  5586. else
  5587. {
  5588. Console.ForegroundColor = ConsoleColor.Green;
  5589. Console.Write(""PASS: "");
  5590. }
  5591. Console.ForegroundColor = temp;
  5592. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  5593. return actual == expected;
  5594. }
  5595. static void TestIBindableVectorMembers()
  5596. {
  5597. Console.WriteLine(""=== IBindableVectorSimple ==="");
  5598. var v = new IBindableVectorSimple();
  5599. //Add
  5600. v.ClearFlag();
  5601. v.Add(1);
  5602. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_get_Size);
  5603. //Contains
  5604. v.ClearFlag();
  5605. bool b = v.Contains(1);
  5606. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_IndexOf);
  5607. //CopyTo
  5608. v.ClearFlag();
  5609. int[] arr = new int[10];
  5610. v.CopyTo(arr, 0);
  5611. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_get_Size);
  5612. //GetEnumerator
  5613. v.ClearFlag();
  5614. int count = v.Count;
  5615. IEnumerator enumerator = ((IEnumerable)v).GetEnumerator();
  5616. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableIterable_First);
  5617. //IndexOf
  5618. v.ClearFlag();
  5619. var rez = v.IndexOf(1);
  5620. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_IndexOf);
  5621. //Insert
  5622. v.ClearFlag();
  5623. v.Insert(1, 2);
  5624. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_InsertAt);
  5625. //IsReadOnly
  5626. v.ClearFlag();
  5627. bool isReadOnly = v.IsReadOnly;
  5628. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  5629. //Indexing
  5630. v.ClearFlag();
  5631. object val = v[0];
  5632. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_GetAt);
  5633. v.ClearFlag();
  5634. val = v[1];
  5635. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_GetAt);
  5636. //Remove
  5637. v.ClearFlag();
  5638. v.Remove(1);
  5639. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_IndexOf);
  5640. //RemoveAt
  5641. v.ClearFlag();
  5642. v.RemoveAt(0);
  5643. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_RemoveAt);
  5644. //Clear
  5645. v.Add(1);
  5646. v.Add(2);
  5647. v.ClearFlag();
  5648. v.Clear();
  5649. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_Clear);
  5650. }
  5651. static int Main()
  5652. {
  5653. TestIBindableVectorMembers();
  5654. Console.WriteLine(FailedCount);
  5655. return FailedCount;
  5656. }
  5657. }";
  5658. var verifier = CompileAndVerify(source,
  5659. additionalRefs: LegacyRefs,
  5660. emitOptions: EmitOptions.RefEmitBug,
  5661. verify: false);
  5662. verifier.VerifyDiagnostics(
  5663. // (2,1): info CS8019: Unnecessary using directive.
  5664. // using System.Collections.Generic;
  5665. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections.Generic;"),
  5666. // (3,1): info CS8019: Unnecessary using directive.
  5667. // using System.Reflection;
  5668. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  5669. // (4,1): info CS8019: Unnecessary using directive.
  5670. // using System.Linq.Expressions;
  5671. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  5672. // (6,1): info CS8019: Unnecessary using directive.
  5673. // using System.Linq;
  5674. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"));
  5675. verifier.VerifyIL("AllMembers.TestIBindableVectorMembers",
  5676. @"{
  5677. // Code size 410 (0x19a)
  5678. .maxstack 4
  5679. .locals init (int[] V_0) //arr
  5680. IL_0000: ldstr ""=== IBindableVectorSimple ===""
  5681. IL_0005: call ""void System.Console.WriteLine(string)""
  5682. IL_000a: newobj ""Windows.Languages.WinRTTest.IBindableVectorSimple..ctor()""
  5683. IL_000f: dup
  5684. IL_0010: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorSimple.ClearFlag()""
  5685. IL_0015: dup
  5686. IL_0016: ldc.i4.1
  5687. IL_0017: box ""int""
  5688. IL_001c: callvirt ""int System.Collections.IList.Add(object)""
  5689. IL_0021: pop
  5690. IL_0022: dup
  5691. IL_0023: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorSimple.GetFlagState()""
  5692. IL_0028: ldc.i4.s 28
  5693. IL_002a: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5694. IL_002f: pop
  5695. IL_0030: dup
  5696. IL_0031: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorSimple.ClearFlag()""
  5697. IL_0036: dup
  5698. IL_0037: ldc.i4.1
  5699. IL_0038: box ""int""
  5700. IL_003d: callvirt ""bool System.Collections.IList.Contains(object)""
  5701. IL_0042: pop
  5702. IL_0043: dup
  5703. IL_0044: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorSimple.GetFlagState()""
  5704. IL_0049: ldc.i4.s 30
  5705. IL_004b: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5706. IL_0050: pop
  5707. IL_0051: dup
  5708. IL_0052: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorSimple.ClearFlag()""
  5709. IL_0057: ldc.i4.s 10
  5710. IL_0059: newarr ""int""
  5711. IL_005e: stloc.0
  5712. IL_005f: dup
  5713. IL_0060: ldloc.0
  5714. IL_0061: ldc.i4.0
  5715. IL_0062: callvirt ""void System.Collections.ICollection.CopyTo(System.Array, int)""
  5716. IL_0067: dup
  5717. IL_0068: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorSimple.GetFlagState()""
  5718. IL_006d: ldc.i4.s 28
  5719. IL_006f: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5720. IL_0074: pop
  5721. IL_0075: dup
  5722. IL_0076: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorSimple.ClearFlag()""
  5723. IL_007b: dup
  5724. IL_007c: callvirt ""int System.Collections.ICollection.Count.get""
  5725. IL_0081: pop
  5726. IL_0082: dup
  5727. IL_0083: callvirt ""System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()""
  5728. IL_0088: pop
  5729. IL_0089: dup
  5730. IL_008a: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorSimple.GetFlagState()""
  5731. IL_008f: ldc.i4.s 26
  5732. IL_0091: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5733. IL_0096: pop
  5734. IL_0097: dup
  5735. IL_0098: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorSimple.ClearFlag()""
  5736. IL_009d: dup
  5737. IL_009e: ldc.i4.1
  5738. IL_009f: box ""int""
  5739. IL_00a4: callvirt ""int System.Collections.IList.IndexOf(object)""
  5740. IL_00a9: pop
  5741. IL_00aa: dup
  5742. IL_00ab: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorSimple.GetFlagState()""
  5743. IL_00b0: ldc.i4.s 30
  5744. IL_00b2: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5745. IL_00b7: pop
  5746. IL_00b8: dup
  5747. IL_00b9: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorSimple.ClearFlag()""
  5748. IL_00be: dup
  5749. IL_00bf: ldc.i4.1
  5750. IL_00c0: ldc.i4.2
  5751. IL_00c1: box ""int""
  5752. IL_00c6: callvirt ""void System.Collections.IList.Insert(int, object)""
  5753. IL_00cb: dup
  5754. IL_00cc: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorSimple.GetFlagState()""
  5755. IL_00d1: ldc.i4.s 32
  5756. IL_00d3: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5757. IL_00d8: pop
  5758. IL_00d9: dup
  5759. IL_00da: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorSimple.ClearFlag()""
  5760. IL_00df: dup
  5761. IL_00e0: callvirt ""bool System.Collections.IList.IsReadOnly.get""
  5762. IL_00e5: pop
  5763. IL_00e6: dup
  5764. IL_00e7: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorSimple.GetFlagState()""
  5765. IL_00ec: ldc.i4.0
  5766. IL_00ed: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5767. IL_00f2: pop
  5768. IL_00f3: dup
  5769. IL_00f4: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorSimple.ClearFlag()""
  5770. IL_00f9: dup
  5771. IL_00fa: ldc.i4.0
  5772. IL_00fb: callvirt ""object System.Collections.IList.this[int].get""
  5773. IL_0100: pop
  5774. IL_0101: dup
  5775. IL_0102: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorSimple.GetFlagState()""
  5776. IL_0107: ldc.i4.s 27
  5777. IL_0109: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5778. IL_010e: pop
  5779. IL_010f: dup
  5780. IL_0110: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorSimple.ClearFlag()""
  5781. IL_0115: dup
  5782. IL_0116: ldc.i4.1
  5783. IL_0117: callvirt ""object System.Collections.IList.this[int].get""
  5784. IL_011c: pop
  5785. IL_011d: dup
  5786. IL_011e: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorSimple.GetFlagState()""
  5787. IL_0123: ldc.i4.s 27
  5788. IL_0125: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5789. IL_012a: pop
  5790. IL_012b: dup
  5791. IL_012c: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorSimple.ClearFlag()""
  5792. IL_0131: dup
  5793. IL_0132: ldc.i4.1
  5794. IL_0133: box ""int""
  5795. IL_0138: callvirt ""void System.Collections.IList.Remove(object)""
  5796. IL_013d: dup
  5797. IL_013e: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorSimple.GetFlagState()""
  5798. IL_0143: ldc.i4.s 30
  5799. IL_0145: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5800. IL_014a: pop
  5801. IL_014b: dup
  5802. IL_014c: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorSimple.ClearFlag()""
  5803. IL_0151: dup
  5804. IL_0152: ldc.i4.0
  5805. IL_0153: callvirt ""void System.Collections.IList.RemoveAt(int)""
  5806. IL_0158: dup
  5807. IL_0159: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorSimple.GetFlagState()""
  5808. IL_015e: ldc.i4.s 33
  5809. IL_0160: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5810. IL_0165: pop
  5811. IL_0166: dup
  5812. IL_0167: ldc.i4.1
  5813. IL_0168: box ""int""
  5814. IL_016d: callvirt ""int System.Collections.IList.Add(object)""
  5815. IL_0172: pop
  5816. IL_0173: dup
  5817. IL_0174: ldc.i4.2
  5818. IL_0175: box ""int""
  5819. IL_017a: callvirt ""int System.Collections.IList.Add(object)""
  5820. IL_017f: pop
  5821. IL_0180: dup
  5822. IL_0181: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorSimple.ClearFlag()""
  5823. IL_0186: dup
  5824. IL_0187: callvirt ""void System.Collections.IList.Clear()""
  5825. IL_018c: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorSimple.GetFlagState()""
  5826. IL_0191: ldc.i4.s 36
  5827. IL_0193: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5828. IL_0198: pop
  5829. IL_0199: ret
  5830. }");
  5831. }
  5832. [Fact]
  5833. public void LegacyCollectionTest14()
  5834. {
  5835. var source =
  5836. @"using Windows.Languages.WinRTTest;
  5837. using System.Collections.Generic;
  5838. using System.Reflection;
  5839. using System.Linq.Expressions;
  5840. using System;
  5841. using System.Linq;
  5842. using System.Collections;
  5843. class AllMembers
  5844. {
  5845. private static int FailedCount = 0;
  5846. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  5847. {
  5848. var temp = Console.ForegroundColor;
  5849. if (actual != expected)
  5850. {
  5851. FailedCount++;
  5852. Console.ForegroundColor = ConsoleColor.Red;
  5853. Console.Write(""FAIL: "");
  5854. }
  5855. else
  5856. {
  5857. Console.ForegroundColor = ConsoleColor.Green;
  5858. Console.Write(""PASS: "");
  5859. }
  5860. Console.ForegroundColor = temp;
  5861. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  5862. return actual == expected;
  5863. }
  5864. static void TestIBindableIterableMembers()
  5865. {
  5866. Console.WriteLine(""=== IBindableIterableSimple ==="");
  5867. var v = new IBindableIterableSimple();
  5868. //Add
  5869. v.ClearFlag();
  5870. v.GetEnumerator();
  5871. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableIterable_First);
  5872. }
  5873. static int Main()
  5874. {
  5875. TestIBindableIterableMembers();
  5876. Console.WriteLine(FailedCount);
  5877. return FailedCount;
  5878. }
  5879. }";
  5880. var verifier = CompileAndVerify(source,
  5881. additionalRefs: LegacyRefs,
  5882. emitOptions: EmitOptions.RefEmitBug,
  5883. verify: false);
  5884. verifier.VerifyDiagnostics(
  5885. // (2,1): info CS8019: Unnecessary using directive.
  5886. // using System.Collections.Generic;
  5887. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections.Generic;"),
  5888. // (3,1): info CS8019: Unnecessary using directive.
  5889. // using System.Reflection;
  5890. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  5891. // (4,1): info CS8019: Unnecessary using directive.
  5892. // using System.Linq.Expressions;
  5893. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  5894. // (6,1): info CS8019: Unnecessary using directive.
  5895. // using System.Linq;
  5896. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"),
  5897. // (7,1): info CS8019: Unnecessary using directive.
  5898. // using System.Collections;
  5899. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections;"));
  5900. verifier.VerifyIL("AllMembers.TestIBindableIterableMembers",
  5901. @"{
  5902. // Code size 42 (0x2a)
  5903. .maxstack 2
  5904. IL_0000: ldstr ""=== IBindableIterableSimple ===""
  5905. IL_0005: call ""void System.Console.WriteLine(string)""
  5906. IL_000a: newobj ""Windows.Languages.WinRTTest.IBindableIterableSimple..ctor()""
  5907. IL_000f: dup
  5908. IL_0010: callvirt ""void Windows.Languages.WinRTTest.IBindableIterableSimple.ClearFlag()""
  5909. IL_0015: dup
  5910. IL_0016: callvirt ""System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()""
  5911. IL_001b: pop
  5912. IL_001c: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableIterableSimple.GetFlagState()""
  5913. IL_0021: ldc.i4.s 26
  5914. IL_0023: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  5915. IL_0028: pop
  5916. IL_0029: ret
  5917. }");
  5918. }
  5919. [Fact]
  5920. public void LegacyCollectionTest15()
  5921. {
  5922. var source =
  5923. @"using Windows.Languages.WinRTTest;
  5924. using System.Collections.Generic;
  5925. using System.Reflection;
  5926. using System.Linq.Expressions;
  5927. using System;
  5928. using System.Linq;
  5929. using System.Collections;
  5930. class AllMembers
  5931. {
  5932. private static int FailedCount = 0;
  5933. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  5934. {
  5935. var temp = Console.ForegroundColor;
  5936. if (actual != expected)
  5937. {
  5938. FailedCount++;
  5939. Console.ForegroundColor = ConsoleColor.Red;
  5940. Console.Write(""FAIL: "");
  5941. }
  5942. else
  5943. {
  5944. Console.ForegroundColor = ConsoleColor.Green;
  5945. Console.Write(""PASS: "");
  5946. }
  5947. Console.ForegroundColor = temp;
  5948. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  5949. return actual == expected;
  5950. }
  5951. static void TestIBindableVectorIVectorIntMembers()
  5952. {
  5953. Console.WriteLine(""=== IBindableVectorIVectorIntSimple ==="");
  5954. var v = new IBindableVectorIVectorInt();
  5955. //Validate IBindableVector
  5956. //Add
  5957. v.ClearFlag();
  5958. v.Add((object)1);
  5959. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_get_Size);
  5960. //Contains
  5961. v.ClearFlag();
  5962. bool b = v.Contains((object)1);
  5963. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_IndexOf);
  5964. //CopyTo
  5965. v.ClearFlag();
  5966. int[] arr = new int[10];
  5967. v.CopyTo(arr, 0);
  5968. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_get_Size);
  5969. //GetEnumerator
  5970. v.ClearFlag();
  5971. int count = ((IList)v).Count;
  5972. IEnumerator enumerator = ((IEnumerable)v).GetEnumerator();
  5973. ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First);
  5974. //IndexOf
  5975. v.ClearFlag();
  5976. var rez = v.IndexOf((object)1);
  5977. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_IndexOf);
  5978. //Insert
  5979. v.ClearFlag();
  5980. v.Insert(1, (object)2);
  5981. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_InsertAt);
  5982. //IsReadOnly
  5983. v.ClearFlag();
  5984. bool isReadOnly = ((IList)v).IsReadOnly;
  5985. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  5986. //Indexing
  5987. v.ClearFlag();
  5988. object val = ((IList)v)[0];
  5989. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_GetAt);
  5990. v.ClearFlag();
  5991. val = ((IList)v)[1];
  5992. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_GetAt);
  5993. //Remove
  5994. v.ClearFlag();
  5995. v.Remove((object)1);
  5996. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_IndexOf);
  5997. //RemoveAt
  5998. v.ClearFlag();
  5999. ((IList)v).RemoveAt(0);
  6000. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_RemoveAt);
  6001. //Clear
  6002. v.Add(1);
  6003. v.Add(2);
  6004. v.ClearFlag();
  6005. ((IList)v).Clear();
  6006. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_Clear);
  6007. //Validate Vector<int>
  6008. //Add
  6009. v.ClearFlag();
  6010. v.Add(1);
  6011. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_Append);
  6012. //Contains
  6013. v.ClearFlag();
  6014. b = v.Contains(1);
  6015. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  6016. //CopyTo
  6017. v.ClearFlag();
  6018. arr = new int[10];
  6019. v.CopyTo(arr, 0);
  6020. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_get_Size);
  6021. //GetEnumerator
  6022. v.ClearFlag();
  6023. count = ((IList<int>)v).Count;
  6024. IEnumerator<int> enumerator2 = ((IList<int>)v).GetEnumerator();
  6025. ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First);
  6026. //IndexOf
  6027. v.ClearFlag();
  6028. rez = v.IndexOf(1);
  6029. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  6030. //Insert
  6031. v.ClearFlag();
  6032. v.Insert(1, 2);
  6033. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_InsertAt);
  6034. //IsReadOnly
  6035. v.ClearFlag();
  6036. isReadOnly = ((IList<int>)v).IsReadOnly;
  6037. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  6038. //Indexing
  6039. v.ClearFlag();
  6040. val = ((IList<int>)v)[0];
  6041. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  6042. v.ClearFlag();
  6043. val = ((IList<int>)v)[1];
  6044. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_GetAt);
  6045. //Remove
  6046. v.ClearFlag();
  6047. v.Remove(1);
  6048. ValidateMethod(v.GetFlagState(), TestMethodCalled.IVector_IndexOf);
  6049. //RemoveAt
  6050. v.ClearFlag();
  6051. ((IList<int>)v).RemoveAt(0);
  6052. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_RemoveAt);
  6053. //Clear
  6054. v.Add(1);
  6055. v.Add(2);
  6056. v.ClearFlag();
  6057. ((IList<int>)v).Clear();
  6058. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_Clear);
  6059. }
  6060. static int Main()
  6061. {
  6062. TestIBindableVectorIVectorIntMembers();
  6063. Console.WriteLine(FailedCount);
  6064. return FailedCount;
  6065. }
  6066. }";
  6067. var verifier = CompileAndVerify(source,
  6068. additionalRefs: LegacyRefs,
  6069. emitOptions: EmitOptions.RefEmitBug,
  6070. verify:false);
  6071. verifier.VerifyDiagnostics(
  6072. // (3,1): info CS8019: Unnecessary using directive.
  6073. // using System.Reflection;
  6074. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  6075. // (4,1): info CS8019: Unnecessary using directive.
  6076. // using System.Linq.Expressions;
  6077. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  6078. // (6,1): info CS8019: Unnecessary using directive.
  6079. // using System.Linq;
  6080. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"));
  6081. verifier.VerifyIL("AllMembers.TestIBindableVectorIVectorIntMembers",
  6082. @"
  6083. {
  6084. // Code size 748 (0x2ec)
  6085. .maxstack 4
  6086. .locals init (int[] V_0) //arr
  6087. IL_0000: ldstr ""=== IBindableVectorIVectorIntSimple ===""
  6088. IL_0005: call ""void System.Console.WriteLine(string)""
  6089. IL_000a: newobj ""Windows.Languages.WinRTTest.IBindableVectorIVectorInt..ctor()""
  6090. IL_000f: dup
  6091. IL_0010: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6092. IL_0015: dup
  6093. IL_0016: ldc.i4.1
  6094. IL_0017: box ""int""
  6095. IL_001c: callvirt ""int System.Collections.IList.Add(object)""
  6096. IL_0021: pop
  6097. IL_0022: dup
  6098. IL_0023: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6099. IL_0028: ldc.i4.s 28
  6100. IL_002a: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6101. IL_002f: pop
  6102. IL_0030: dup
  6103. IL_0031: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6104. IL_0036: dup
  6105. IL_0037: ldc.i4.1
  6106. IL_0038: box ""int""
  6107. IL_003d: callvirt ""bool System.Collections.IList.Contains(object)""
  6108. IL_0042: pop
  6109. IL_0043: dup
  6110. IL_0044: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6111. IL_0049: ldc.i4.s 30
  6112. IL_004b: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6113. IL_0050: pop
  6114. IL_0051: dup
  6115. IL_0052: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6116. IL_0057: ldc.i4.s 10
  6117. IL_0059: newarr ""int""
  6118. IL_005e: stloc.0
  6119. IL_005f: dup
  6120. IL_0060: ldloc.0
  6121. IL_0061: ldc.i4.0
  6122. IL_0062: callvirt ""void System.Collections.Generic.ICollection<int>.CopyTo(int[], int)""
  6123. IL_0067: dup
  6124. IL_0068: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6125. IL_006d: ldc.i4.s 28
  6126. IL_006f: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6127. IL_0074: pop
  6128. IL_0075: dup
  6129. IL_0076: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6130. IL_007b: dup
  6131. IL_007c: callvirt ""int System.Collections.ICollection.Count.get""
  6132. IL_0081: pop
  6133. IL_0082: dup
  6134. IL_0083: callvirt ""System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()""
  6135. IL_0088: pop
  6136. IL_0089: dup
  6137. IL_008a: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6138. IL_008f: ldc.i4.1
  6139. IL_0090: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6140. IL_0095: pop
  6141. IL_0096: dup
  6142. IL_0097: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6143. IL_009c: dup
  6144. IL_009d: ldc.i4.1
  6145. IL_009e: box ""int""
  6146. IL_00a3: callvirt ""int System.Collections.IList.IndexOf(object)""
  6147. IL_00a8: pop
  6148. IL_00a9: dup
  6149. IL_00aa: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6150. IL_00af: ldc.i4.s 30
  6151. IL_00b1: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6152. IL_00b6: pop
  6153. IL_00b7: dup
  6154. IL_00b8: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6155. IL_00bd: dup
  6156. IL_00be: ldc.i4.1
  6157. IL_00bf: ldc.i4.2
  6158. IL_00c0: box ""int""
  6159. IL_00c5: callvirt ""void System.Collections.IList.Insert(int, object)""
  6160. IL_00ca: dup
  6161. IL_00cb: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6162. IL_00d0: ldc.i4.s 32
  6163. IL_00d2: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6164. IL_00d7: pop
  6165. IL_00d8: dup
  6166. IL_00d9: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6167. IL_00de: dup
  6168. IL_00df: callvirt ""bool System.Collections.IList.IsReadOnly.get""
  6169. IL_00e4: pop
  6170. IL_00e5: dup
  6171. IL_00e6: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6172. IL_00eb: ldc.i4.0
  6173. IL_00ec: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6174. IL_00f1: pop
  6175. IL_00f2: dup
  6176. IL_00f3: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6177. IL_00f8: dup
  6178. IL_00f9: ldc.i4.0
  6179. IL_00fa: callvirt ""object System.Collections.IList.this[int].get""
  6180. IL_00ff: pop
  6181. IL_0100: dup
  6182. IL_0101: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6183. IL_0106: ldc.i4.s 27
  6184. IL_0108: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6185. IL_010d: pop
  6186. IL_010e: dup
  6187. IL_010f: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6188. IL_0114: dup
  6189. IL_0115: ldc.i4.1
  6190. IL_0116: callvirt ""object System.Collections.IList.this[int].get""
  6191. IL_011b: pop
  6192. IL_011c: dup
  6193. IL_011d: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6194. IL_0122: ldc.i4.s 27
  6195. IL_0124: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6196. IL_0129: pop
  6197. IL_012a: dup
  6198. IL_012b: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6199. IL_0130: dup
  6200. IL_0131: ldc.i4.1
  6201. IL_0132: box ""int""
  6202. IL_0137: callvirt ""void System.Collections.IList.Remove(object)""
  6203. IL_013c: dup
  6204. IL_013d: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6205. IL_0142: ldc.i4.s 30
  6206. IL_0144: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6207. IL_0149: pop
  6208. IL_014a: dup
  6209. IL_014b: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6210. IL_0150: dup
  6211. IL_0151: ldc.i4.0
  6212. IL_0152: callvirt ""void System.Collections.IList.RemoveAt(int)""
  6213. IL_0157: dup
  6214. IL_0158: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6215. IL_015d: ldc.i4.s 33
  6216. IL_015f: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6217. IL_0164: pop
  6218. IL_0165: dup
  6219. IL_0166: ldc.i4.1
  6220. IL_0167: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  6221. IL_016c: dup
  6222. IL_016d: ldc.i4.2
  6223. IL_016e: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  6224. IL_0173: dup
  6225. IL_0174: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6226. IL_0179: dup
  6227. IL_017a: callvirt ""void System.Collections.IList.Clear()""
  6228. IL_017f: dup
  6229. IL_0180: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6230. IL_0185: ldc.i4.s 36
  6231. IL_0187: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6232. IL_018c: pop
  6233. IL_018d: dup
  6234. IL_018e: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6235. IL_0193: dup
  6236. IL_0194: ldc.i4.1
  6237. IL_0195: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  6238. IL_019a: dup
  6239. IL_019b: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6240. IL_01a0: ldc.i4.s 9
  6241. IL_01a2: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6242. IL_01a7: pop
  6243. IL_01a8: dup
  6244. IL_01a9: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6245. IL_01ae: dup
  6246. IL_01af: ldc.i4.1
  6247. IL_01b0: callvirt ""bool System.Collections.Generic.ICollection<int>.Contains(int)""
  6248. IL_01b5: pop
  6249. IL_01b6: dup
  6250. IL_01b7: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6251. IL_01bc: ldc.i4.5
  6252. IL_01bd: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6253. IL_01c2: pop
  6254. IL_01c3: dup
  6255. IL_01c4: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6256. IL_01c9: ldc.i4.s 10
  6257. IL_01cb: newarr ""int""
  6258. IL_01d0: stloc.0
  6259. IL_01d1: dup
  6260. IL_01d2: ldloc.0
  6261. IL_01d3: ldc.i4.0
  6262. IL_01d4: callvirt ""void System.Collections.Generic.ICollection<int>.CopyTo(int[], int)""
  6263. IL_01d9: dup
  6264. IL_01da: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6265. IL_01df: ldc.i4.s 28
  6266. IL_01e1: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6267. IL_01e6: pop
  6268. IL_01e7: dup
  6269. IL_01e8: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6270. IL_01ed: dup
  6271. IL_01ee: callvirt ""int System.Collections.Generic.ICollection<int>.Count.get""
  6272. IL_01f3: pop
  6273. IL_01f4: dup
  6274. IL_01f5: callvirt ""System.Collections.Generic.IEnumerator<int> System.Collections.Generic.IEnumerable<int>.GetEnumerator()""
  6275. IL_01fa: pop
  6276. IL_01fb: dup
  6277. IL_01fc: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6278. IL_0201: ldc.i4.1
  6279. IL_0202: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6280. IL_0207: pop
  6281. IL_0208: dup
  6282. IL_0209: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6283. IL_020e: dup
  6284. IL_020f: ldc.i4.1
  6285. IL_0210: callvirt ""int System.Collections.Generic.IList<int>.IndexOf(int)""
  6286. IL_0215: pop
  6287. IL_0216: dup
  6288. IL_0217: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6289. IL_021c: ldc.i4.5
  6290. IL_021d: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6291. IL_0222: pop
  6292. IL_0223: dup
  6293. IL_0224: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6294. IL_0229: dup
  6295. IL_022a: ldc.i4.1
  6296. IL_022b: ldc.i4.2
  6297. IL_022c: callvirt ""void System.Collections.Generic.IList<int>.Insert(int, int)""
  6298. IL_0231: dup
  6299. IL_0232: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6300. IL_0237: ldc.i4.7
  6301. IL_0238: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6302. IL_023d: pop
  6303. IL_023e: dup
  6304. IL_023f: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6305. IL_0244: dup
  6306. IL_0245: callvirt ""bool System.Collections.Generic.ICollection<int>.IsReadOnly.get""
  6307. IL_024a: pop
  6308. IL_024b: dup
  6309. IL_024c: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6310. IL_0251: ldc.i4.0
  6311. IL_0252: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6312. IL_0257: pop
  6313. IL_0258: dup
  6314. IL_0259: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6315. IL_025e: dup
  6316. IL_025f: ldc.i4.0
  6317. IL_0260: callvirt ""int System.Collections.Generic.IList<int>.this[int].get""
  6318. IL_0265: pop
  6319. IL_0266: dup
  6320. IL_0267: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6321. IL_026c: ldc.i4.2
  6322. IL_026d: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6323. IL_0272: pop
  6324. IL_0273: dup
  6325. IL_0274: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6326. IL_0279: dup
  6327. IL_027a: ldc.i4.1
  6328. IL_027b: callvirt ""int System.Collections.Generic.IList<int>.this[int].get""
  6329. IL_0280: pop
  6330. IL_0281: dup
  6331. IL_0282: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6332. IL_0287: ldc.i4.2
  6333. IL_0288: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6334. IL_028d: pop
  6335. IL_028e: dup
  6336. IL_028f: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6337. IL_0294: dup
  6338. IL_0295: ldc.i4.1
  6339. IL_0296: callvirt ""bool System.Collections.Generic.ICollection<int>.Remove(int)""
  6340. IL_029b: pop
  6341. IL_029c: dup
  6342. IL_029d: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6343. IL_02a2: ldc.i4.5
  6344. IL_02a3: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6345. IL_02a8: pop
  6346. IL_02a9: dup
  6347. IL_02aa: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6348. IL_02af: dup
  6349. IL_02b0: ldc.i4.0
  6350. IL_02b1: callvirt ""void System.Collections.Generic.IList<int>.RemoveAt(int)""
  6351. IL_02b6: dup
  6352. IL_02b7: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6353. IL_02bc: ldc.i4.s 33
  6354. IL_02be: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6355. IL_02c3: pop
  6356. IL_02c4: dup
  6357. IL_02c5: ldc.i4.1
  6358. IL_02c6: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  6359. IL_02cb: dup
  6360. IL_02cc: ldc.i4.2
  6361. IL_02cd: callvirt ""void System.Collections.Generic.ICollection<int>.Add(int)""
  6362. IL_02d2: dup
  6363. IL_02d3: callvirt ""void Windows.Languages.WinRTTest.IBindableVectorIVectorInt.ClearFlag()""
  6364. IL_02d8: dup
  6365. IL_02d9: callvirt ""void System.Collections.Generic.ICollection<int>.Clear()""
  6366. IL_02de: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableVectorIVectorInt.GetFlagState()""
  6367. IL_02e3: ldc.i4.s 36
  6368. IL_02e5: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6369. IL_02ea: pop
  6370. IL_02eb: ret
  6371. }");
  6372. }
  6373. [Fact]
  6374. public void LegacyCollectionTest16()
  6375. {
  6376. var source =
  6377. @"using Windows.Languages.WinRTTest;
  6378. using System.Collections.Generic;
  6379. using System.Reflection;
  6380. using System.Linq.Expressions;
  6381. using System;
  6382. using System.Linq;
  6383. using System.Collections;
  6384. class AllMembers
  6385. {
  6386. private static int FailedCount = 0;
  6387. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  6388. {
  6389. var temp = Console.ForegroundColor;
  6390. if (actual != expected)
  6391. {
  6392. FailedCount++;
  6393. Console.ForegroundColor = ConsoleColor.Red;
  6394. Console.Write(""FAIL: "");
  6395. }
  6396. else
  6397. {
  6398. Console.ForegroundColor = ConsoleColor.Green;
  6399. Console.Write(""PASS: "");
  6400. }
  6401. Console.ForegroundColor = temp;
  6402. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  6403. return actual == expected;
  6404. }
  6405. static void TestIBindableIterableIIterableMembers()
  6406. {
  6407. Console.WriteLine(""=== IBindableIterableIIterable ==="");
  6408. var v = new IBindableIterableIIterable();
  6409. //Add
  6410. v.ClearFlag();
  6411. ((IEnumerable)v).GetEnumerator();
  6412. ValidateMethod(v.GetFlagState(), TestMethodCalled.IIterable_First);
  6413. }
  6414. static int Main()
  6415. {
  6416. TestIBindableIterableIIterableMembers();
  6417. Console.WriteLine(FailedCount);
  6418. return FailedCount;
  6419. }
  6420. }";
  6421. var verifier = CompileAndVerify(source,
  6422. additionalRefs: LegacyRefs,
  6423. emitOptions: EmitOptions.RefEmitBug,
  6424. verify: false);
  6425. verifier.VerifyDiagnostics(
  6426. // (2,1): info CS8019: Unnecessary using directive.
  6427. // using System.Collections.Generic;
  6428. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections.Generic;"),
  6429. // (3,1): info CS8019: Unnecessary using directive.
  6430. // using System.Reflection;
  6431. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  6432. // (4,1): info CS8019: Unnecessary using directive.
  6433. // using System.Linq.Expressions;
  6434. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  6435. // (6,1): info CS8019: Unnecessary using directive.
  6436. // using System.Linq;
  6437. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"));
  6438. verifier.VerifyIL("AllMembers.TestIBindableIterableIIterableMembers",
  6439. @"{
  6440. // Code size 41 (0x29)
  6441. .maxstack 2
  6442. IL_0000: ldstr ""=== IBindableIterableIIterable ===""
  6443. IL_0005: call ""void System.Console.WriteLine(string)""
  6444. IL_000a: newobj ""Windows.Languages.WinRTTest.IBindableIterableIIterable..ctor()""
  6445. IL_000f: dup
  6446. IL_0010: callvirt ""void Windows.Languages.WinRTTest.IBindableIterableIIterable.ClearFlag()""
  6447. IL_0015: dup
  6448. IL_0016: callvirt ""System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()""
  6449. IL_001b: pop
  6450. IL_001c: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.IBindableIterableIIterable.GetFlagState()""
  6451. IL_0021: ldc.i4.1
  6452. IL_0022: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6453. IL_0027: pop
  6454. IL_0028: ret
  6455. }");
  6456. }
  6457. [Fact]
  6458. public void LegacyCollectionTest17()
  6459. {
  6460. var source =
  6461. @"using Windows.Languages.WinRTTest;
  6462. using System.Collections.Generic;
  6463. using System.Reflection;
  6464. using System.Linq.Expressions;
  6465. using System;
  6466. using System.Linq;
  6467. using System.Collections;
  6468. class AllMembers
  6469. {
  6470. private static int FailedCount = 0;
  6471. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  6472. {
  6473. var temp = Console.ForegroundColor;
  6474. if (actual != expected)
  6475. {
  6476. FailedCount++;
  6477. Console.ForegroundColor = ConsoleColor.Red;
  6478. Console.Write(""FAIL: "");
  6479. }
  6480. else
  6481. {
  6482. Console.ForegroundColor = ConsoleColor.Green;
  6483. Console.Write(""PASS: "");
  6484. }
  6485. Console.ForegroundColor = temp;
  6486. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  6487. return actual == expected;
  6488. }
  6489. static void INotifyCollectionAndBindableVectorMembers()
  6490. {
  6491. Console.WriteLine(""=== INotifyCollectionAndBindableVectorClass ==="");
  6492. var v = new INotifyCollectionAndBindableVectorClass();
  6493. //Add
  6494. v.ClearFlag();
  6495. v.Add(1);
  6496. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_get_Size);
  6497. //Contains
  6498. v.ClearFlag();
  6499. bool b = v.Contains(1);
  6500. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_IndexOf);
  6501. //CopyTo
  6502. v.ClearFlag();
  6503. int[] arr = new int[10];
  6504. v.CopyTo(arr, 0);
  6505. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_get_Size);
  6506. //GetEnumerator
  6507. v.ClearFlag();
  6508. int count = v.Count;
  6509. IEnumerator enumerator = ((IEnumerable)v).GetEnumerator();
  6510. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableIterable_First);
  6511. //IndexOf
  6512. v.ClearFlag();
  6513. var rez = v.IndexOf(1);
  6514. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_IndexOf);
  6515. //Insert
  6516. v.ClearFlag();
  6517. v.Insert(1, 2);
  6518. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_InsertAt);
  6519. //IsReadOnly
  6520. v.ClearFlag();
  6521. bool isReadOnly = v.IsReadOnly;
  6522. ValidateMethod(v.GetFlagState(), TestMethodCalled.NotSet);
  6523. //Indexing
  6524. v.ClearFlag();
  6525. object val = v[0];
  6526. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_GetAt);
  6527. v.ClearFlag();
  6528. val = v[1];
  6529. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_GetAt);
  6530. //Remove
  6531. v.ClearFlag();
  6532. v.Remove(1);
  6533. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_IndexOf);
  6534. //RemoveAt
  6535. v.ClearFlag();
  6536. v.RemoveAt(0);
  6537. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_RemoveAt);
  6538. //Clear
  6539. v.Add(1);
  6540. v.Add(2);
  6541. v.ClearFlag();
  6542. v.Clear();
  6543. ValidateMethod(v.GetFlagState(), TestMethodCalled.IBindableVector_Clear);
  6544. //Events
  6545. //Add event
  6546. v.ClearFlag();
  6547. var dele = new System.Collections.Specialized.NotifyCollectionChangedEventHandler(v_CollectionChanged);
  6548. v.CollectionChanged += dele;
  6549. ValidateMethod(v.GetFlagState(), TestMethodCalled.INotifyCollectionChanged_Add_CollectionChanged);
  6550. //Remove event
  6551. v.ClearFlag();
  6552. v.CollectionChanged -= dele;
  6553. ValidateMethod(v.GetFlagState(), TestMethodCalled.INotifyCollectionChanged_Remove_CollectionChanged);
  6554. }
  6555. static void v_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  6556. {
  6557. throw new NotImplementedException();
  6558. }
  6559. static void v_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
  6560. {
  6561. throw new NotImplementedException();
  6562. }
  6563. static int Main()
  6564. {
  6565. INotifyCollectionAndBindableVectorMembers();
  6566. Console.WriteLine(FailedCount);
  6567. return FailedCount;
  6568. }
  6569. }";
  6570. var verifier = CompileAndVerify(
  6571. source,
  6572. additionalRefs: LegacyRefs,
  6573. emitOptions: EmitOptions.RefEmitBug,
  6574. verify: false);
  6575. verifier.VerifyDiagnostics(
  6576. // (2,1): info CS8019: Unnecessary using directive.
  6577. // using System.Collections.Generic;
  6578. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections.Generic;"),
  6579. // (3,1): info CS8019: Unnecessary using directive.
  6580. // using System.Reflection;
  6581. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  6582. // (4,1): info CS8019: Unnecessary using directive.
  6583. // using System.Linq.Expressions;
  6584. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  6585. // (6,1): info CS8019: Unnecessary using directive.
  6586. // using System.Linq;
  6587. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"));
  6588. verifier.VerifyIL("AllMembers.INotifyCollectionAndBindableVectorMembers",
  6589. @"
  6590. {
  6591. // Code size 477 (0x1dd)
  6592. .maxstack 4
  6593. .locals init (int[] V_0, //arr
  6594. System.Collections.Specialized.NotifyCollectionChangedEventHandler V_1) //dele
  6595. IL_0000: ldstr ""=== INotifyCollectionAndBindableVectorClass ===""
  6596. IL_0005: call ""void System.Console.WriteLine(string)""
  6597. IL_000a: newobj ""Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass..ctor()""
  6598. IL_000f: dup
  6599. IL_0010: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.ClearFlag()""
  6600. IL_0015: dup
  6601. IL_0016: ldc.i4.1
  6602. IL_0017: box ""int""
  6603. IL_001c: callvirt ""int System.Collections.IList.Add(object)""
  6604. IL_0021: pop
  6605. IL_0022: dup
  6606. IL_0023: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.GetFlagState()""
  6607. IL_0028: ldc.i4.s 28
  6608. IL_002a: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6609. IL_002f: pop
  6610. IL_0030: dup
  6611. IL_0031: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.ClearFlag()""
  6612. IL_0036: dup
  6613. IL_0037: ldc.i4.1
  6614. IL_0038: box ""int""
  6615. IL_003d: callvirt ""bool System.Collections.IList.Contains(object)""
  6616. IL_0042: pop
  6617. IL_0043: dup
  6618. IL_0044: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.GetFlagState()""
  6619. IL_0049: ldc.i4.s 30
  6620. IL_004b: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6621. IL_0050: pop
  6622. IL_0051: dup
  6623. IL_0052: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.ClearFlag()""
  6624. IL_0057: ldc.i4.s 10
  6625. IL_0059: newarr ""int""
  6626. IL_005e: stloc.0
  6627. IL_005f: dup
  6628. IL_0060: ldloc.0
  6629. IL_0061: ldc.i4.0
  6630. IL_0062: callvirt ""void System.Collections.ICollection.CopyTo(System.Array, int)""
  6631. IL_0067: dup
  6632. IL_0068: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.GetFlagState()""
  6633. IL_006d: ldc.i4.s 28
  6634. IL_006f: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6635. IL_0074: pop
  6636. IL_0075: dup
  6637. IL_0076: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.ClearFlag()""
  6638. IL_007b: dup
  6639. IL_007c: callvirt ""int System.Collections.ICollection.Count.get""
  6640. IL_0081: pop
  6641. IL_0082: dup
  6642. IL_0083: callvirt ""System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()""
  6643. IL_0088: pop
  6644. IL_0089: dup
  6645. IL_008a: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.GetFlagState()""
  6646. IL_008f: ldc.i4.s 26
  6647. IL_0091: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6648. IL_0096: pop
  6649. IL_0097: dup
  6650. IL_0098: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.ClearFlag()""
  6651. IL_009d: dup
  6652. IL_009e: ldc.i4.1
  6653. IL_009f: box ""int""
  6654. IL_00a4: callvirt ""int System.Collections.IList.IndexOf(object)""
  6655. IL_00a9: pop
  6656. IL_00aa: dup
  6657. IL_00ab: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.GetFlagState()""
  6658. IL_00b0: ldc.i4.s 30
  6659. IL_00b2: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6660. IL_00b7: pop
  6661. IL_00b8: dup
  6662. IL_00b9: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.ClearFlag()""
  6663. IL_00be: dup
  6664. IL_00bf: ldc.i4.1
  6665. IL_00c0: ldc.i4.2
  6666. IL_00c1: box ""int""
  6667. IL_00c6: callvirt ""void System.Collections.IList.Insert(int, object)""
  6668. IL_00cb: dup
  6669. IL_00cc: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.GetFlagState()""
  6670. IL_00d1: ldc.i4.s 32
  6671. IL_00d3: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6672. IL_00d8: pop
  6673. IL_00d9: dup
  6674. IL_00da: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.ClearFlag()""
  6675. IL_00df: dup
  6676. IL_00e0: callvirt ""bool System.Collections.IList.IsReadOnly.get""
  6677. IL_00e5: pop
  6678. IL_00e6: dup
  6679. IL_00e7: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.GetFlagState()""
  6680. IL_00ec: ldc.i4.0
  6681. IL_00ed: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6682. IL_00f2: pop
  6683. IL_00f3: dup
  6684. IL_00f4: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.ClearFlag()""
  6685. IL_00f9: dup
  6686. IL_00fa: ldc.i4.0
  6687. IL_00fb: callvirt ""object System.Collections.IList.this[int].get""
  6688. IL_0100: pop
  6689. IL_0101: dup
  6690. IL_0102: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.GetFlagState()""
  6691. IL_0107: ldc.i4.s 27
  6692. IL_0109: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6693. IL_010e: pop
  6694. IL_010f: dup
  6695. IL_0110: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.ClearFlag()""
  6696. IL_0115: dup
  6697. IL_0116: ldc.i4.1
  6698. IL_0117: callvirt ""object System.Collections.IList.this[int].get""
  6699. IL_011c: pop
  6700. IL_011d: dup
  6701. IL_011e: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.GetFlagState()""
  6702. IL_0123: ldc.i4.s 27
  6703. IL_0125: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6704. IL_012a: pop
  6705. IL_012b: dup
  6706. IL_012c: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.ClearFlag()""
  6707. IL_0131: dup
  6708. IL_0132: ldc.i4.1
  6709. IL_0133: box ""int""
  6710. IL_0138: callvirt ""void System.Collections.IList.Remove(object)""
  6711. IL_013d: dup
  6712. IL_013e: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.GetFlagState()""
  6713. IL_0143: ldc.i4.s 30
  6714. IL_0145: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6715. IL_014a: pop
  6716. IL_014b: dup
  6717. IL_014c: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.ClearFlag()""
  6718. IL_0151: dup
  6719. IL_0152: ldc.i4.0
  6720. IL_0153: callvirt ""void System.Collections.IList.RemoveAt(int)""
  6721. IL_0158: dup
  6722. IL_0159: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.GetFlagState()""
  6723. IL_015e: ldc.i4.s 33
  6724. IL_0160: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6725. IL_0165: pop
  6726. IL_0166: dup
  6727. IL_0167: ldc.i4.1
  6728. IL_0168: box ""int""
  6729. IL_016d: callvirt ""int System.Collections.IList.Add(object)""
  6730. IL_0172: pop
  6731. IL_0173: dup
  6732. IL_0174: ldc.i4.2
  6733. IL_0175: box ""int""
  6734. IL_017a: callvirt ""int System.Collections.IList.Add(object)""
  6735. IL_017f: pop
  6736. IL_0180: dup
  6737. IL_0181: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.ClearFlag()""
  6738. IL_0186: dup
  6739. IL_0187: callvirt ""void System.Collections.IList.Clear()""
  6740. IL_018c: dup
  6741. IL_018d: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.GetFlagState()""
  6742. IL_0192: ldc.i4.s 36
  6743. IL_0194: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6744. IL_0199: pop
  6745. IL_019a: dup
  6746. IL_019b: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.ClearFlag()""
  6747. IL_01a0: ldnull
  6748. IL_01a1: ldftn ""void AllMembers.v_CollectionChanged(object, System.Collections.Specialized.NotifyCollectionChangedEventArgs)""
  6749. IL_01a7: newobj ""System.Collections.Specialized.NotifyCollectionChangedEventHandler..ctor(object, System.IntPtr)""
  6750. IL_01ac: stloc.1
  6751. IL_01ad: dup
  6752. IL_01ae: ldloc.1
  6753. IL_01af: callvirt ""void System.Collections.Specialized.INotifyCollectionChanged.CollectionChanged.add""
  6754. IL_01b4: dup
  6755. IL_01b5: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.GetFlagState()""
  6756. IL_01ba: ldc.i4.s 37
  6757. IL_01bc: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6758. IL_01c1: pop
  6759. IL_01c2: dup
  6760. IL_01c3: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.ClearFlag()""
  6761. IL_01c8: dup
  6762. IL_01c9: ldloc.1
  6763. IL_01ca: callvirt ""void System.Collections.Specialized.INotifyCollectionChanged.CollectionChanged.remove""
  6764. IL_01cf: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionAndBindableVectorClass.GetFlagState()""
  6765. IL_01d4: ldc.i4.s 38
  6766. IL_01d6: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6767. IL_01db: pop
  6768. IL_01dc: ret
  6769. }");
  6770. }
  6771. [Fact]
  6772. public void LegacyCollectionTest18()
  6773. {
  6774. var source =
  6775. @"using Windows.Languages.WinRTTest;
  6776. using System.Collections.Generic;
  6777. using System.Reflection;
  6778. using System.Linq.Expressions;
  6779. using System;
  6780. using System.Linq;
  6781. using System.Collections;
  6782. class AllMembers
  6783. {
  6784. private static int FailedCount = 0;
  6785. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  6786. {
  6787. var temp = Console.ForegroundColor;
  6788. if (actual != expected)
  6789. {
  6790. FailedCount++;
  6791. Console.ForegroundColor = ConsoleColor.Red;
  6792. Console.Write(""FAIL: "");
  6793. }
  6794. else
  6795. {
  6796. Console.ForegroundColor = ConsoleColor.Green;
  6797. Console.Write(""PASS: "");
  6798. }
  6799. Console.ForegroundColor = temp;
  6800. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  6801. return actual == expected;
  6802. }
  6803. static void INotifyCollectionChangedMembers()
  6804. {
  6805. Console.WriteLine(""=== INotifyCollectionChangedClass ==="");
  6806. var v = new INotifyCollectionChangedClass();
  6807. //Events
  6808. //Add event
  6809. v.ClearFlag();
  6810. var dele = new System.Collections.Specialized.NotifyCollectionChangedEventHandler(v_CollectionChanged);
  6811. v.CollectionChanged += dele;
  6812. ValidateMethod(v.GetFlagState(), TestMethodCalled.INotifyCollectionChanged_Add_CollectionChanged);
  6813. //Remove event
  6814. v.ClearFlag();
  6815. v.CollectionChanged -= dele;
  6816. ValidateMethod(v.GetFlagState(), TestMethodCalled.INotifyCollectionChanged_Remove_CollectionChanged);
  6817. }
  6818. static void v_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  6819. {
  6820. throw new NotImplementedException();
  6821. }
  6822. static void v_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
  6823. {
  6824. throw new NotImplementedException();
  6825. }
  6826. static int Main()
  6827. {
  6828. INotifyCollectionChangedMembers();
  6829. Console.WriteLine(FailedCount);
  6830. return FailedCount;
  6831. }
  6832. }";
  6833. var verifier = CompileAndVerify(
  6834. source,
  6835. emitOptions: EmitOptions.RefEmitBug,
  6836. additionalRefs: LegacyRefs,
  6837. verify: false);
  6838. verifier.VerifyDiagnostics(
  6839. // (2,1): info CS8019: Unnecessary using directive.
  6840. // using System.Collections.Generic;
  6841. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections.Generic;"),
  6842. // (3,1): info CS8019: Unnecessary using directive.
  6843. // using System.Reflection;
  6844. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  6845. // (4,1): info CS8019: Unnecessary using directive.
  6846. // using System.Linq.Expressions;
  6847. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  6848. // (6,1): info CS8019: Unnecessary using directive.
  6849. // using System.Linq;
  6850. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"),
  6851. // (7,1): info CS8019: Unnecessary using directive.
  6852. // using System.Collections;
  6853. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections;"));
  6854. verifier.VerifyIL("AllMembers.INotifyCollectionChangedMembers",
  6855. @"
  6856. {
  6857. // Code size 82 (0x52)
  6858. .maxstack 3
  6859. .locals init (System.Collections.Specialized.NotifyCollectionChangedEventHandler V_0) //dele
  6860. IL_0000: ldstr ""=== INotifyCollectionChangedClass ===""
  6861. IL_0005: call ""void System.Console.WriteLine(string)""
  6862. IL_000a: newobj ""Windows.Languages.WinRTTest.INotifyCollectionChangedClass..ctor()""
  6863. IL_000f: dup
  6864. IL_0010: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionChangedClass.ClearFlag()""
  6865. IL_0015: ldnull
  6866. IL_0016: ldftn ""void AllMembers.v_CollectionChanged(object, System.Collections.Specialized.NotifyCollectionChangedEventArgs)""
  6867. IL_001c: newobj ""System.Collections.Specialized.NotifyCollectionChangedEventHandler..ctor(object, System.IntPtr)""
  6868. IL_0021: stloc.0
  6869. IL_0022: dup
  6870. IL_0023: ldloc.0
  6871. IL_0024: callvirt ""void System.Collections.Specialized.INotifyCollectionChanged.CollectionChanged.add""
  6872. IL_0029: dup
  6873. IL_002a: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionChangedClass.GetFlagState()""
  6874. IL_002f: ldc.i4.s 37
  6875. IL_0031: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6876. IL_0036: pop
  6877. IL_0037: dup
  6878. IL_0038: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionChangedClass.ClearFlag()""
  6879. IL_003d: dup
  6880. IL_003e: ldloc.0
  6881. IL_003f: callvirt ""void System.Collections.Specialized.INotifyCollectionChanged.CollectionChanged.remove""
  6882. IL_0044: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionChangedClass.GetFlagState()""
  6883. IL_0049: ldc.i4.s 38
  6884. IL_004b: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6885. IL_0050: pop
  6886. IL_0051: ret
  6887. }");
  6888. }
  6889. [Fact]
  6890. public void LegacyCollectionTest19()
  6891. {
  6892. var source =
  6893. @"using Windows.Languages.WinRTTest;
  6894. using System.Collections.Generic;
  6895. using System.Reflection;
  6896. using System.Linq.Expressions;
  6897. using System;
  6898. using System.Linq;
  6899. using System.Collections;
  6900. class AllMembers
  6901. {
  6902. private static int FailedCount = 0;
  6903. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  6904. {
  6905. var temp = Console.ForegroundColor;
  6906. if (actual != expected)
  6907. {
  6908. FailedCount++;
  6909. Console.ForegroundColor = ConsoleColor.Red;
  6910. Console.Write(""FAIL: "");
  6911. }
  6912. else
  6913. {
  6914. Console.ForegroundColor = ConsoleColor.Green;
  6915. Console.Write(""PASS: "");
  6916. }
  6917. Console.ForegroundColor = temp;
  6918. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  6919. return actual == expected;
  6920. }
  6921. static void INotifyCollectionChangedMembers()
  6922. {
  6923. Console.WriteLine(""=== INotifyCollectionChangedClass ==="");
  6924. var v = new INotifyCollectionChangedClass();
  6925. //Events
  6926. //Add event
  6927. v.ClearFlag();
  6928. var dele = new System.Collections.Specialized.NotifyCollectionChangedEventHandler(v_CollectionChanged);
  6929. v.CollectionChanged += dele;
  6930. ValidateMethod(v.GetFlagState(), TestMethodCalled.INotifyCollectionChanged_Add_CollectionChanged);
  6931. //Remove event
  6932. v.ClearFlag();
  6933. v.CollectionChanged -= dele;
  6934. ValidateMethod(v.GetFlagState(), TestMethodCalled.INotifyCollectionChanged_Remove_CollectionChanged);
  6935. }
  6936. static void v_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  6937. {
  6938. throw new NotImplementedException();
  6939. }
  6940. static void v_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
  6941. {
  6942. throw new NotImplementedException();
  6943. }
  6944. static int Main()
  6945. {
  6946. INotifyCollectionChangedMembers();
  6947. Console.WriteLine(FailedCount);
  6948. return FailedCount;
  6949. }
  6950. }";
  6951. var verifier = CompileAndVerify(
  6952. source,
  6953. emitOptions: EmitOptions.RefEmitBug,
  6954. additionalRefs: LegacyRefs,
  6955. verify: false);
  6956. verifier.VerifyDiagnostics(
  6957. // (2,1): info CS8019: Unnecessary using directive.
  6958. // using System.Collections.Generic;
  6959. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections.Generic;"),
  6960. // (3,1): info CS8019: Unnecessary using directive.
  6961. // using System.Reflection;
  6962. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  6963. // (4,1): info CS8019: Unnecessary using directive.
  6964. // using System.Linq.Expressions;
  6965. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  6966. // (6,1): info CS8019: Unnecessary using directive.
  6967. // using System.Linq;
  6968. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"),
  6969. // (7,1): info CS8019: Unnecessary using directive.
  6970. // using System.Collections;
  6971. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections;"));
  6972. verifier.VerifyIL("AllMembers.INotifyCollectionChangedMembers",
  6973. @"
  6974. {
  6975. // Code size 82 (0x52)
  6976. .maxstack 3
  6977. .locals init (System.Collections.Specialized.NotifyCollectionChangedEventHandler V_0) //dele
  6978. IL_0000: ldstr ""=== INotifyCollectionChangedClass ===""
  6979. IL_0005: call ""void System.Console.WriteLine(string)""
  6980. IL_000a: newobj ""Windows.Languages.WinRTTest.INotifyCollectionChangedClass..ctor()""
  6981. IL_000f: dup
  6982. IL_0010: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionChangedClass.ClearFlag()""
  6983. IL_0015: ldnull
  6984. IL_0016: ldftn ""void AllMembers.v_CollectionChanged(object, System.Collections.Specialized.NotifyCollectionChangedEventArgs)""
  6985. IL_001c: newobj ""System.Collections.Specialized.NotifyCollectionChangedEventHandler..ctor(object, System.IntPtr)""
  6986. IL_0021: stloc.0
  6987. IL_0022: dup
  6988. IL_0023: ldloc.0
  6989. IL_0024: callvirt ""void System.Collections.Specialized.INotifyCollectionChanged.CollectionChanged.add""
  6990. IL_0029: dup
  6991. IL_002a: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionChangedClass.GetFlagState()""
  6992. IL_002f: ldc.i4.s 37
  6993. IL_0031: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  6994. IL_0036: pop
  6995. IL_0037: dup
  6996. IL_0038: callvirt ""void Windows.Languages.WinRTTest.INotifyCollectionChangedClass.ClearFlag()""
  6997. IL_003d: dup
  6998. IL_003e: ldloc.0
  6999. IL_003f: callvirt ""void System.Collections.Specialized.INotifyCollectionChanged.CollectionChanged.remove""
  7000. IL_0044: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyCollectionChangedClass.GetFlagState()""
  7001. IL_0049: ldc.i4.s 38
  7002. IL_004b: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  7003. IL_0050: pop
  7004. IL_0051: ret
  7005. }");
  7006. }
  7007. [Fact]
  7008. public void LegacyCollectionTest20()
  7009. {
  7010. var source =
  7011. @"using Windows.Languages.WinRTTest;
  7012. using System.Collections.Generic;
  7013. using System.Reflection;
  7014. using System.Linq.Expressions;
  7015. using System;
  7016. using System.Linq;
  7017. using System.Collections;
  7018. class AllMembers
  7019. {
  7020. private static int FailedCount = 0;
  7021. private static bool ValidateMethod(TestMethodCalled actual, TestMethodCalled expected)
  7022. {
  7023. var temp = Console.ForegroundColor;
  7024. if (actual != expected)
  7025. {
  7026. FailedCount++;
  7027. Console.ForegroundColor = ConsoleColor.Red;
  7028. Console.Write(""FAIL: "");
  7029. }
  7030. else
  7031. {
  7032. Console.ForegroundColor = ConsoleColor.Green;
  7033. Console.Write(""PASS: "");
  7034. }
  7035. Console.ForegroundColor = temp;
  7036. Console.WriteLine(""Expected: {0}, Actual: {1}"", expected, actual);
  7037. return actual == expected;
  7038. }
  7039. static void IPropertyChangedMembers()
  7040. {
  7041. Console.WriteLine(""=== INotifyCollectionChangedClass ==="");
  7042. var v = new INotifyPropertyChangedClass();
  7043. // PropertyChanged
  7044. //Add
  7045. v.ClearFlag();
  7046. var pdeleg = new System.ComponentModel.PropertyChangedEventHandler(v_PropertyChanged);
  7047. v.PropertyChanged += pdeleg;
  7048. ValidateMethod(v.GetFlagState(), TestMethodCalled.INotifyPropertyChanged_Add_PropertyChanged);
  7049. //Remove
  7050. v.ClearFlag();
  7051. v.PropertyChanged -= pdeleg;
  7052. ValidateMethod(v.GetFlagState(), TestMethodCalled.INotifyPropertyChanged_Remove_PropertyChanged);
  7053. }
  7054. static void v_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  7055. {
  7056. throw new NotImplementedException();
  7057. }
  7058. static int Main()
  7059. {
  7060. IPropertyChangedMembers();
  7061. Console.WriteLine(FailedCount);
  7062. return FailedCount;
  7063. }
  7064. }";
  7065. var verifier = CompileAndVerify(
  7066. source,
  7067. emitOptions: EmitOptions.RefEmitBug,
  7068. additionalRefs: LegacyRefs,
  7069. verify: false);
  7070. verifier.VerifyDiagnostics(
  7071. // (2,1): info CS8019: Unnecessary using directive.
  7072. // using System.Collections.Generic;
  7073. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections.Generic;"),
  7074. // (3,1): info CS8019: Unnecessary using directive.
  7075. // using System.Reflection;
  7076. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Reflection;"),
  7077. // (4,1): info CS8019: Unnecessary using directive.
  7078. // using System.Linq.Expressions;
  7079. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq.Expressions;"),
  7080. // (6,1): info CS8019: Unnecessary using directive.
  7081. // using System.Linq;
  7082. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Linq;"),
  7083. // (7,1): info CS8019: Unnecessary using directive.
  7084. // using System.Collections;
  7085. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System.Collections;"));
  7086. verifier.VerifyIL("AllMembers.IPropertyChangedMembers",
  7087. @"
  7088. {
  7089. // Code size 82 (0x52)
  7090. .maxstack 3
  7091. .locals init (System.ComponentModel.PropertyChangedEventHandler V_0) //pdeleg
  7092. IL_0000: ldstr ""=== INotifyCollectionChangedClass ===""
  7093. IL_0005: call ""void System.Console.WriteLine(string)""
  7094. IL_000a: newobj ""Windows.Languages.WinRTTest.INotifyPropertyChangedClass..ctor()""
  7095. IL_000f: dup
  7096. IL_0010: callvirt ""void Windows.Languages.WinRTTest.INotifyPropertyChangedClass.ClearFlag()""
  7097. IL_0015: ldnull
  7098. IL_0016: ldftn ""void AllMembers.v_PropertyChanged(object, System.ComponentModel.PropertyChangedEventArgs)""
  7099. IL_001c: newobj ""System.ComponentModel.PropertyChangedEventHandler..ctor(object, System.IntPtr)""
  7100. IL_0021: stloc.0
  7101. IL_0022: dup
  7102. IL_0023: ldloc.0
  7103. IL_0024: callvirt ""void System.ComponentModel.INotifyPropertyChanged.PropertyChanged.add""
  7104. IL_0029: dup
  7105. IL_002a: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyPropertyChangedClass.GetFlagState()""
  7106. IL_002f: ldc.i4.s 39
  7107. IL_0031: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  7108. IL_0036: pop
  7109. IL_0037: dup
  7110. IL_0038: callvirt ""void Windows.Languages.WinRTTest.INotifyPropertyChangedClass.ClearFlag()""
  7111. IL_003d: dup
  7112. IL_003e: ldloc.0
  7113. IL_003f: callvirt ""void System.ComponentModel.INotifyPropertyChanged.PropertyChanged.remove""
  7114. IL_0044: callvirt ""Windows.Languages.WinRTTest.TestMethodCalled Windows.Languages.WinRTTest.INotifyPropertyChangedClass.GetFlagState()""
  7115. IL_0049: ldc.i4.s 40
  7116. IL_004b: call ""bool AllMembers.ValidateMethod(Windows.Languages.WinRTTest.TestMethodCalled, Windows.Languages.WinRTTest.TestMethodCalled)""
  7117. IL_0050: pop
  7118. IL_0051: ret
  7119. }
  7120. ");
  7121. }
  7122. [Fact]
  7123. public void WinRTCompilationReference()
  7124. {
  7125. var source =
  7126. @"using System.Collections;
  7127. using System.Collections.Generic;
  7128. namespace Test
  7129. {
  7130. public class C : IEnumerable<int>
  7131. {
  7132. IEnumerator IEnumerable.GetEnumerator()
  7133. {
  7134. return null;
  7135. }
  7136. public IEnumerator<int> GetEnumerator()
  7137. {
  7138. return null;
  7139. }
  7140. }
  7141. }";
  7142. var verifier = CompileAndVerify(source,
  7143. options: TestOptions.WinMDObj,
  7144. emitOptions: EmitOptions.RefEmitBug,
  7145. additionalRefs: WinRtRefs);
  7146. verifier.VerifyDiagnostics();
  7147. verifier.VerifyIL("Test.C.GetEnumerator()",
  7148. @"{
  7149. // Code size 6 (0x6)
  7150. .maxstack 1
  7151. .locals init (System.Collections.Generic.IEnumerator<int> V_0)
  7152. IL_0000: ldnull
  7153. IL_0001: stloc.0
  7154. IL_0002: br.s IL_0004
  7155. IL_0004: ldloc.0
  7156. IL_0005: ret
  7157. }");
  7158. var compRef = verifier.Compilation.ToMetadataReference();
  7159. var allRefs = new List<MetadataReference>(WinRtRefs);
  7160. allRefs.Add(compRef);
  7161. source =
  7162. @"using System;
  7163. using Test;
  7164. namespace Test2
  7165. {
  7166. public class D
  7167. {
  7168. public static void Main(string[] args)
  7169. {
  7170. var c = new C();
  7171. var e = c.GetEnumerator();
  7172. }
  7173. }
  7174. }";
  7175. verifier = CompileAndVerify(source,
  7176. emitOptions: EmitOptions.RefEmitBug,
  7177. additionalRefs: allRefs.ToArray());
  7178. verifier.VerifyDiagnostics(
  7179. // (1,1): info CS8019: Unnecessary using directive.
  7180. // using System;
  7181. Diagnostic(ErrorCode.INF_UnusedUsingDirective, "using System;"));
  7182. verifier.VerifyIL("Test2.D.Main",
  7183. @"{
  7184. // Code size 12 (0xc)
  7185. .maxstack 1
  7186. IL_0000: newobj ""Test.C..ctor()""
  7187. IL_0005: callvirt ""System.Collections.Generic.IEnumerator<int> Test.C.GetEnumerator()""
  7188. IL_000a: pop
  7189. IL_000b: ret
  7190. }");
  7191. }
  7192. }
  7193. }