提交 f33a8940 编写于 作者: G Gen Lu

Add IL verification to test attribute test

上级 dbff03b7
......@@ -652,7 +652,79 @@ static int MethodWithOutFactAttribute(int x)
True
";
string expectedMethodWithFactAttributeIL = @"{
// Code size 68 (0x44)
.maxstack 4
.locals init (int V_0)
.try
{
IL_0000: ldsfld ""bool[] Program.<MethodWithFactAttribute>1ipayload__Field""
IL_0005: brtrue.s IL_001c
IL_0007: ldsfld ""System.Guid <PrivateImplementationDetails>.MVID""
IL_000c: ldtoken ""int Program.MethodWithFactAttribute(int)""
IL_0011: ldsflda ""bool[] Program.<MethodWithFactAttribute>1ipayload__Field""
IL_0016: ldc.i4.3
IL_0017: call ""void Microsoft.CodeAnalysis.Runtime.Instrumentation.CreatePayload(System.Guid, int, ref bool[], int)""
IL_001c: ldsfld ""bool[] Program.<MethodWithFactAttribute>1ipayload__Field""
IL_0021: ldc.i4.0
IL_0022: ldc.i4.1
IL_0023: stelem.i1
IL_0024: ldarg.0
IL_0025: ldc.i4.1
IL_0026: add
IL_0027: ldsfld ""bool[] Program.<MethodWithFactAttribute>1ipayload__Field""
IL_002c: ldc.i4.1
IL_002d: ldc.i4.1
IL_002e: stelem.i1
IL_002f: ldc.i4.1
IL_0030: add
IL_0031: ldsfld ""bool[] Program.<MethodWithFactAttribute>1ipayload__Field""
IL_0036: ldc.i4.2
IL_0037: ldc.i4.1
IL_0038: stelem.i1
IL_0039: stloc.0
IL_003a: leave.s IL_0042
}
finally
{
IL_003c: call ""void Microsoft.CodeAnalysis.Runtime.Instrumentation.FlushPayload()""
IL_0041: endfinally
}
IL_0042: ldloc.0
IL_0043: ret
}";
string expectedMethodWithOutFactAttributeIL = @"{
// Code size 58 (0x3a)
.maxstack 4
IL_0000: ldsfld ""bool[] Program.<MethodWithOutFactAttribute>2ipayload__Field""
IL_0005: brtrue.s IL_001c
IL_0007: ldsfld ""System.Guid <PrivateImplementationDetails>.MVID""
IL_000c: ldtoken ""int Program.MethodWithOutFactAttribute(int)""
IL_0011: ldsflda ""bool[] Program.<MethodWithOutFactAttribute>2ipayload__Field""
IL_0016: ldc.i4.3
IL_0017: call ""void Microsoft.CodeAnalysis.Runtime.Instrumentation.CreatePayload(System.Guid, int, ref bool[], int)""
IL_001c: ldsfld ""bool[] Program.<MethodWithOutFactAttribute>2ipayload__Field""
IL_0021: ldc.i4.0
IL_0022: ldc.i4.1
IL_0023: stelem.i1
IL_0024: ldarg.0
IL_0025: ldc.i4.1
IL_0026: add
IL_0027: ldsfld ""bool[] Program.<MethodWithOutFactAttribute>2ipayload__Field""
IL_002c: ldc.i4.1
IL_002d: ldc.i4.1
IL_002e: stelem.i1
IL_002f: ldc.i4.1
IL_0030: add
IL_0031: ldsfld ""bool[] Program.<MethodWithOutFactAttribute>2ipayload__Field""
IL_0036: ldc.i4.2
IL_0037: ldc.i4.1
IL_0038: stelem.i1
IL_0039: ret
}";
CompilationVerifier verifier = CompileAndVerify(source + InstrumentationHelperSource + XunitFactAttributeSource, emitOptions: EmitOptions.Default.WithInstrument("Test.Flag"), expectedOutput: expectedOutput);
verifier.VerifyIL("Program.MethodWithFactAttribute", expectedMethodWithFactAttributeIL);
verifier.VerifyIL("Program.MethodWithOutFactAttribute", expectedMethodWithOutFactAttributeIL);
}
private CompilationVerifier CompileAndVerify(string source, EmitOptions emitOptions, string expectedOutput = null)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册