https://bugzilla.novell.com/show_bug.cgi?id=475962

User [email protected] added comment
https://bugzilla.novell.com/show_bug.cgi?id=475962#c4


Seiya Yazaki <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]




--- Comment #4 from Seiya Yazaki <[email protected]>  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.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to