2 using System
.Diagnostics
;
3 using System
.Reflection
;
6 public static void staticCrash () {
11 public void callStaticCrash () {
17 public static void callCallStaticCrash
<T
> () {
18 Gen
<T
> gt
= new Gen
<T
> ();
19 gt
.callStaticCrash ();
22 public static bool test (Exception exc
, Type type
) {
23 StackTrace st
= new StackTrace (exc
);
24 for (int i
= 0; i
< st
.FrameCount
; ++i
) {
25 StackFrame sf
= st
.GetFrame (i
);
26 MethodBase m
= sf
.GetMethod ();
27 Type t
= m
.DeclaringType
;
28 if (m
.IsGenericMethod
) {
29 Type
[] margs
= m
.GetGenericArguments ();
30 //Console.WriteLine (m.Name);
31 if (margs
.Length
!= 1)
33 if (margs
[0] != type
)
36 if (t
.IsGenericType
) {
37 Type
[] targs
= t
.GetGenericArguments ();
38 //Console.WriteLine (t.FullName);
39 if (targs
.Length
!= 1)
41 if (targs
[0] != type
)
48 public static int Main () {
50 callCallStaticCrash
<int> ();
51 } catch (Exception exc
) {
52 if (!test (exc
, typeof (int)))
56 callCallStaticCrash
<object> ();
57 } catch (Exception exc
) {
58 if (!test (exc
, typeof (object)))
62 callCallStaticCrash
<string> ();
63 } catch (Exception exc
) {
64 if (!test (exc
, typeof (string)))
68 callCallStaticCrash
<Gen
<string>> ();
69 } catch (Exception exc
) {
70 if (!test (exc
, typeof (Gen
<string>)))