[Mono-bugs] [Bug 475962] exception thrown from CreateDelegate () when compiling Expression returning a delegate
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Mar 18 12:45:18 EDT 2009
https://bugzilla.novell.com/show_bug.cgi?id=475962
User saiya.v6 at gmail.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=475962#c4
Seiya Yazaki <saiya.v6 at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |saiya.v6 at gmail.com
--- Comment #4 from Seiya Yazaki <saiya.v6 at gmail.com> 2009-03-18 10:45:18 MST ---
I have seen mono 2.2 source code about this issue and tried above codes.
Then I have found that second argument of
MethodCallExpression(Delegate.CreateDelegate) is null.
Second argument of Delegate.CreateDelegate(Type, Object, MethodInfo) is
expected to be not null because the d.testFunc isn't static method call form.
So I think there are bug during translation from C# source code into
ExpressionTree.
Following is a code to see that the second argument for Delegate.CreateDelegate
is null (Based on Zoltan's code).
--- Sample code ---
using System;
using System.Linq.Expressions;
namespace MonoBug
{
class Program
{
public void testFunc() {}
static void Main()
{
Expression<System.Func<Program, Action>> action = (d => d.testFunc);
// System.Delegate.CreateDelegate(System.Type, object,
System.Reflection.MethodInfo)
// Action.Body.Operand.Arguments[1].Value = (null)
var actBody = (UnaryExpression)(action.Body);
var methodCall = (MethodCallExpression)(actBody.Operand);
var methodArg1 = (ConstantExpression)(methodCall.Arguments[1]);
Console.WriteLine(string.Format(
"Action.Body.Operand.Arguments[1].Value = {0}",
methodArg1.Value ?? "(null)"
));
// Compiling this code with csc.exe (.net Fx 3.5),
methodCall.Arguments[1] is result in ParameterExpression of "d". This behavior
is seemed to be expected.
var t = action.Compile();
Program p = new Program();
t(p);
}
}
}
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list