Skip to content

Commit 5eaf523

Browse files
author
Maksim Volkau
committed
fixed: #476
1 parent cd59c8e commit 5eaf523

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

src/FastExpressionCompiler/FastExpressionCompiler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ namespace FastExpressionCompiler
7777
using System.Diagnostics.CodeAnalysis;
7878
using static System.Environment;
7979
using static CodePrinter;
80-
using System.Data.Odbc;
8180

8281
/// <summary>The flags for the compiler</summary>
8382
[Flags]

test/FastExpressionCompiler.IssueTests/Issue476_System_ExecutionEngineException_with_nullables_on_repeated_calls_to_ConcurrentDictionary copy.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
#if NET8_0_OR_GREATER
12
using System;
3+
using System.Reflection.Emit;
24
using System.Text.Json;
35

46
#if LIGHT_EXPRESSION
@@ -42,12 +44,36 @@ public void Original_case(TestContext t)
4244

4345
// the compiled function should return default(int), yet it calls reader.GetInt32 instead
4446
var a = fs(ref reader);
47+
fs.AssertOpCodes(
48+
OpCodes.Ldarg_1, // at IL_0000
49+
OpCodes.Call, // JsonTokenType Utf8JsonReader.get_TokenType() at IL_0001
50+
OpCodes.Ldc_I4_S, // 11 at IL_0006
51+
OpCodes.Bne_Un, // IL_0019 at IL_0008
52+
OpCodes.Ldc_I4_0, // at IL_0013
53+
OpCodes.Br, // IL_0025 at IL_0014
54+
OpCodes.Ldarg_1, // at IL_0019
55+
OpCodes.Call, // int Utf8JsonReader.GetInt32() at IL_0020
56+
OpCodes.Ret // at IL_0025
57+
);
4558
t.AreEqual(default, a);
4659

4760
var ff = expr.CompileFast(false);
4861
ff.PrintIL(format: ILDecoder.ILFormat.AssertOpCodes);
62+
ff.AssertOpCodes(
63+
OpCodes.Ldarg_1, // at IL_0000
64+
OpCodes.Call, // JsonTokenType Utf8JsonReader.get_TokenType() at IL_0001
65+
OpCodes.Ldc_I4_S, // 11 at IL_0006
66+
OpCodes.Ceq, // at IL_0008
67+
OpCodes.Brfalse, // IL_0021at IL_0010
68+
OpCodes.Ldc_I4_0, // at IL_0015
69+
OpCodes.Br, // IL_0027 at IL_0016
70+
OpCodes.Ldarg_1, // at IL_0021
71+
OpCodes.Call, // int Utf8JsonReader.GetInt32() at IL_0022
72+
OpCodes.Ret // at IL_0027
73+
);
4974

5075
var b = ff(ref reader);
5176
t.AreEqual(default, b);
5277
}
5378
}
79+
#endif

test/FastExpressionCompiler.TestsRunner/Program.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,21 @@ public static void Main()
2525
// new Issue441_Fails_to_pass_Constant_as_call_parameter_by_reference().Run();
2626
// new Issue461_InvalidProgramException_when_null_checking_type_by_ref().Run();
2727

28-
var t = new LightExpression.TestRun(LightExpression.TestFlags.RethrowException);
28+
var lt = new LightExpression.TestRun(LightExpression.TestFlags.RethrowException);
2929

30-
t.Run(new LightExpression.IssueTests.Issue490_Regression_in_compiling_lambdas_with_ref_struct_parameters());
31-
t.Run(new LightExpression.IssueTests.Issue398_Optimize_Switch_with_OpCodes_Switch());
32-
t.Run(new LightExpression.IssueTests.Issue468_Optimize_the_delegate_access_to_the_Closure_object_for_the_modern_NET());
33-
t.Run(new LightExpression.IssueTests.Issue472_TryInterpret_and_Reduce_primitive_arithmetic_and_logical_expressions_during_the_compilation());
34-
t.Run(new LightExpression.IssueTests.Issue473_InvalidProgramException_when_using_Expression_Condition_with_converted_decimal_expression());
35-
t.Run(new LightExpression.IssueTests.Issue476_System_ExecutionEngineException_with_nullables_on_repeated_calls_to_ConcurrentDictionary());
30+
#if NET8_0_OR_GREATER
31+
lt.Run(new LightExpression.IssueTests.Issue490_Regression_in_compiling_lambdas_with_ref_struct_parameters());
32+
#endif
33+
34+
lt.Run(new LightExpression.IssueTests.Issue398_Optimize_Switch_with_OpCodes_Switch());
35+
lt.Run(new LightExpression.IssueTests.Issue468_Optimize_the_delegate_access_to_the_Closure_object_for_the_modern_NET());
36+
lt.Run(new LightExpression.IssueTests.Issue472_TryInterpret_and_Reduce_primitive_arithmetic_and_logical_expressions_during_the_compilation());
37+
lt.Run(new LightExpression.IssueTests.Issue473_InvalidProgramException_when_using_Expression_Condition_with_converted_decimal_expression());
38+
lt.Run(new LightExpression.IssueTests.Issue476_System_ExecutionEngineException_with_nullables_on_repeated_calls_to_ConcurrentDictionary());
3639

3740
#if NET8_0_OR_GREATER
38-
var ts = new TestRun();
39-
ts.Run(new Issue475_Reuse_DynamicMethod_if_possible());
41+
var st = new TestRun();
42+
st.Run(new Issue475_Reuse_DynamicMethod_if_possible());
4043
#endif
4144

4245
RunAllTests();

0 commit comments

Comments
 (0)