Update Haiku support (#15674)
[mono-project.git] / mono / tests / delegate15.cs
blob52163fc892efbf39c7591327c9b817b0c6c403b4
1 using System;
2 using System.Reflection;
4 public static class Program
6 class BaseType <T1, T2>
8 private T1 a;
9 private T2 b;
11 public static void blah () { }
14 class DerivedType <T> : BaseType <string, T>
16 public static void blah2 () { }
19 public static int Main (string[] args)
21 MethodInfo method = typeof (BaseType<,>).GetMethod ("blah");
22 Delegate del = Delegate.CreateDelegate (typeof (Action), null, method, true);
23 bool caught = false;
25 try {
26 ((Action)del) ();
27 } catch (InvalidOperationException) {
28 caught = true;
31 if (!caught) {
32 Console.WriteLine ("1");
33 return 1;
36 method = typeof (DerivedType<>).GetMethod ("blah2");
37 del = Delegate.CreateDelegate (typeof (Action), null, method, true);
38 caught = false;
40 try {
41 ((Action)del) ();
42 } catch (InvalidOperationException) {
43 caught = true;
46 if (!caught) {
47 Console.WriteLine ("2");
48 return 2;
51 Console.WriteLine ("OK");
52 return 0;