2 using System
.Reflection
;
3 using System
.Runtime
.InteropServices
;
7 [DllImport ("libtest")]
8 public static extern int test_method_thunk (int test_id
, IntPtr testMethodHandle
,
9 IntPtr createObjectHandle
);
11 static void RunTests(int series
, Type type
)
13 const string Prefix
= "Test";
14 MethodInfo createObjectMethod
= type
.GetMethod ("CreateObject");
16 foreach (MethodInfo mi
in type
.GetMethods ()) {
17 string name
= mi
.Name
;
18 if (!name
.StartsWith (Prefix
))
21 int id
= Convert
.ToInt32 (name
.Substring (Prefix
.Length
));
23 int res
= test_method_thunk (series
+ id
, mi
.MethodHandle
.Value
, createObjectMethod
.MethodHandle
.Value
);
26 Console
.WriteLine ("{0} returned {1}", mi
, res
);
27 Environment
.Exit ((id
<< 3) + res
);
32 public static int Main ()
34 RunTests (0, typeof (Test
));
35 RunTests (100, typeof (TestStruct
));
39 public static object CreateObject ()
44 public static void Test0 ()
48 public static int Test1 ()
53 public static string Test2 (string s
)
58 public string Test3 (string a
)
63 public int Test4 (string a
, int i
)
68 public int Test5 (string a
, int i
)
70 throw new NotImplementedException ();
73 public bool Test6 (byte a1
, short a2
, int a3
, long a4
, float a5
, double a6
, string a7
)
79 (Math
.Abs (a5
- 3.1415) < 0.001) &&
80 (Math
.Abs (a6
- 3.1415) < 0.001) &&
84 public static long Test7 ()
86 return Int64
.MaxValue
;
89 public static void Test8 (ref byte a1
, ref short a2
, ref int a3
, ref long a4
, ref float a5
, ref double a6
, ref string a7
)
100 public static void Test9 (ref byte a1
, ref short a2
, ref int a3
, ref long a4
, ref float a5
, ref double a6
, ref string a7
)
102 throw new NotImplementedException ();
105 public static void Test10 (ref Test obj
)
112 public struct TestStruct
117 public static object CreateObject ()
119 return new TestStruct ();
122 public static bool Test0 (TestStruct s
)
124 bool res
= s
.A
== 42 && Math
.Abs (s
.B
- 3.1415) < 0.001;
126 /* these changes must not be visible in unmanaged code */
133 public static void Test1 (ref TestStruct s
)
139 public static TestStruct
Test2 ()
141 TestStruct s
= new TestStruct ();