[Mono-bugs] [Bug 656918] Unexpected "method argument length mismatch" in System.Delegate.CreateDelegate

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Dec 14 06:48:23 EST 2010


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

https://bugzilla.novell.com/show_bug.cgi?id=656918#c2


Jb Evain <jbevain at novell.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|Sys.Core                    |C#
            Version|2.6.x                       |SVN
         AssignedTo|jbevain at novell.com          |msafar at novell.com
            Product|Mono: Class Libraries       |Mono: Compilers

--- Comment #2 from Jb Evain <jbevain at novell.com> 2010-12-14 11:48:22 UTC ---
This is actually a compiler issue.

Test case to be compiled with dmcs:

<<<<<<<<<<<<<<<<<<

using System;
using System.Linq.Expressions;
using System.Reflection;

class Foo {

    public void OnBaz (IBaz baz)
    {
    }
}

interface IBar {
    void RunOnBaz (Action<IBaz> action);
}

interface IBaz {
}

class Program {

    static void Main ()
    {
        var foo = new Foo ();

        Test (bar => bar.RunOnBaz (foo.OnBaz));
    }

    static void Test (Expression<Action<IBar>> expression)
    {
        var flags = BindingFlags.Static | BindingFlags.Instance |
BindingFlags.Public | BindingFlags.NonPublic;

        Console.WriteLine (
            typeof (Expression).GetProperty ("DebugView", flags).GetValue
(expression, null));
    }
}

<<<<<<<<<<<<<<<<<<

dmcs seems to pass a null constant argument to the this parameter of
CreateDelegate.

The binary produced by csc works on .net and on Mono:

<<<<<<<<<<<<<<<<<<
Lambda #Lambda1<System.Action`1[IBar]>(IBar $bar) {
    .Call $bar.RunOnBaz((System.Action`1[IBaz]).Call
System.Delegate.CreateDelegate(
            .Constant<System.Type>(System.Action`1[IBaz]),
           
Constant<Program+<>c__DisplayClass0>(Program+<>c__DisplayClass0).foo,
            .Constant<System.Reflection.MethodInfo>(Void OnBaz(IBaz))))
}
<<<<<<<<<<<<<<<<<<


The binary produced by dmcs doesn't work, neither on .net, nor on Mono:

<<<<<<<<<<<<<<<<<<
Lambda #Lambda1<System.Action`1[IBar]>(IBar $bar) {
    .Call $bar.RunOnBaz((System.Action`1[IBaz]).Call
System.Delegate.CreateDelegate(
            .Constant<System.Type>(System.Action`1[IBaz]),
            null,
            .Constant<System.Reflection.MethodInfo>(Void OnBaz(IBaz))))
}
<<<<<<<<<<<<<<<<<<

-- 
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