var del = Delegate.Remove (del1, del2);
}
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void CreateDelegateThrowsAnArgumentExceptionWhenCalledWithAnOpenGeneric()
+ {
+ var m = GetType().GetMethod("AnyGenericMethod");
+ Delegate.CreateDelegate(typeof(Action), this, m);
+ }
+
+ public void AnyGenericMethod<T>()
+ {
+ }
+
static bool Int32D2 (int x, int y)
{
return (x & y) == y;
}
if (sig->generic_param_count && method->wrapper_type == MONO_WRAPPER_NONE) {
- if (!method->is_inflated)
- mono_raise_exception(mono_get_exception_argument("method", " Cannot bind to the target method because its signature differs from that of the delegate type"));
+ if (!method->is_inflated) {
+ mono_set_pending_exception(mono_get_exception_argument("method", " Cannot bind to the target method because its signature differs from that of the delegate type"));
+ return NULL;
+ }
}
delegate = mono_object_new_checked (mono_object_domain (type), delegate_class, &error);
bug-323114.cs \
bug-Xamarin-5278.cs \
interlocked.cs \
- delegate-argument-exception.cs \
delegate-async-exit.cs \
delegate-delegate-exit.cs \
delegate-exit.cs \
+++ /dev/null
-using System;
-
-class Test {
- public static int Main () {
- return new Test().CallCreateDelegate();
- }
-
- public int CallCreateDelegate() {
- try {
- var m = typeof(Test).GetMethod("Foo");
- var a = (Action) Delegate.CreateDelegate(typeof(Action), this, m);
- a();
- }
- catch (ArgumentException) {
- return 0;
- }
-
- return 1;
- }
-
- public void Foo<T>()
- {
- }
-}
\ No newline at end of file