https://bugzilla.novell.com/show_bug.cgi?id=656918
https://bugzilla.novell.com/show_bug.cgi?id=656918#c0 Summary: Unexpected "method argument length mismatch" in System.Delegate.CreateDelegate Classification: Mono Product: Mono: Runtime Version: 2.6.x Platform: Macintosh OS/Version: Mac OS X 10.6 Status: NEW Severity: Normal Priority: P5 - None Component: misc AssignedTo: [email protected] ReportedBy: [email protected] QAContact: [email protected] Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7 I've got a class A that calls a method on interface B, passing to it one of its own methods as sort of a continuation that B is supposed to call when it has a result. The code seems to work fine in practice, but testing it with Moq 4.0.10827, targeting Mono/.NET 3.5, produces the stack trace below. A correspondent on StackOverflow (see http://stackoverflow.com/questions/4328075/moq-verifying-a-method-was-called-with-a-particular-delegate-produces-method-ar) ran the code with MS .NET and it worked fine, so it looks like a bug (or at least an incompatibility) in Mono. Reproducible: Always Steps to Reproduce: 1. Run the unit test below. public class A { readonly B myB; public A (B b) { myB = b; } public void HandleC (C c) { // do something } public void DoFindC () { myB.FindC (HandleC); } } public interface B { // Finds a C and then passes it to handleC void FindC (Action<C> handleC); } public interface C { } [TestFixture()] public class ATest { [Test()] public void TestDoFindC () { Mock<B> bMock = new Mock<B> (); A a = new A(bMock.Object); a.DoFindC(); bMock.Verify(b => b.FindC(a.HandleC)); } } Actual Results: Test fails with the following stack trace: System.ArgumentException : method argument length mismatch at System.Delegate.CreateDelegate (System.Type,object,System.Reflection.MethodInfo,bool) <IL 0x002db, 0x00624> at System.Delegate.CreateDelegate (System.Type,object,System.Reflection.MethodInfo) <IL 0x00004, 0x00015> at (wrapper dynamic-method) System.Runtime.CompilerServices.ExecutionScope.lambda_method (System.Runtime.CompilerServices.ExecutionScope) <IL 0x00015, 0x00079> at Moq.MatcherFactory.CreateMatcher (System.Linq.Expressions.Expression,bool) <IL 0x0008e, 0x0018e> at Moq.MethodCall..ctor (Moq.Mock,System.Func`1<bool>,System.Linq.Expressions.Expression,System.Reflection.MethodInfo,System.Linq.Expressions.Expression[]) <IL 0x0010a, 0x0023f> at Moq.Mock.Verify<Foo.B> (Moq.Mock,System.Linq.Expressions.Expression`1<System.Action`1<Foo.B>>,Moq.Times,string) <0x001af> at Moq.Mock`1<Foo.B>.Verify (System.Linq.Expressions.Expression`1<System.Action`1<Foo.B>>) <0x0005c> at Foo.ATest.TestDoFindC () [0x0003d] in /Users/work/Projects/orbiter-mobile/test-orbiter-core/Controllers/ATest.cs:49 at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (object,object[],System.Exception&) <0x00004> at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <IL 0x000d6, 0x0012a> Expected Results: Test passes. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. You are the assignee for the bug. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
