Skip to content

Commit c28ae51

Browse files
committed
add check for AllowPrintIL to #478
1 parent 4b657b7 commit c28ae51

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

src/FastExpressionCompiler/TestTools.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ public static void PrintIL(this MethodInfo method, [CallerMemberName] string tag
154154

155155
public static void PrintIL(this IDelegateDebugInfo diagInfo, [CallerMemberName] string tag = null)
156156
{
157+
if (!AllowPrintIL) return;
158+
157159
SmallMap4<IDelegateDebugInfo, string, RefEq<IDelegateDebugInfo>,
158160
SmallMap4.SingleArrayEntries<IDelegateDebugInfo, string, RefEq<IDelegateDebugInfo>>
159161
> uniquePrinted = default;

test/FastExpressionCompiler.IssueTests/Issue347_InvalidProgramException_on_compiling_an_expression_that_returns_a_record_which_implements_IList.cs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,24 +83,22 @@ public void Test_struct_parameter_in_closure_of_the_nested_lambda()
8383

8484
var f = expr.CompileFast(true, CompilerFlags.EnableDelegateDebugInfo);
8585
Asserts.IsNotNull(f);
86-
f.PrintIL();
8786

88-
var di = f.TryGetDebugInfo();
89-
foreach (var ni in di.EnumerateNestedLambdas())
90-
{
91-
ni.PrintIL("nested");
92-
ni.AssertOpCodes(
93-
OpCodes.Ldarg_0,
94-
OpCodes.Ldfld, // ArrayClosureWithNonPassedParams.NonPassedParams
95-
OpCodes.Ldc_I4_0,
96-
OpCodes.Ldelem_Ref,
97-
OpCodes.Unbox_Any, // NotifyModel
98-
OpCodes.Stloc_0,
99-
OpCodes.Ldloca_S, // 0
100-
OpCodes.Call, // NotifyModel.get_Number1
101-
OpCodes.Ret
102-
);
103-
}
87+
var fd = f.TryGetDebugInfo();
88+
fd.PrintIL();
89+
90+
var nested = fd.EnumerateNestedLambdas().First();
91+
nested.AssertOpCodes(
92+
OpCodes.Ldarg_0,
93+
OpCodes.Ldfld, // ArrayClosureWithNonPassedParams.NonPassedParams
94+
OpCodes.Ldc_I4_0,
95+
OpCodes.Ldelem_Ref,
96+
OpCodes.Unbox_Any, // NotifyModel
97+
OpCodes.Stloc_0,
98+
OpCodes.Ldloca_S, // 0
99+
OpCodes.Call, // NotifyModel.get_Number1
100+
OpCodes.Ret
101+
);
104102

105103
var y = f(m);
106104
Asserts.AreEqual(43, y);

test/FastExpressionCompiler.TestsRunner/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public static void Main()
1616

1717
new LightExpression.UnitTests.NestedLambdasSharedToExpressionCodeStringTest().Run();
1818

19+
new LightExpression.IssueTests.Issue347_InvalidProgramException_on_compiling_an_expression_that_returns_a_record_which_implements_IList().Run();
1920
// new Issue316_in_parameter().Run();
2021
// new LightExpression.IssueTests.Issue55_CompileFast_crash_with_ref_parameter().Run();
2122
// new LightExpression.IssueTests.Issue341_Equality_comparison_between_nullable_and_null_inside_Any_produces_incorrect_compiled_expression().Run();
22-
// new LightExpression.IssueTests.Issue347_InvalidProgramException_on_compiling_an_expression_that_returns_a_record_which_implements_IList().Run();
2323
// new Issue441_Fails_to_pass_Constant_as_call_parameter_by_reference().Run();
2424
// new Issue461_InvalidProgramException_when_null_checking_type_by_ref().Run();
2525

0 commit comments

Comments
 (0)