Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / generic-virtual-invoke.2.cs
1 using System;
2 using System.Reflection;
3
4 public abstract class Base {
5         public abstract object virt<T> ();
6 }
7
8 public class Derived : Base {
9         public override object virt<T> () {
10                 return new T [3];
11         }
12 }
13
14 public class ClassA {}
15
16 public class main {
17         public static int Main () {
18                 Base b = new Derived ();
19
20                 MethodInfo method = typeof (Base).GetMethod ("virt");
21                 Type [] arg_types = { typeof (object), typeof (string), typeof (ClassA),
22                                       typeof (Base), typeof (Derived) };
23                 Type [] array_types = { typeof (object []), typeof (string []), typeof (ClassA []),
24                                         typeof (Base []), typeof (Derived []) };
25
26                 for (int j = 0; j < 100; ++j)
27                         for (int i = 0; i < arg_types.Length; ++i)
28                         {
29                                 Type [] args = { arg_types [i] };
30                                 MethodInfo inflated = method.MakeGenericMethod (args);
31
32                                 if (inflated.Invoke (b, null).GetType () != array_types [i])
33                                         return 1;
34                         }
35
36                 return 0;
37         }
38 }