2 // Copyright 2011 Xamarin Inc (http://www.xamarin.com).
7 using System.Runtime.InteropServices;
8 using System.Runtime.CompilerServices;
9 using System.Reflection.Emit;
15 public static int delegate_test (int a)
23 public int delegate_test_instance (int a)
28 [StructLayout (LayoutKind.Sequential)]
29 public struct SimpleStruct {
34 [MarshalAs(UnmanagedType.LPWStr)]
38 [StructLayout (LayoutKind.Sequential)]
39 public struct SimpleStructGen<T> {
44 [MarshalAs(UnmanagedType.LPWStr)]
48 [StructLayout (LayoutKind.Sequential)]
49 public struct SimpleStruct2 {
60 [StructLayout (LayoutKind.Sequential, Size=0)]
61 public struct EmptyStruct {
64 [StructLayout (LayoutKind.Sequential, Size=1)]
65 public struct EmptyStructCpp {
68 [StructLayout (LayoutKind.Sequential)]
69 public struct DelegateStruct {
71 public SimpleDelegate del;
72 [MarshalAs(UnmanagedType.FunctionPtr)]
73 public SimpleDelegate del2;
74 [MarshalAs(UnmanagedType.FunctionPtr)]
75 public SimpleDelegate del3;
78 [StructLayout (LayoutKind.Sequential)]
79 public struct SingleDoubleStruct {
83 /* sparcv9 has complex conventions when passing structs with doubles in them
84 by value, some simple tests for them */
85 [StructLayout (LayoutKind.Sequential)]
91 [StructLayout (LayoutKind.Sequential)]
92 public struct MixedPoint {
97 [StructLayout (LayoutKind.Sequential)]
98 public struct TinyStruct {
99 public TinyStruct (int i)
106 [StructLayout (LayoutKind.Sequential)]
107 public class SimpleClass {
118 [StructLayout (LayoutKind.Sequential)]
119 public class EmptyClass {
122 [StructLayout (LayoutKind.Sequential)]
123 public struct LongAlignStruct {
129 [StructLayout(LayoutKind.Sequential)]
130 public class BlittableClass
136 [StructLayout (LayoutKind.Sequential)]
143 [StructLayout(LayoutKind.Sequential)]
151 public AsAnyStruct(int i, int j, int k, String s) {
159 [StructLayout(LayoutKind.Sequential)]
167 public AsAnyClass(int i, int j, int k, String s) {
174 [DllImport ("libnot-found", EntryPoint="not_found")]
175 public static extern int mono_library_not_found ();
177 [DllImport ("libtest", EntryPoint="not_found")]
178 public static extern int mono_entry_point_not_found ();
180 [DllImport ("libtest.dll", EntryPoint="mono_test_marshal_char")]
181 public static extern int mono_test_marshal_char_2 (char a1);
183 [DllImport ("test", EntryPoint="mono_test_marshal_char")]
184 public static extern int mono_test_marshal_char_3 (char a1);
186 [DllImport ("libtest", EntryPoint="mono_test_marshal_char")]
187 public static extern int mono_test_marshal_char (char a1);
189 [DllImport ("libtest", EntryPoint="mono_test_marshal_char_array", CharSet=CharSet.Unicode)]
190 public static extern int mono_test_marshal_char_array (char[] a1);
192 [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_byref")]
193 public static extern int mono_test_marshal_bool_byref (int a, ref bool b, int c);
195 [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_in_as_I1_U1")]
196 public static extern int mono_test_marshal_bool_in_as_I1 ([MarshalAs (UnmanagedType.I1)] bool bTrue, [MarshalAs (UnmanagedType.I1)] bool bFalse);
198 [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_in_as_I1_U1")]
199 public static extern int mono_test_marshal_bool_in_as_U1 ([MarshalAs (UnmanagedType.U1)] bool bTrue, [MarshalAs (UnmanagedType.U1)] bool bFalse);
201 [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_out_as_I1_U1")]
202 public static extern int mono_test_marshal_bool_out_as_I1 ([MarshalAs (UnmanagedType.I1)] out bool bTrue, [MarshalAs (UnmanagedType.I1)] out bool bFalse);
204 [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_out_as_I1_U1")]
205 public static extern int mono_test_marshal_bool_out_as_U1 ([MarshalAs (UnmanagedType.U1)] out bool bTrue, [MarshalAs (UnmanagedType.U1)] out bool bFalse);
207 [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_ref_as_I1_U1")]
208 public static extern int mono_test_marshal_bool_ref_as_I1 ([MarshalAs (UnmanagedType.I1)] ref bool bTrue, [MarshalAs (UnmanagedType.I1)] ref bool bFalse);
210 [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_ref_as_I1_U1")]
211 public static extern int mono_test_marshal_bool_ref_as_U1 ([MarshalAs (UnmanagedType.U1)] ref bool bTrue, [MarshalAs (UnmanagedType.U1)] ref bool bFalse);
213 [DllImport ("libtest", EntryPoint="mono_test_marshal_array")]
214 public static extern int mono_test_marshal_array (int [] a1);
216 [DllImport ("libtest", EntryPoint="mono_test_marshal_empty_string_array")]
217 public static extern int mono_test_marshal_empty_string_array (string [] a1);
219 [DllImport ("libtest", EntryPoint="mono_test_marshal_string_array")]
220 public static extern int mono_test_marshal_string_array (string [] a1);
222 [DllImport ("libtest", EntryPoint="mono_test_marshal_unicode_string_array", CharSet=CharSet.Unicode)]
223 public static extern int mono_test_marshal_unicode_string_array (string [] a1, [MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr)]string [] a2);
225 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_array")]
226 public static extern int mono_test_marshal_stringbuilder_array (StringBuilder [] a1);
228 [DllImport ("libtest", EntryPoint="mono_test_marshal_inout_array")]
229 public static extern int mono_test_marshal_inout_array ([In, Out] int [] a1);
231 [DllImport ("libtest", EntryPoint="mono_test_marshal_out_array")]
232 public static extern int mono_test_marshal_out_array ([Out] [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int [] a1, int n);
234 [DllImport ("libtest", EntryPoint="mono_test_marshal_out_byref_array_out_size_param")]
235 public static extern int mono_test_marshal_out_byref_array_out_size_param ([Out] [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] out int [] a1, out int n);
237 [DllImport ("libtest", EntryPoint="mono_test_marshal_inout_nonblittable_array", CharSet = CharSet.Unicode)]
238 public static extern int mono_test_marshal_inout_nonblittable_array ([In, Out] char [] a1);
240 [DllImport ("libtest", EntryPoint="mono_test_marshal_struct")]
241 public static extern int mono_test_marshal_struct (SimpleStruct ss);
243 [DllImport ("libtest", EntryPoint="mono_test_marshal_struct")]
244 public static extern int mono_test_marshal_struct_gen (SimpleStructGen<string> ss);
246 [DllImport ("libtest", EntryPoint="mono_test_marshal_struct2")]
247 public static extern int mono_test_marshal_struct2 (SimpleStruct2 ss);
249 [DllImport ("libtest", EntryPoint="mono_test_marshal_struct2_2")]
250 public static extern int mono_test_marshal_struct2_2 (int i, int j, int k, SimpleStruct2 ss);
252 [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_struct")]
253 public static extern int mono_test_marshal_byref_struct (ref SimpleStruct ss, bool a, bool b, bool c, String d);
255 [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_struct")]
256 public static extern int mono_test_marshal_byref_struct_in ([In] ref SimpleStruct ss, bool a, bool b, bool c, String d);
258 [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_struct")]
259 public static extern int mono_test_marshal_byref_struct_inout ([In, Out] ref SimpleStruct ss, bool a, bool b, bool c, String d);
261 [DllImport ("libtest", EntryPoint="mono_test_marshal_point")]
262 public static extern int mono_test_marshal_point (Point p);
264 [DllImport ("libtest", EntryPoint="mono_test_marshal_mixed_point")]
265 public static extern int mono_test_marshal_mixed_point (MixedPoint p);
267 [DllImport ("libtest", EntryPoint="mono_test_empty_struct")]
268 public static extern int mono_test_empty_struct (int a, EmptyStruct es, int b);
270 [DllImport ("libtest", EntryPoint="mono_test_return_empty_struct")]
271 public static extern EmptyStruct mono_test_return_empty_struct (int a);
273 [DllImport ("libtest", EntryPoint="mono_test_return_empty_struct")]
274 public static extern EmptyStructCpp mono_test_return_empty_struct_cpp (int a);
276 [DllImport ("libtest", EntryPoint="mono_test_marshal_lpstruct")]
277 public static extern int mono_test_marshal_lpstruct ([In, MarshalAs(UnmanagedType.LPStruct)] SimpleStruct ss);
279 [DllImport ("libtest", EntryPoint="mono_test_marshal_lpstruct_blittable")]
280 public static extern int mono_test_marshal_lpstruct_blittable ([In, MarshalAs(UnmanagedType.LPStruct)] Point p);
282 [DllImport ("libtest", EntryPoint="mono_test_marshal_struct_array")]
283 public static extern int mono_test_marshal_struct_array (SimpleStruct2[] ss);
285 [DllImport ("libtest", EntryPoint="mono_test_marshal_long_align_struct_array")]
286 public static extern int mono_test_marshal_long_align_struct_array (LongAlignStruct[] ss);
288 [DllImport ("libtest", EntryPoint="mono_test_marshal_class")]
289 public static extern SimpleClass mono_test_marshal_class (int i, int j, int k, SimpleClass ss, int l);
291 [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_class")]
292 public static extern int mono_test_marshal_byref_class (ref SimpleClass ss);
294 [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate")]
295 public static extern int mono_test_marshal_delegate (SimpleDelegate d);
297 [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate_struct")]
298 public static extern DelegateStruct mono_test_marshal_delegate_struct (DelegateStruct d);
300 [DllImport ("libtest", EntryPoint="mono_test_marshal_return_delegate")]
301 public static extern SimpleDelegate mono_test_marshal_return_delegate (SimpleDelegate d);
303 [DllImport ("libtest", EntryPoint="mono_test_return_vtype")]
304 public static extern SimpleStruct mono_test_return_vtype (IntPtr i);
306 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder")]
307 public static extern void mono_test_marshal_stringbuilder (StringBuilder sb, int len);
309 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_default")]
310 public static extern void mono_test_marshal_stringbuilder_default (StringBuilder sb, int len);
312 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_append")]
313 public static extern void mono_test_marshal_stringbuilder_append (StringBuilder sb, int len);
315 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_unicode", CharSet=CharSet.Unicode)]
316 public static extern void mono_test_marshal_stringbuilder_unicode (StringBuilder sb, int len);
318 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_out")]
319 public static extern void mono_test_marshal_stringbuilder_out (out StringBuilder sb);
321 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_ref")]
322 public static extern int mono_test_marshal_stringbuilder_ref (ref StringBuilder sb);
324 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_out_unicode", CharSet=CharSet.Unicode)]
325 public static extern void mono_test_marshal_stringbuilder_out_unicode (out StringBuilder sb);
327 [DllImport ("libtest", EntryPoint="mono_test_last_error", SetLastError=true)]
328 public static extern void mono_test_last_error (int err);
330 [DllImport ("libtest", EntryPoint="mono_test_asany")]
331 public static extern int mono_test_asany ([MarshalAs (UnmanagedType.AsAny)] object o, int what);
333 [DllImport ("libtest", EntryPoint="mono_test_asany", CharSet=CharSet.Unicode)]
334 public static extern int mono_test_asany_unicode ([MarshalAs (UnmanagedType.AsAny)] object o, int what);
336 [DllImport("libtest", EntryPoint="mono_test_marshal_asany_in")]
337 static extern void mono_test_asany_in ([MarshalAs(UnmanagedType.AsAny)][In] object obj);
339 [DllImport("libtest", EntryPoint="mono_test_marshal_asany_out")]
340 static extern void mono_test_asany_out ([MarshalAs(UnmanagedType.AsAny)][Out] object obj);
341 [DllImport("libtest", EntryPoint="mono_test_marshal_asany_inout")]
342 static extern void mono_test_asany_inout ([MarshalAs(UnmanagedType.AsAny)][In, Out] object obj);
344 [DllImport ("libtest")]
345 static extern int class_marshal_test0 (SimpleObj obj);
347 [DllImport ("libtest")]
348 static extern void class_marshal_test1 (out SimpleObj obj);
350 [DllImport ("libtest")]
351 static extern int class_marshal_test4 (SimpleObj obj);
353 [DllImport ("libtest")]
354 static extern int string_marshal_test0 (string str);
356 [DllImport ("libtest")]
357 static extern void string_marshal_test1 (out string str);
359 [DllImport ("libtest")]
360 static extern int string_marshal_test2 (ref string str);
362 [DllImport ("libtest")]
363 static extern int string_marshal_test3 (string str);
365 public delegate int SimpleDelegate (int a);
367 public static int Main (string[] args) {
368 return TestDriver.RunTests (typeof (Tests), args);
371 public static int test_0_marshal_char () {
372 return mono_test_marshal_char ('a');
375 public static int test_0_marshal_char_array () {
376 // a unicode char[] is implicitly marshalled as [Out]
377 char[] buf = new char [32];
378 mono_test_marshal_char_array (buf);
379 string s = new string (buf);
380 if (s.StartsWith ("abcdef"))
386 public static int test_1225_marshal_array () {
387 int [] a1 = new int [50];
388 for (int i = 0; i < 50; i++)
391 return mono_test_marshal_array (a1);
394 public static int test_1225_marshal_inout_array () {
395 int [] a1 = new int [50];
396 for (int i = 0; i < 50; i++)
399 int res = mono_test_marshal_inout_array (a1);
401 for (int i = 0; i < 50; i++)
402 if (a1 [i] != 50 - i) {
403 Console.WriteLine ("X: " + i + " " + a1 [i]);
410 public static int test_0_marshal_out_array () {
411 int [] a1 = new int [50];
413 int res = mono_test_marshal_out_array (a1, 0);
415 for (int i = 0; i < 50; i++)
417 Console.WriteLine ("X: " + i + " " + a1 [i]);
424 public static int test_0_marshal_out_byref_array_out_size_param () {
428 int res = mono_test_marshal_out_byref_array_out_size_param (out a1, out len);
431 for (int i = 0; i < len; i++)
437 public static int test_0_marshal_inout_nonblittable_array () {
438 char [] a1 = new char [10];
439 for (int i = 0; i < 10; i++)
440 a1 [i] = "Hello, World" [i];
442 int res = mono_test_marshal_inout_nonblittable_array (a1);
444 for (int i = 0; i < 10; i++)
451 public static int test_0_marshal_struct () {
452 SimpleStruct ss = new SimpleStruct ();
456 return mono_test_marshal_struct (ss);
459 public static int test_0_marshal_struct_gen () {
460 SimpleStructGen<string> ss = new SimpleStructGen<string> ();
464 return mono_test_marshal_struct_gen (ss);
467 public static int test_0_marshal_struct2 () {
468 SimpleStruct2 ss2 = new SimpleStruct2 ();
476 return mono_test_marshal_struct2 (ss2);
479 public static int test_0_marshal_struct3 () {
480 SimpleStruct2 ss2 = new SimpleStruct2 ();
488 return mono_test_marshal_struct2_2 (10, 11, 12, ss2);
491 public static int test_0_marshal_empty_struct () {
492 EmptyStruct es = new EmptyStruct ();
494 if (mono_test_empty_struct (1, es, 2) != 0)
497 mono_test_return_empty_struct (42);
502 /* FIXME: This doesn't work on all platforms */
504 public static int test_0_marshal_empty_struct_cpp () {
505 EmptyStructCpp es = new EmptyStructCpp ();
507 mono_test_return_empty_struct_cpp (42);
513 public static int test_0_marshal_lpstruct () {
514 SimpleStruct ss = new SimpleStruct ();
518 return mono_test_marshal_lpstruct (ss);
521 public static int test_0_marshal_lpstruct_blittable () {
522 Point p = new Point ();
526 return mono_test_marshal_lpstruct_blittable (p);
529 public static int test_0_marshal_struct_array () {
530 SimpleStruct2[] ss_arr = new SimpleStruct2 [2];
532 SimpleStruct2 ss2 = new SimpleStruct2 ();
551 return mono_test_marshal_struct_array (ss_arr);
554 public static int test_105_marshal_long_align_struct_array () {
555 LongAlignStruct[] ss_arr = new LongAlignStruct [2];
557 LongAlignStruct ss = new LongAlignStruct ();
570 return mono_test_marshal_long_align_struct_array (ss_arr);
573 /* Test classes as arguments and return values */
574 public static int test_0_marshal_class () {
575 SimpleClass ss = new SimpleClass ();
583 SimpleClass res = mono_test_marshal_class (10, 11, 12, ss, 14);
586 if (! (res.a == ss.a && res.b == ss.b && res.c == ss.c &&
587 res.d == ss.d && res.e == ss.e && res.f == ss.f &&
588 res.g == ss.g && res.h == ss.h))
591 /* Test null arguments and results */
592 res = mono_test_marshal_class (10, 11, 12, null, 14);
599 public static int test_0_marshal_byref_class () {
600 SimpleClass ss = new SimpleClass ();
608 int res = mono_test_marshal_byref_class (ref ss);
609 if (ss.d != "TEST-RES")
615 public static int test_0_marshal_delegate () {
616 SimpleDelegate d = new SimpleDelegate (delegate_test);
618 return mono_test_marshal_delegate (d);
621 public static int test_34_marshal_instance_delegate () {
622 Tests t = new Tests ();
624 SimpleDelegate d = new SimpleDelegate (t.delegate_test_instance);
626 return mono_test_marshal_delegate (d);
629 /* Static delegates closed over their first argument */
630 public static int closed_delegate (Tests t, int a) {
631 return t.int_field + a;
634 public static int test_34_marshal_closed_static_delegate () {
635 Tests t = new Tests ();
637 SimpleDelegate d = (SimpleDelegate)Delegate.CreateDelegate (typeof (SimpleDelegate), t, typeof (Tests).GetMethod ("closed_delegate"));
639 return mono_test_marshal_delegate (d);
642 public static int test_0_marshal_return_delegate () {
643 SimpleDelegate d = new SimpleDelegate (delegate_test);
645 SimpleDelegate d2 = mono_test_marshal_return_delegate (d);
650 public static int test_0_marshal_delegate_struct () {
651 DelegateStruct s = new DelegateStruct ();
654 s.del = new SimpleDelegate (delegate_test);
655 s.del2 = new SimpleDelegate (delegate_test);
658 DelegateStruct res = mono_test_marshal_delegate_struct (s);
662 if (res.del (2) != 0)
664 if (res.del2 (2) != 0)
666 if (res.del3 != null)
672 [DllImport ("libtest", EntryPoint="mono_test_marshal_out_delegate")]
673 public static extern int mono_test_marshal_out_delegate (out SimpleDelegate d);
675 public static int test_3_marshal_out_delegate () {
676 SimpleDelegate d = null;
678 mono_test_marshal_out_delegate (out d);
683 public static int test_0_marshal_byref_struct () {
684 SimpleStruct s = new SimpleStruct ();
691 int res = mono_test_marshal_byref_struct (ref s, true, false, true, "ABC");
694 if (s.a != false || s.b != true || s.c != false || s.d != "DEF")
699 public static int test_0_marshal_byref_struct_in () {
700 SimpleStruct s = new SimpleStruct ();
707 int res = mono_test_marshal_byref_struct_in (ref s, true, false, true, "ABC");
710 if (s.a != true || s.b != false || s.c != true || s.d != "ABC")
715 public static int test_0_marshal_byref_struct_inout () {
716 SimpleStruct s = new SimpleStruct ();
723 int res = mono_test_marshal_byref_struct_inout (ref s, true, false, true, "ABC");
726 if (s.a != false || s.b != true || s.c != false || s.d != "DEF")
731 public static int test_0_marshal_point () {
732 Point pt = new Point();
736 return mono_test_marshal_point(pt);
739 public static int test_0_marshal_mixed_point () {
740 MixedPoint mpt = new MixedPoint();
744 return mono_test_marshal_mixed_point(mpt);
747 public static int test_0_marshal_bool_byref () {
749 if (mono_test_marshal_bool_byref (99, ref b, 100) != 1)
752 if (mono_test_marshal_bool_byref (99, ref b, 100) != 0)
760 public static int test_0_marshal_bool_as_I1 () {
764 if ((ret = mono_test_marshal_bool_in_as_I1 (true, false)) != 0)
767 if ((ret = mono_test_marshal_bool_out_as_I1 (out bTrue, out bFalse)) != 0)
776 if ((ret = mono_test_marshal_bool_ref_as_I1 (ref bTrue, ref bFalse)) != 0)
788 public static int test_0_marshal_bool_as_U1 () {
792 if ((ret = mono_test_marshal_bool_in_as_U1 (true, false)) != 0)
795 if ((ret = mono_test_marshal_bool_out_as_U1 (out bTrue, out bFalse)) != 0)
804 if ((ret = mono_test_marshal_bool_ref_as_U1 (ref bTrue, ref bFalse)) != 0)
816 public static int test_0_return_vtype () {
817 SimpleStruct ss = mono_test_return_vtype (new IntPtr (5));
819 if (!ss.a && ss.b && !ss.c && ss.d == "TEST" && ss.d2 == "TEST2")
825 public static int test_0_marshal_stringbuilder () {
826 StringBuilder sb = new StringBuilder(255);
828 mono_test_marshal_stringbuilder (sb, sb.Capacity);
829 String res = sb.ToString();
831 if (res != "This is my message. Isn't it nice?")
834 // Test StringBuilder with default capacity (16)
835 StringBuilder sb2 = new StringBuilder();
836 mono_test_marshal_stringbuilder_default (sb2, sb2.Capacity);
837 if (sb2.ToString () != "This is my messa")
843 public static int test_0_marshal_stringbuilder_append () {
844 const String in_sentinel = "MONO_";
845 const String out_sentinel = "CSHARP_";
846 const int iterations = 100;
847 StringBuilder sb = new StringBuilder(255);
848 StringBuilder check = new StringBuilder(255);
850 for (int i = 0; i < iterations; i++) {
851 sb.Append (in_sentinel[i % in_sentinel.Length]);
852 check.Append (out_sentinel[i % out_sentinel.Length]);
854 mono_test_marshal_stringbuilder_append (sb, sb.Length);
856 String res = sb.ToString();
857 String checkRev = check.ToString();
862 // Test StringBuilder with default capacity (16)
863 StringBuilder sb2 = new StringBuilder();
864 mono_test_marshal_stringbuilder_default (sb2, sb2.Capacity);
865 if (sb2.ToString () != "This is my messa")
871 public static int test_0_marshal_stringbuilder_unicode () {
872 StringBuilder sb = new StringBuilder(255);
873 mono_test_marshal_stringbuilder_unicode (sb, sb.Capacity);
874 String res = sb.ToString();
876 if (res != "This is my message. Isn't it nice?")
879 // Test StringBuilder with default capacity (16)
880 StringBuilder sb2 = new StringBuilder();
881 mono_test_marshal_stringbuilder_unicode (sb2, sb2.Capacity);
882 if (sb2.ToString () != "This is my messa")
888 public static int test_0_marshal_stringbuilder_out () {
890 mono_test_marshal_stringbuilder_out (out sb);
892 if (sb.ToString () != "This is my message. Isn't it nice?")
897 public static int test_0_marshal_stringbuilder_out_unicode () {
899 mono_test_marshal_stringbuilder_out_unicode (out sb);
901 if (sb.ToString () != "This is my message. Isn't it nice?")
906 public static int test_0_marshal_stringbuilder_ref () {
907 StringBuilder sb = new StringBuilder ();
909 int res = mono_test_marshal_stringbuilder_ref (ref sb);
913 if (sb.ToString () != "This is my message. Isn't it nice?")
918 public static int test_0_marshal_empty_string_array () {
919 return mono_test_marshal_empty_string_array (null);
922 public static int test_0_marshal_string_array () {
923 return mono_test_marshal_string_array (new String [] { "ABC", "DEF" });
926 public static int test_0_marshal_unicode_string_array () {
927 return mono_test_marshal_unicode_string_array (new String [] { "ABC", "DEF" }, new String [] { "ABC", "DEF" });
930 public static int test_0_marshal_stringbuilder_array () {
931 StringBuilder sb1 = new StringBuilder ("ABC");
932 StringBuilder sb2 = new StringBuilder ("DEF");
934 int res = mono_test_marshal_stringbuilder_array (new StringBuilder [] { sb1, sb2 });
937 if (sb1.ToString () != "DEF")
939 if (sb2.ToString () != "ABC")
944 public static int test_0_last_error () {
945 mono_test_last_error (5);
946 if (Marshal.GetLastWin32Error () == 5)
952 public static int test_0_entry_point_not_found () {
955 mono_entry_point_not_found ();
958 catch (EntryPointNotFoundException) {
964 public static int test_0_library_not_found () {
967 mono_library_not_found ();
970 catch (DllNotFoundException) {
976 /* Check that the runtime trims .dll from the library name */
977 public static int test_0_trim_dll_from_name () {
979 mono_test_marshal_char_2 ('A');
984 /* Check that the runtime adds lib to to the library name */
985 public static int test_0_add_lib_to_name () {
987 mono_test_marshal_char_3 ('A');
996 public static int test_0_asany () {
997 if (mono_test_asany (5, 1) != 0)
1000 if (mono_test_asany ("ABC", 2) != 0)
1003 SimpleStruct2 ss2 = new SimpleStruct2 ();
1011 if (mono_test_asany (ss2, 3) != 0)
1014 if (mono_test_asany_unicode ("ABC", 4) != 0)
1020 mono_test_asany (c, 0);
1023 catch (ArgumentException) {
1027 mono_test_asany (new Object (), 0);
1030 catch (ArgumentException) {
1036 /* AsAny marshalling + [In, Out] */
1038 public static int test_0_asany_in () {
1040 AsAnyStruct str = new AsAnyStruct(1,2,3, "ABC");
1041 mono_test_asany_in (str);
1044 AsAnyClass cls = new AsAnyClass(1,2,3, "ABC");
1045 mono_test_asany_in (cls);
1046 if ((cls.i != 1) || (cls.j != 2) || (cls.k != 3))
1050 object obj = new AsAnyStruct(1,2,3, "ABC");
1051 mono_test_asany_in (obj);
1052 str = (AsAnyStruct)obj;
1053 if ((str.i != 1) || (str.j != 2) || (str.k != 3))
1059 public static int test_0_asany_out () {
1061 AsAnyStruct str = new AsAnyStruct(1,2,3, "ABC");
1062 mono_test_asany_out (str);
1065 AsAnyClass cls = new AsAnyClass(1,2,3, "ABC");
1066 mono_test_asany_out (cls);
1067 if ((cls.i != 10) || (cls.j != 20) || (cls.k != 30))
1071 object obj = new AsAnyStruct(1,2,3, "ABC");
1072 mono_test_asany_out (obj);
1073 str = (AsAnyStruct)obj;
1074 if ((str.i != 10) || (str.j != 20) || (str.k != 30))
1080 public static int test_0_asany_inout () {
1082 AsAnyStruct str = new AsAnyStruct(1,2,3, "ABC");
1083 mono_test_asany_inout (str);
1086 AsAnyClass cls = new AsAnyClass(1,2,3, "ABC");
1087 mono_test_asany_inout (cls);
1088 if ((cls.i != 10) || (cls.j != 20) || (cls.k != 30))
1092 object obj = new AsAnyStruct(1,2,3, "ABC");
1093 mono_test_asany_inout (obj);
1094 str = (AsAnyStruct)obj;
1095 if ((str.i != 10) || (str.j != 20) || (str.k != 30))
1101 /* Byref String Array */
1103 [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_string_array")]
1104 public static extern int mono_test_marshal_byref_string_array (ref string[] data);
1106 public static int test_0_byref_string_array () {
1108 string[] arr = null;
1110 if (mono_test_marshal_byref_string_array (ref arr) != 0)
1113 arr = new string[] { "Alpha", "Beta", "Gamma" };
1115 if (mono_test_marshal_byref_string_array (ref arr) != 1)
1118 /* FIXME: Test returned array and out case */
1124 * AMD64 small structs-by-value tests.
1127 /* TEST 1: 16 byte long INTEGER struct */
1129 [StructLayout(LayoutKind.Sequential)]
1130 public struct Amd64Struct1 {
1137 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct1")]
1138 public static extern Amd64Struct1 mono_test_marshal_amd64_pass_return_struct1 (Amd64Struct1 s);
1140 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct1_many_args")]
1141 public static extern Amd64Struct1 mono_test_marshal_amd64_pass_return_struct1_many_args (Amd64Struct1 s, int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8);
1143 public static int test_0_amd64_struct1 () {
1144 Amd64Struct1 s = new Amd64Struct1 ();
1150 Amd64Struct1 s2 = mono_test_marshal_amd64_pass_return_struct1 (s);
1152 return ((s2.i == 6) && (s2.j == -4) && (s2.k == 0x1000000) && (s2.l == 0x10000000)) ? 0 : 1;
1155 public static int test_0_amd64_struct1_many_args () {
1156 Amd64Struct1 s = new Amd64Struct1 ();
1162 Amd64Struct1 s2 = mono_test_marshal_amd64_pass_return_struct1_many_args (s, 1, 2, 3, 4, 5, 6, 7, 8);
1164 return ((s2.i == 6) && (s2.j == -4) && (s2.k == 0x1000000) && (s2.l == 0x10000000 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8)) ? 0 : 1;
1167 /* TEST 2: 8 byte long INTEGER struct */
1169 [StructLayout(LayoutKind.Sequential)]
1170 public struct Amd64Struct2 {
1175 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct2")]
1176 public static extern Amd64Struct2 mono_test_marshal_amd64_pass_return_struct2 (Amd64Struct2 s);
1178 public static int test_0_amd64_struct2 () {
1179 Amd64Struct2 s = new Amd64Struct2 ();
1183 Amd64Struct2 s2 = mono_test_marshal_amd64_pass_return_struct2 (s);
1185 return ((s2.i == 6) && (s2.j == -4)) ? 0 : 1;
1188 /* TEST 3: 4 byte long INTEGER struct */
1190 [StructLayout(LayoutKind.Sequential)]
1191 public struct Amd64Struct3 {
1195 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct3")]
1196 public static extern Amd64Struct3 mono_test_marshal_amd64_pass_return_struct3 (Amd64Struct3 s);
1198 public static int test_0_amd64_struct3 () {
1199 Amd64Struct3 s = new Amd64Struct3 ();
1202 Amd64Struct3 s2 = mono_test_marshal_amd64_pass_return_struct3 (s);
1204 return (s2.i == -4) ? 0 : 1;
1207 /* Test 4: 16 byte long FLOAT struct */
1209 [StructLayout(LayoutKind.Sequential)]
1210 public struct Amd64Struct4 {
1211 public double d1, d2;
1214 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct4")]
1215 public static extern Amd64Struct4 mono_test_marshal_amd64_pass_return_struct4 (Amd64Struct4 s);
1217 public static int test_0_amd64_struct4 () {
1218 Amd64Struct4 s = new Amd64Struct4 ();
1222 Amd64Struct4 s2 = mono_test_marshal_amd64_pass_return_struct4 (s);
1224 return (s2.d1 == 6.0 && s2.d2 == -4.0) ? 0 : 1;
1231 /* Test 5: Float HFA */
1233 [StructLayout(LayoutKind.Sequential)]
1234 public struct TestStruct5 {
1235 public float d1, d2;
1238 [DllImport ("libtest", EntryPoint="mono_test_marshal_ia64_pass_return_struct5")]
1239 public static extern TestStruct5 mono_test_marshal_ia64_pass_return_struct5 (double d1, double d2, TestStruct5 s, int i, double f3, double f4);
1241 public static int test_0_ia64_struct5 () {
1242 TestStruct5 s = new TestStruct5 ();
1246 TestStruct5 s2 = mono_test_marshal_ia64_pass_return_struct5 (1.0, 2.0, s, 5, 3.0, 4.0);
1248 return (s2.d1 == 13.0 && s2.d2 == 7.0) ? 0 : 1;
1251 /* Test 6: Double HFA */
1253 [StructLayout(LayoutKind.Sequential)]
1254 public struct TestStruct6 {
1255 public double d1, d2;
1258 [DllImport ("libtest", EntryPoint="mono_test_marshal_ia64_pass_return_struct6")]
1259 public static extern TestStruct6 mono_test_marshal_ia64_pass_return_struct6 (double d1, double d2, TestStruct6 s, int i, double f3, double f4);
1261 public static int test_0_ia64_struct6 () {
1262 TestStruct6 s = new TestStruct6 ();
1266 TestStruct6 s2 = mono_test_marshal_ia64_pass_return_struct6 (1.0, 2.0, s, 3, 4.0, 5.0);
1268 return (s2.d1 == 12.0 && s2.d2 == 3.0) ? 0 : 1;
1271 /* Blittable class */
1272 [DllImport("libtest")]
1273 private static extern BlittableClass TestBlittableClass (BlittableClass vl);
1275 public static int test_0_marshal_blittable_class () {
1276 BlittableClass v1 = new BlittableClass ();
1278 /* Since it is blittable, it looks like it is passed as in/out */
1279 BlittableClass v2 = TestBlittableClass (v1);
1281 if (v1.a != 2 || v1.b != 3)
1284 if (v2.a != 2 || v2.b != 3)
1288 BlittableClass v3 = TestBlittableClass (null);
1290 if (v3.a != 42 || v3.b != 43)
1297 * Generic structures
1300 [StructLayout(LayoutKind.Sequential)]
1301 public struct Amd64Struct1Gen<T> {
1308 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct1")]
1309 public static extern Amd64Struct1Gen<int> mono_test_marshal_amd64_pass_return_struct1_gen (Amd64Struct1Gen<int> s);
1311 public static int test_0_amd64_struct1_gen () {
1312 Amd64Struct1Gen<int> s = new Amd64Struct1Gen<int> ();
1318 Amd64Struct1Gen<int> s2 = mono_test_marshal_amd64_pass_return_struct1_gen (s);
1320 return ((s2.i == 6) && (s2.j == -4) && (s2.k == 0x1000000) && (s2.l == 0x10000000)) ? 0 : 1;
1327 public static int test_0_marshal_byval_class () {
1328 SimpleObj obj0 = new SimpleObj ();
1332 if (class_marshal_test0 (obj0) != 0)
1338 public static int test_0_marshal_byval_class_null () {
1339 if (class_marshal_test4 (null) != 0)
1345 public static int test_0_marshal_out_class () {
1348 class_marshal_test1 (out obj1);
1350 if (obj1.str != "ABC")
1359 public static int test_0_marshal_string () {
1360 return string_marshal_test0 ("TEST0");
1363 public static int test_0_marshal_out_string () {
1366 string_marshal_test1 (out res);
1374 public static int test_0_marshal_byref_string () {
1375 string res = "TEST1";
1377 int r = string_marshal_test2 (ref res);
1385 public static int test_0_marshal_null_string () {
1386 return string_marshal_test3 (null);
1390 [DllImport ("libtest", EntryPoint="mono_test_stdcall_mismatch_1", CallingConvention=CallingConvention.StdCall)]
1391 public static extern int mono_test_stdcall_mismatch_1 (int a, int b, int c);
1393 /* Test mismatched called conventions, the native function is cdecl */
1394 public static int test_0_stdcall_mismatch_1 () {
1395 mono_test_stdcall_mismatch_1 (0, 1, 2);
1399 [DllImport ("libtest", EntryPoint="mono_test_stdcall_mismatch_2", CallingConvention=CallingConvention.Cdecl)]
1400 public static extern int mono_test_stdcall_mismatch_2 (int a, int b, int c);
1402 /* Test mismatched called conventions, the native function is stdcall */
1403 public static int test_0_stdcall_mismatch_2 () {
1404 mono_test_stdcall_mismatch_2 (0, 1, 2);
1409 [DllImport ("libtest", EntryPoint="mono_test_stdcall_name_mangling", CallingConvention=CallingConvention.StdCall)]
1410 public static extern int mono_test_stdcall_name_mangling (int a, int b, int c);
1412 public static int test_0_stdcall_name_mangling () {
1413 return mono_test_stdcall_name_mangling (0, 1, 2) == 3 ? 0 : 1;
1418 [DllImport ("libtest", EntryPoint="mono_test_marshal_pass_return_float")]
1419 public static extern float mono_test_marshal_pass_return_float (float f);
1421 public static int test_0_pass_return_float () {
1422 float f = mono_test_marshal_pass_return_float (1.5f);
1424 return (f == 2.5f) ? 0 : 1;
1428 * Pointers to structures can not be passed
1431 /* This seems to be allowed by MS in some cases */
1433 public struct CharInfo {
1434 public char Character;
1435 public short Attributes;
1438 [DllImport ("libtest", EntryPoint="mono_test_marshal_struct")]
1439 public static unsafe extern int mono_test_marshal_ptr_to_struct (CharInfo *ptr);
1441 public static unsafe int test_0_marshal_ptr_to_struct () {
1442 CharInfo [] buffer = new CharInfo [1];
1443 fixed (CharInfo *ptr = &buffer [0]) {
1445 mono_test_marshal_ptr_to_struct (ptr);
1448 catch (MarshalDirectiveException) {
1457 * LPWStr marshalling
1460 [DllImport("libtest", EntryPoint="test_lpwstr_marshal")]
1461 [return: MarshalAs(UnmanagedType.LPWStr)]
1462 private static extern string mono_test_marshal_lpwstr_marshal(
1463 [MarshalAs(UnmanagedType.LPWStr)] string s,
1466 [DllImport("libtest", EntryPoint="test_lpwstr_marshal", CharSet=CharSet.Unicode)]
1467 private static extern string mono_test_marshal_lpwstr_marshal2(
1471 [DllImport("libtest", EntryPoint="test_lpwstr_marshal_out")]
1472 private static extern void mono_test_marshal_lpwstr_out_marshal(
1473 [MarshalAs(UnmanagedType.LPWStr)] out string s);
1475 [DllImport("libtest", EntryPoint="test_lpwstr_marshal_out", CharSet=CharSet.Unicode)]
1476 private static extern void mono_test_marshal_lpwstr_out_marshal2(
1479 public static int test_0_pass_return_lwpstr () {
1482 mono_test_marshal_lpwstr_out_marshal (out s);
1488 mono_test_marshal_lpwstr_out_marshal2 (out s);
1496 public static int test_0_out_lwpstr () {
1499 string res = mono_test_marshal_lpwstr_marshal (s, s.Length);
1504 string res2 = mono_test_marshal_lpwstr_marshal2 (s, s.Length);
1513 * Byref bool marshalling
1516 [DllImport("libtest")]
1517 extern static int marshal_test_ref_bool
1520 [MarshalAs(UnmanagedType.I1)] ref bool b1,
1521 [MarshalAs(UnmanagedType.VariantBool)] ref bool b2,
1525 public static int test_0_pass_byref_bool () {
1526 for (int i = 0; i < 8; i++)
1528 bool b1 = (i & 4) != 0;
1529 bool b2 = (i & 2) != 0;
1530 bool b3 = (i & 1) != 0;
1531 bool orig_b1 = b1, orig_b2 = b2, orig_b3 = b3;
1532 if (marshal_test_ref_bool(i, ref b1, ref b2, ref b3) != 0)
1546 * Bool struct field marshalling
1552 [MarshalAs(UnmanagedType.I1)] public bool b1;
1553 [MarshalAs(UnmanagedType.VariantBool)] public bool b2;
1557 [DllImport("libtest")]
1558 extern static int marshal_test_bool_struct(ref BoolStruct s);
1560 public static int test_0_pass_bool_in_struct () {
1561 for (int i = 0; i < 8; i++)
1563 BoolStruct s = new BoolStruct();
1565 s.b1 = (i & 4) != 0;
1566 s.b2 = (i & 2) != 0;
1567 s.b3 = (i & 1) != 0;
1568 BoolStruct orig = s;
1569 if (marshal_test_bool_struct(ref s) != 0)
1571 if (s.b1 != !orig.b1)
1573 if (s.b2 != !orig.b2)
1575 if (s.b3 != !orig.b3)
1583 * Alignment of structs containing longs
1586 struct LongStruct2 {
1592 public LongStruct2 l;
1595 [DllImport("libtest")]
1596 extern static int mono_test_marshal_long_struct (ref LongStruct s);
1598 public static int test_47_pass_long_struct () {
1599 LongStruct s = new LongStruct ();
1601 s.l = new LongStruct2 ();
1604 return mono_test_marshal_long_struct (ref s);
1608 * Invoking pinvoke methods through delegates
1611 delegate int MyDelegate (string name);
1613 [DllImport ("libtest", EntryPoint="mono_test_puts_static")]
1614 public static extern int puts_static (string name);
1616 public static int test_0_invoke_pinvoke_through_delegate () {
1617 puts_static ("A simple Test for PInvoke 1");
1619 MyDelegate d = new MyDelegate (puts_static);
1620 d ("A simple Test for PInvoke 2");
1622 object [] args = {"A simple Test for PInvoke 3"};
1623 d.DynamicInvoke (args);
1629 * Missing virtual pinvoke methods
1634 public virtual object MyClone ()
1640 public class T2 : T {
1641 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1642 public override extern object MyClone ();
1645 public static int test_0_missing_virtual_pinvoke_method () {
1650 } catch (Exception ex) {
1658 * Marshalling of type 'object'
1661 [DllImport ("libtest", EntryPoint="mono_test_marshal_class")]
1662 public static extern SimpleClass mono_test_marshal_object (int i, int j, int k, object ss, int l);
1664 public static int test_0_marshal_object () {
1666 mono_test_marshal_object (0, 0, 0, null, 0);
1668 } catch (Exception) {
1674 * Marshalling of DateTime to OLE DATE (double)
1676 [DllImport ("libtest", EntryPoint="mono_test_marshal_date_time")]
1677 public static extern double mono_test_marshal_date_time (DateTime d, out DateTime d2);
1679 public static int test_0_marshal_date_time () {
1680 DateTime d = new DateTime (2009, 12, 6);
1682 double d3 = mono_test_marshal_date_time (d, out d2);
1691 * Calling pinvoke functions dynamically using calli
1694 [DllImport("libtest")]
1695 private static extern IntPtr mono_test_marshal_lookup_symbol (string fileName);
1697 delegate void CalliDel (IntPtr a, int[] f);
1699 public static int test_0_calli_dynamic () {
1700 /* we need the cdecl version because the icall convention demands it under Windows */
1701 IntPtr func = mono_test_marshal_lookup_symbol ("mono_test_marshal_inout_array_cdecl");
1703 DynamicMethod dm = new DynamicMethod ("calli", typeof (void), new Type [] { typeof (IntPtr), typeof (int[]) });
1705 var il = dm.GetILGenerator ();
1706 var signature = SignatureHelper.GetMethodSigHelper (CallingConvention.Cdecl, typeof (void));
1708 il.Emit (OpCodes.Ldarg, 1);
1709 signature.AddArgument (typeof (byte[]));
1711 il.Emit (OpCodes.Ldarg_0);
1713 il.Emit (OpCodes.Calli, signature);
1714 il.Emit (OpCodes.Ret);
1716 var f = (CalliDel)dm.CreateDelegate (typeof (CalliDel));
1718 int[] arr = new int [1000];
1719 for (int i = 0; i < 50; ++i)
1722 if (arr.Length != 1000)
1724 for (int i = 0; i < 50; ++i)
1725 if (arr [i] != 50 - i)
1732 /*char array marshaling */
1733 [DllImport ("libtest", EntryPoint="mono_test_marshal_ansi_char_array", CharSet=CharSet.Ansi)]
1734 public static extern int mono_test_marshal_ansi_char_array (char[] a1);
1736 public static int test_0_marshal_ansi_char_array () {
1737 char[] buf = new char [32];
1743 if (mono_test_marshal_ansi_char_array (buf) != 0)
1746 string s = new string (buf);
1747 if (s.StartsWith ("qwer"))
1753 /*char array marshaling */
1754 [DllImport ("libtest", EntryPoint="mono_test_marshal_unicode_char_array", CharSet=CharSet.Unicode)]
1755 public static extern int mono_test_marshal_unicode_char_array (char[] a1);
1757 public static int test_0_marshal_unicode_char_array () {
1758 char[] buf = new char [32];
1764 if (mono_test_marshal_unicode_char_array (buf) != 0)
1767 string s = new string (buf);
1768 if (s.StartsWith ("abcdef"))
1774 [DllImport ("libtest", EntryPoint="mono_test_marshal_lpstr")]
1775 public static extern int mono_test_marshal_lpstr ([MarshalAs(UnmanagedType.LPStr)] string str);
1777 public static int test_0_mono_test_marshal_lpstr () {
1780 if (mono_test_marshal_lpstr (str) != 0)
1786 [DllImport ("libtest", EntryPoint="mono_test_marshal_lpwstr")]
1787 public static extern int mono_test_marshal_lpwstr ([MarshalAs(UnmanagedType.LPWStr)] string str);
1789 public static int test_0_mono_test_marshal_lpwstr () {
1792 if (mono_test_marshal_lpwstr (str) != 0)
1799 [method: DllImport ("libtest", EntryPoint="mono_test_marshal_return_lpstr")]
1800 [return: MarshalAs(UnmanagedType.LPStr)]
1801 public static extern string mono_test_marshal_return_lpstr ();
1803 public static int test_0_mono_test_marshal_return_lpstr () {
1804 string str = mono_test_marshal_return_lpstr ();
1811 [method: DllImport ("libtest", EntryPoint="mono_test_marshal_return_lpwstr")]
1812 [return: MarshalAs(UnmanagedType.LPWStr)]
1813 public static extern string mono_test_marshal_return_lpwstr ();
1815 public static int test_0_mono_test_marshal_return_lpwstr () {
1816 string str = mono_test_marshal_return_lpwstr ();
1823 [DllImport ("libtest", EntryPoint="mono_test_has_thiscall")]
1824 public static extern int mono_test_has_thiscall ();
1826 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall1", CallingConvention=CallingConvention.ThisCall)]
1827 public static extern int mono_test_native_thiscall (int a);
1829 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall2", CallingConvention=CallingConvention.ThisCall)]
1830 public static extern int mono_test_native_thiscall (int a, int b);
1832 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall3", CallingConvention=CallingConvention.ThisCall)]
1833 public static extern int mono_test_native_thiscall (int a, int b, int c);
1835 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall1", CallingConvention=CallingConvention.ThisCall)]
1836 public static extern int mono_test_native_thiscall (TinyStruct a);
1838 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall2", CallingConvention=CallingConvention.ThisCall)]
1839 public static extern int mono_test_native_thiscall (TinyStruct a, int b);
1841 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall3", CallingConvention=CallingConvention.ThisCall)]
1842 public static extern int mono_test_native_thiscall (TinyStruct a, int b, int c);
1844 public static int test_0_native_thiscall ()
1846 if (mono_test_has_thiscall () == 0)
1849 if (mono_test_native_thiscall (1968329802) != 1968329802)
1852 if (mono_test_native_thiscall (268894549, 1212675791) != 1481570339)
1855 if (mono_test_native_thiscall (1288082683, -421187449, -1733670329) != -866775098)
1858 if (mono_test_native_thiscall (new TinyStruct(1968329802)) != 1968329802)
1861 if (mono_test_native_thiscall (new TinyStruct(268894549), 1212675791) != 1481570339)
1864 if (mono_test_native_thiscall (new TinyStruct(1288082683), -421187449, -1733670329) != -866775098)
1870 [DllImport ("libtest", EntryPoint = "mono_test_marshal_return_single_double_struct")]
1871 public static extern SingleDoubleStruct mono_test_marshal_return_single_double_struct ();
1873 public static int test_0_x86_single_double_struct_ret () {
1874 double d = mono_test_marshal_return_single_double_struct ().d;