[Mono-bugs] [Bug 695978] New: Error in Delegate.CreateDelegate for ValueType Instance method without target
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed May 25 09:12:08 EDT 2011
https://bugzilla.novell.com/show_bug.cgi?id=695978
https://bugzilla.novell.com/show_bug.cgi?id=695978#c0
Summary: Error in Delegate.CreateDelegate for ValueType
Instance method without target
Classification: Mono
Product: Mono: Class Libraries
Version: 2.10.x
Platform: All
OS/Version: All
Status: NEW
Severity: Critical
Priority: P5 - None
Component: CORLIB
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: goldywhite at gmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24
(KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24
for value types when no target specified in Delegate.CreateDelegate method,
first delegate parameter must be passed by ref.
Reproducible: Always
Steps to Reproduce:
1. define:
struct a { public void test() { } }
delegate void ActionRef (ref a _this);
2. call:
var d = (ActionRef) Delegate.CreateDelegate(typeof (ActionRef), typeof
(a).GetMethod("test"));
3. call:
var d = (Action) Delegate.CreateDelegate(typeof (Action), typeof
(a).GetMethod("test"));
d();
Actual Results:
2. Unhandled Exception: System.ArgumentException: method arguments are
incompatible
at System.Delegate.CreateDelegate (System.Type type, System.Object
firstArgument, System.Reflection.MethodInfo method, Boolean throwOnBindFailure,
Boolean allowClosed) [0x0033d] in
/usr/src/redhat/BUILD/mono-2.10.2/mcs/class/corlib/System/Delegate.cs:264
3. Unhandled Exception: System.InvalidProgramException: Invalid IL code in
(wrapper delegate-invoke) <Module>:...
Expected Results:
2. no errors
3. Unhandled Exception: System.ArgumentException: method arguments are
incompatible
at System.Delegate.CreateDelegate (System.Type type, System.Object
firstArgument, System.Reflection.MethodInfo method, Boolean throwOnBindFailure,
Boolean allowClosed) [0x0033d] in
/usr/src/redhat/BUILD/mono-2.10.2/mcs/class/corlib/System/Delegate.cs:264
i think that replace of following 2 lines will fix problem:
GNU nano 1.3.12 File:
/usr/src/redhat/BUILD/mono-2.10.2/mcs/class/corlib/System/Delegate.cs
if (!method.IsStatic) {
if (args.Length + 1 == delargs.Length)
{
// The first argument should
match this
argsMatch = arg_type_match
(delargs [0].ParameterType, method.DeclaringType);
for (int i = 0; i <
args.Length; i++)
argsMatch &=
arg_type_match (delargs [i + 1].ParameterType, args [i].ParameterType);
} else {
// closed over a null reference
argsMatch = allowClosed;
for (int i = 0; i <
args.Length; i++)
argsMatch &=
arg_type_match (delargs [i].ParameterType, args [i].ParameterType);
}
} else {
if (delargs.Length + 1 == args.Length)
{
// closed over a null reference
argsMatch = !args
[0].ParameterType.IsValueType && allowClosed;
for (int i = 0; i <
delargs.Length; i++)
argsMatch &=
arg_type_match (delargs [i].ParameterType, args [i + 1].ParameterType);
} else {
> argsMatch = true;
> for (int i = 0; i < args.Length; i++)
argsMatch &=
arg_type_match (delargs [i].ParameterType, args [i].ParameterType);
}
}
[ line 247/556 (44%), col
1/66 (1%), char 7763/15972 (48%) ]
with
argsMatch = arg_type_match (delargs [i].ParameterType, args
[i].ParameterType.MakeByRefType());
for (int i = 1; i < args.Length; i++)
--
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.
More information about the mono-bugs
mailing list