2 using System.Diagnostics;
3 using System.Reflection;
6 public static void staticCrash () {
11 public void callStaticCrash () {
18 public void Throw () {
19 throw new Exception ();
22 public void Throw<T3> () {
23 throw new Exception ();
27 class Bar<T> : Foo<object, T> {
31 public static void callCallStaticCrash<T> () {
32 Gen<T> gt = new Gen<T> ();
33 gt.callStaticCrash ();
36 public static bool test (Exception exc, Type type) {
37 StackTrace st = new StackTrace (exc);
38 for (int i = 0; i < st.FrameCount; ++i) {
39 StackFrame sf = st.GetFrame (i);
40 MethodBase m = sf.GetMethod ();
41 Type t = m.DeclaringType;
42 if (m.IsGenericMethod) {
43 Type[] margs = m.GetGenericArguments ();
44 //Console.WriteLine (m.Name);
45 if (margs.Length != 1)
47 if (margs [0] != type)
50 if (t.IsGenericType) {
51 Type[] targs = t.GetGenericArguments ();
52 //Console.WriteLine (t.FullName);
53 if (targs.Length != 1)
55 if (targs [0] != type)
62 public static int Main () {
64 callCallStaticCrash <int> ();
65 } catch (Exception exc) {
66 if (!test (exc, typeof (int)))
70 callCallStaticCrash <object> ();
71 } catch (Exception exc) {
72 if (!test (exc, typeof (object)))
76 callCallStaticCrash <string> ();
77 } catch (Exception exc) {
78 if (!test (exc, typeof (string)))
82 callCallStaticCrash <Gen<string>> ();
83 } catch (Exception exc) {
84 if (!test (exc, typeof (Gen<string>)))
88 // Exception thrown in inherited method with different generic context
91 new Bar <string> ().Throw ();
92 } catch (Exception ex) {
93 Console.WriteLine (new StackTrace (ex));
97 new Bar <string> ().Throw<Bar<string>> ();
98 } catch (Exception ex) {
99 Console.WriteLine (new StackTrace (ex));