Пример #1
0
        private static void VerifyIL(CompilationVerifier verifier, MethodSymbol method, string expectedIL)
        {
            var methodData = verifier.TestData.Methods[method];
            var actualIL   = verifier.VisualizeIL(methodData, realIL: true);

            AssertEx.AssertEqualToleratingWhitespaceDifferences(expectedIL, actualIL);
        }
Пример #2
0
        private string GetFieldLoadsAndStores(CompilationVerifier c, string qualifiedMethodName)
        {
            var actualLines = c.VisualizeIL(qualifiedMethodName).Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            return(string.Join(Environment.NewLine,
                               from pair in actualLines.Zip(actualLines.Skip(1), (line1, line2) => new { line1, line2 })
                               where pair.line2.Contains("ldfld") || pair.line2.Contains("stfld")
                               select pair.line1.Trim() + Environment.NewLine + pair.line2.Trim()));
        }
Пример #3
0
        private string GetFieldLoadsAndStores(CompilationVerifier c, string qualifiedMethodName)
        {
            var actualLines = c.VisualizeIL(qualifiedMethodName).Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            return string.Join(Environment.NewLine,
                from pair in actualLines.Zip(actualLines.Skip(1), (line1, line2) => new { line1, line2 })
                where pair.line2.Contains("ldfld") || pair.line2.Contains("stfld")
                select pair.line1.Trim() + Environment.NewLine + pair.line2.Trim());
        }
Пример #4
0
 private static void VerifyIL(CompilationVerifier verifier, MethodSymbol method, string expectedIL)
 {
     var methodData = verifier.TestData.Methods[method];
     var actualIL = verifier.VisualizeIL(methodData, realIL: true);
     AssertEx.AssertEqualToleratingWhitespaceDifferences(expectedIL, actualIL);
 }
        private static void AssertInstrumented(CompilationVerifier verifier, string qualifiedMethodName, bool expected = true)
        {
            string il = verifier.VisualizeIL(qualifiedMethodName);

            // Tests using this helper are constructed such that instrumented methods contain a call to CreatePayload, 
            // lambdas a reference to payload bool array.
            bool instrumented = il.Contains("CreatePayload") || il.Contains("bool[]");

            Assert.True(expected == instrumented, $"Method '{qualifiedMethodName}' should {(expected ? "be" : "not be")} instrumented. Actual IL:{Environment.NewLine}{il}");
        }