Skip to content

Commit

Permalink
4th test for #347 without nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
dadhi committed Oct 2, 2022
1 parent a550263 commit 6855540
Showing 1 changed file with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,41 @@ public class Issue347_InvalidProgramException_on_compiling_an_expression_that_re
{
public int Run()
{
Test_nullable_param_in_closure_of_the_nested_lambda();
Test_struct_parameter_in_closure_of_the_nested_lambda();
// Test_nullable_param_in_closure_of_the_nested_lambda();
// Test_nullable_of_struct_and_struct_field_in_the_nested_lambda();
// Test_original();
return 3;
return 4;
}

[Test]
public void Test_struct_parameter_in_closure_of_the_nested_lambda()
{
var incMethod = GetType().GetMethod(nameof(Inc), BindingFlags.Public | BindingFlags.Static);
var propValue = typeof(NotifyModel).GetProperty(nameof(NotifyModel.Number1));

var p = Parameter(typeof(NotifyModel), "m");
var expr = Lambda<Func<NotifyModel, int>>(
Call(incMethod, Lambda<Func<int>>(Property(p, propValue))),
p
);

expr.PrintCSharp();

var fs = expr.CompileSys();
fs.PrintIL();

var m = new NotifyModel(42, -1);

var x = fs(m);
Assert.AreEqual(43, x);

var f = expr.CompileFast(true, CompilerFlags.EnableDelegateDebugInfo);
Assert.IsNotNull(f);
f.PrintIL();

var y = f(m);
Assert.AreEqual(43, y);
}

[Test]
Expand Down

0 comments on commit 6855540

Please sign in to comment.