-
-
Notifications
You must be signed in to change notification settings - Fork 91
Closed
Description
The following throws an InvalidProgramException
public static class Numbers
{
public static int GetInt() => 40;
public static int AddTwo(ref int value) => value + 2;
}
public class Program
{
public static void Main()
{
var getIntMethod = typeof(Numbers).GetMethod(nameof(Numbers.GetInt));
var addTwoMethod = typeof(Numbers).GetMethod(nameof(Numbers.AddTwo));
var getIntCall = Expression.Call(getIntMethod);
var expr = Expression.Call(addTwoMethod, getIntCall);
var lambda = Expression.Lambda<Func<int>>(expr).CompileFast();
var result = lambda();
}
}
Expression.Compile
is fine with it, but FEC doesn't like it.
The issue is easy to work around by storing the result of the first method in a
variable and passing the variable to the second method, but I wanted to pass the
error along.
Here is a small dotnetfiddle https://dotnetfiddle.net/PWeV9P that demonstrates the issue.
Thank you for a really nice library.