[tests] Add tests for AppDomainUnloadedException handling
[mono.git] / mono / tests / bug-29585.cs
1 namespace TestCase
2 {
3     using System;
4     using System.Linq;
5     using System.Reflection;
6
7
8     public class MainClass
9     {
10         public static int Main()
11         {
12             return new GenericDerived<Param>().FindMethod();
13         }
14     }
15
16
17     interface Param
18     {
19     }
20
21
22     class GenericDerived<T> :
23         Abstract<GenericDerived<T>>
24     {
25         public int FindMethod()
26         {
27             return FindGenericMethod<T>();
28         }
29     }
30
31
32     abstract class Abstract<TDerived>
33         where TDerived : Abstract<TDerived>
34     {
35         protected virtual int FindGenericMethod<T>()
36         {
37             var method = typeof(TDerived)
38                 .GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)
39                 .FirstOrDefault(x => x.Name == "FindGenericMethod" && x.IsGenericMethod);
40
41             Console.WriteLine("TDerived = {0}", typeof(TDerived));
42             Console.WriteLine("method = {0}", method);
43             Console.WriteLine("method.DeclaringType = {0}", method.DeclaringType);
44             Console.WriteLine("method.IsGenericMethod = {0}", method.IsGenericMethod);
45             Console.WriteLine("method.IsGenericMethodDefinition = {0}", method.IsGenericMethodDefinition);
46                         
47                         if (!method.IsGenericMethod)
48                                 return 1;
49                         if (!method.IsGenericMethodDefinition)
50                                 return 2;
51                         return 0;
52         }
53     }
54 }