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 public static int test_0_marshal_empty_struct_cpp () {
503 EmptyStructCpp es = new EmptyStructCpp ();
505 mono_test_return_empty_struct_cpp (42);
510 public static int test_0_marshal_lpstruct () {
511 SimpleStruct ss = new SimpleStruct ();
515 return mono_test_marshal_lpstruct (ss);
518 public static int test_0_marshal_lpstruct_blittable () {
519 Point p = new Point ();
523 return mono_test_marshal_lpstruct_blittable (p);
526 public static int test_0_marshal_struct_array () {
527 SimpleStruct2[] ss_arr = new SimpleStruct2 [2];
529 SimpleStruct2 ss2 = new SimpleStruct2 ();
548 return mono_test_marshal_struct_array (ss_arr);
551 public static int test_105_marshal_long_align_struct_array () {
552 LongAlignStruct[] ss_arr = new LongAlignStruct [2];
554 LongAlignStruct ss = new LongAlignStruct ();
567 return mono_test_marshal_long_align_struct_array (ss_arr);
570 /* Test classes as arguments and return values */
571 public static int test_0_marshal_class () {
572 SimpleClass ss = new SimpleClass ();
580 SimpleClass res = mono_test_marshal_class (10, 11, 12, ss, 14);
583 if (! (res.a == ss.a && res.b == ss.b && res.c == ss.c &&
584 res.d == ss.d && res.e == ss.e && res.f == ss.f &&
585 res.g == ss.g && res.h == ss.h))
588 /* Test null arguments and results */
589 res = mono_test_marshal_class (10, 11, 12, null, 14);
596 public static int test_0_marshal_byref_class () {
597 SimpleClass ss = new SimpleClass ();
605 int res = mono_test_marshal_byref_class (ref ss);
606 if (ss.d != "TEST-RES")
612 public static int test_0_marshal_delegate () {
613 SimpleDelegate d = new SimpleDelegate (delegate_test);
615 return mono_test_marshal_delegate (d);
618 public static int test_34_marshal_instance_delegate () {
619 Tests t = new Tests ();
621 SimpleDelegate d = new SimpleDelegate (t.delegate_test_instance);
623 return mono_test_marshal_delegate (d);
626 /* Static delegates closed over their first argument */
627 public static int closed_delegate (Tests t, int a) {
628 return t.int_field + a;
631 public static int test_34_marshal_closed_static_delegate () {
632 Tests t = new Tests ();
634 SimpleDelegate d = (SimpleDelegate)Delegate.CreateDelegate (typeof (SimpleDelegate), t, typeof (Tests).GetMethod ("closed_delegate"));
636 return mono_test_marshal_delegate (d);
639 public static int test_0_marshal_return_delegate () {
640 SimpleDelegate d = new SimpleDelegate (delegate_test);
642 SimpleDelegate d2 = mono_test_marshal_return_delegate (d);
647 public static int test_0_marshal_delegate_struct () {
648 DelegateStruct s = new DelegateStruct ();
651 s.del = new SimpleDelegate (delegate_test);
652 s.del2 = new SimpleDelegate (delegate_test);
655 DelegateStruct res = mono_test_marshal_delegate_struct (s);
659 if (res.del (2) != 0)
661 if (res.del2 (2) != 0)
663 if (res.del3 != null)
669 [DllImport ("libtest", EntryPoint="mono_test_marshal_out_delegate")]
670 public static extern int mono_test_marshal_out_delegate (out SimpleDelegate d);
672 public static int test_3_marshal_out_delegate () {
673 SimpleDelegate d = null;
675 mono_test_marshal_out_delegate (out d);
680 public static int test_0_marshal_byref_struct () {
681 SimpleStruct s = new SimpleStruct ();
688 int res = mono_test_marshal_byref_struct (ref s, true, false, true, "ABC");
691 if (s.a != false || s.b != true || s.c != false || s.d != "DEF")
696 public static int test_0_marshal_byref_struct_in () {
697 SimpleStruct s = new SimpleStruct ();
704 int res = mono_test_marshal_byref_struct_in (ref s, true, false, true, "ABC");
707 if (s.a != true || s.b != false || s.c != true || s.d != "ABC")
712 public static int test_0_marshal_byref_struct_inout () {
713 SimpleStruct s = new SimpleStruct ();
720 int res = mono_test_marshal_byref_struct_inout (ref s, true, false, true, "ABC");
723 if (s.a != false || s.b != true || s.c != false || s.d != "DEF")
728 public static int test_0_marshal_point () {
729 Point pt = new Point();
733 return mono_test_marshal_point(pt);
736 public static int test_0_marshal_mixed_point () {
737 MixedPoint mpt = new MixedPoint();
741 return mono_test_marshal_mixed_point(mpt);
744 public static int test_0_marshal_bool_byref () {
746 if (mono_test_marshal_bool_byref (99, ref b, 100) != 1)
749 if (mono_test_marshal_bool_byref (99, ref b, 100) != 0)
757 public static int test_0_marshal_bool_as_I1 () {
761 if ((ret = mono_test_marshal_bool_in_as_I1 (true, false)) != 0)
764 if ((ret = mono_test_marshal_bool_out_as_I1 (out bTrue, out bFalse)) != 0)
773 if ((ret = mono_test_marshal_bool_ref_as_I1 (ref bTrue, ref bFalse)) != 0)
785 public static int test_0_marshal_bool_as_U1 () {
789 if ((ret = mono_test_marshal_bool_in_as_U1 (true, false)) != 0)
792 if ((ret = mono_test_marshal_bool_out_as_U1 (out bTrue, out bFalse)) != 0)
801 if ((ret = mono_test_marshal_bool_ref_as_U1 (ref bTrue, ref bFalse)) != 0)
813 public static int test_0_return_vtype () {
814 SimpleStruct ss = mono_test_return_vtype (new IntPtr (5));
816 if (!ss.a && ss.b && !ss.c && ss.d == "TEST" && ss.d2 == "TEST2")
822 public static int test_0_marshal_stringbuilder () {
823 StringBuilder sb = new StringBuilder(255);
825 mono_test_marshal_stringbuilder (sb, sb.Capacity);
826 String res = sb.ToString();
828 if (res != "This is my message. Isn't it nice?")
831 // Test StringBuilder with default capacity (16)
832 StringBuilder sb2 = new StringBuilder();
833 mono_test_marshal_stringbuilder_default (sb2, sb2.Capacity);
834 if (sb2.ToString () != "This is my messa")
840 public static int test_0_marshal_stringbuilder_append () {
841 const String in_sentinel = "MONO_";
842 const String out_sentinel = "CSHARP_";
843 const int iterations = 100;
844 StringBuilder sb = new StringBuilder(255);
845 StringBuilder check = new StringBuilder(255);
847 for (int i = 0; i < iterations; i++) {
848 sb.Append (in_sentinel[i % in_sentinel.Length]);
849 check.Append (out_sentinel[i % out_sentinel.Length]);
851 mono_test_marshal_stringbuilder_append (sb, sb.Length);
853 String res = sb.ToString();
854 String checkRev = check.ToString();
859 // Test StringBuilder with default capacity (16)
860 StringBuilder sb2 = new StringBuilder();
861 mono_test_marshal_stringbuilder_default (sb2, sb2.Capacity);
862 if (sb2.ToString () != "This is my messa")
868 public static int test_0_marshal_stringbuilder_unicode () {
869 StringBuilder sb = new StringBuilder(255);
870 mono_test_marshal_stringbuilder_unicode (sb, sb.Capacity);
871 String res = sb.ToString();
873 if (res != "This is my message. Isn't it nice?")
876 // Test StringBuilder with default capacity (16)
877 StringBuilder sb2 = new StringBuilder();
878 mono_test_marshal_stringbuilder_unicode (sb2, sb2.Capacity);
879 if (sb2.ToString () != "This is my messa")
885 public static int test_0_marshal_stringbuilder_out () {
887 mono_test_marshal_stringbuilder_out (out sb);
889 if (sb.ToString () != "This is my message. Isn't it nice?")
894 public static int test_0_marshal_stringbuilder_out_unicode () {
896 mono_test_marshal_stringbuilder_out_unicode (out sb);
898 if (sb.ToString () != "This is my message. Isn't it nice?")
903 public static int test_0_marshal_stringbuilder_ref () {
904 StringBuilder sb = new StringBuilder ();
906 int res = mono_test_marshal_stringbuilder_ref (ref sb);
910 if (sb.ToString () != "This is my message. Isn't it nice?")
915 public static int test_0_marshal_empty_string_array () {
916 return mono_test_marshal_empty_string_array (null);
919 public static int test_0_marshal_string_array () {
920 return mono_test_marshal_string_array (new String [] { "ABC", "DEF" });
923 public static int test_0_marshal_unicode_string_array () {
924 return mono_test_marshal_unicode_string_array (new String [] { "ABC", "DEF" }, new String [] { "ABC", "DEF" });
927 public static int test_0_marshal_stringbuilder_array () {
928 StringBuilder sb1 = new StringBuilder ("ABC");
929 StringBuilder sb2 = new StringBuilder ("DEF");
931 int res = mono_test_marshal_stringbuilder_array (new StringBuilder [] { sb1, sb2 });
934 if (sb1.ToString () != "DEF")
936 if (sb2.ToString () != "ABC")
941 public static int test_0_last_error () {
942 mono_test_last_error (5);
943 if (Marshal.GetLastWin32Error () == 5)
949 public static int test_0_entry_point_not_found () {
952 mono_entry_point_not_found ();
955 catch (EntryPointNotFoundException) {
961 public static int test_0_library_not_found () {
964 mono_library_not_found ();
967 catch (DllNotFoundException) {
973 /* Check that the runtime trims .dll from the library name */
974 public static int test_0_trim_dll_from_name () {
976 mono_test_marshal_char_2 ('A');
981 /* Check that the runtime adds lib to to the library name */
982 public static int test_0_add_lib_to_name () {
984 mono_test_marshal_char_3 ('A');
993 public static int test_0_asany () {
994 if (mono_test_asany (5, 1) != 0)
997 if (mono_test_asany ("ABC", 2) != 0)
1000 SimpleStruct2 ss2 = new SimpleStruct2 ();
1008 if (mono_test_asany (ss2, 3) != 0)
1011 if (mono_test_asany_unicode ("ABC", 4) != 0)
1017 mono_test_asany (c, 0);
1020 catch (ArgumentException) {
1024 mono_test_asany (new Object (), 0);
1027 catch (ArgumentException) {
1033 /* AsAny marshalling + [In, Out] */
1035 public static int test_0_asany_in () {
1037 AsAnyStruct str = new AsAnyStruct(1,2,3, "ABC");
1038 mono_test_asany_in (str);
1041 AsAnyClass cls = new AsAnyClass(1,2,3, "ABC");
1042 mono_test_asany_in (cls);
1043 if ((cls.i != 1) || (cls.j != 2) || (cls.k != 3))
1047 object obj = new AsAnyStruct(1,2,3, "ABC");
1048 mono_test_asany_in (obj);
1049 str = (AsAnyStruct)obj;
1050 if ((str.i != 1) || (str.j != 2) || (str.k != 3))
1056 public static int test_0_asany_out () {
1058 AsAnyStruct str = new AsAnyStruct(1,2,3, "ABC");
1059 mono_test_asany_out (str);
1062 AsAnyClass cls = new AsAnyClass(1,2,3, "ABC");
1063 mono_test_asany_out (cls);
1064 if ((cls.i != 10) || (cls.j != 20) || (cls.k != 30))
1068 object obj = new AsAnyStruct(1,2,3, "ABC");
1069 mono_test_asany_out (obj);
1070 str = (AsAnyStruct)obj;
1071 if ((str.i != 10) || (str.j != 20) || (str.k != 30))
1077 public static int test_0_asany_inout () {
1079 AsAnyStruct str = new AsAnyStruct(1,2,3, "ABC");
1080 mono_test_asany_inout (str);
1083 AsAnyClass cls = new AsAnyClass(1,2,3, "ABC");
1084 mono_test_asany_inout (cls);
1085 if ((cls.i != 10) || (cls.j != 20) || (cls.k != 30))
1089 object obj = new AsAnyStruct(1,2,3, "ABC");
1090 mono_test_asany_inout (obj);
1091 str = (AsAnyStruct)obj;
1092 if ((str.i != 10) || (str.j != 20) || (str.k != 30))
1098 /* Byref String Array */
1100 [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_string_array")]
1101 public static extern int mono_test_marshal_byref_string_array (ref string[] data);
1103 public static int test_0_byref_string_array () {
1105 string[] arr = null;
1107 if (mono_test_marshal_byref_string_array (ref arr) != 0)
1110 arr = new string[] { "Alpha", "Beta", "Gamma" };
1112 if (mono_test_marshal_byref_string_array (ref arr) != 1)
1115 /* FIXME: Test returned array and out case */
1121 * AMD64 small structs-by-value tests.
1124 /* TEST 1: 16 byte long INTEGER struct */
1126 [StructLayout(LayoutKind.Sequential)]
1127 public struct Amd64Struct1 {
1134 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct1")]
1135 public static extern Amd64Struct1 mono_test_marshal_amd64_pass_return_struct1 (Amd64Struct1 s);
1137 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct1_many_args")]
1138 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);
1140 public static int test_0_amd64_struct1 () {
1141 Amd64Struct1 s = new Amd64Struct1 ();
1147 Amd64Struct1 s2 = mono_test_marshal_amd64_pass_return_struct1 (s);
1149 return ((s2.i == 6) && (s2.j == -4) && (s2.k == 0x1000000) && (s2.l == 0x10000000)) ? 0 : 1;
1152 public static int test_0_amd64_struct1_many_args () {
1153 Amd64Struct1 s = new Amd64Struct1 ();
1159 Amd64Struct1 s2 = mono_test_marshal_amd64_pass_return_struct1_many_args (s, 1, 2, 3, 4, 5, 6, 7, 8);
1161 return ((s2.i == 6) && (s2.j == -4) && (s2.k == 0x1000000) && (s2.l == 0x10000000 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8)) ? 0 : 1;
1164 /* TEST 2: 8 byte long INTEGER struct */
1166 [StructLayout(LayoutKind.Sequential)]
1167 public struct Amd64Struct2 {
1172 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct2")]
1173 public static extern Amd64Struct2 mono_test_marshal_amd64_pass_return_struct2 (Amd64Struct2 s);
1175 public static int test_0_amd64_struct2 () {
1176 Amd64Struct2 s = new Amd64Struct2 ();
1180 Amd64Struct2 s2 = mono_test_marshal_amd64_pass_return_struct2 (s);
1182 return ((s2.i == 6) && (s2.j == -4)) ? 0 : 1;
1185 /* TEST 3: 4 byte long INTEGER struct */
1187 [StructLayout(LayoutKind.Sequential)]
1188 public struct Amd64Struct3 {
1192 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct3")]
1193 public static extern Amd64Struct3 mono_test_marshal_amd64_pass_return_struct3 (Amd64Struct3 s);
1195 public static int test_0_amd64_struct3 () {
1196 Amd64Struct3 s = new Amd64Struct3 ();
1199 Amd64Struct3 s2 = mono_test_marshal_amd64_pass_return_struct3 (s);
1201 return (s2.i == -4) ? 0 : 1;
1204 /* Test 4: 16 byte long FLOAT struct */
1206 [StructLayout(LayoutKind.Sequential)]
1207 public struct Amd64Struct4 {
1208 public double d1, d2;
1211 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct4")]
1212 public static extern Amd64Struct4 mono_test_marshal_amd64_pass_return_struct4 (Amd64Struct4 s);
1214 public static int test_0_amd64_struct4 () {
1215 Amd64Struct4 s = new Amd64Struct4 ();
1219 Amd64Struct4 s2 = mono_test_marshal_amd64_pass_return_struct4 (s);
1221 return (s2.d1 == 6.0 && s2.d2 == -4.0) ? 0 : 1;
1228 /* Test 5: Float HFA */
1230 [StructLayout(LayoutKind.Sequential)]
1231 public struct TestStruct5 {
1232 public float d1, d2;
1235 [DllImport ("libtest", EntryPoint="mono_test_marshal_ia64_pass_return_struct5")]
1236 public static extern TestStruct5 mono_test_marshal_ia64_pass_return_struct5 (double d1, double d2, TestStruct5 s, int i, double f3, double f4);
1238 public static int test_0_ia64_struct5 () {
1239 TestStruct5 s = new TestStruct5 ();
1243 TestStruct5 s2 = mono_test_marshal_ia64_pass_return_struct5 (1.0, 2.0, s, 5, 3.0, 4.0);
1245 return (s2.d1 == 13.0 && s2.d2 == 7.0) ? 0 : 1;
1248 /* Test 6: Double HFA */
1250 [StructLayout(LayoutKind.Sequential)]
1251 public struct TestStruct6 {
1252 public double d1, d2;
1255 [DllImport ("libtest", EntryPoint="mono_test_marshal_ia64_pass_return_struct6")]
1256 public static extern TestStruct6 mono_test_marshal_ia64_pass_return_struct6 (double d1, double d2, TestStruct6 s, int i, double f3, double f4);
1258 public static int test_0_ia64_struct6 () {
1259 TestStruct6 s = new TestStruct6 ();
1263 TestStruct6 s2 = mono_test_marshal_ia64_pass_return_struct6 (1.0, 2.0, s, 3, 4.0, 5.0);
1265 return (s2.d1 == 12.0 && s2.d2 == 3.0) ? 0 : 1;
1268 /* Blittable class */
1269 [DllImport("libtest")]
1270 private static extern BlittableClass TestBlittableClass (BlittableClass vl);
1272 public static int test_0_marshal_blittable_class () {
1273 BlittableClass v1 = new BlittableClass ();
1275 /* Since it is blittable, it looks like it is passed as in/out */
1276 BlittableClass v2 = TestBlittableClass (v1);
1278 if (v1.a != 2 || v1.b != 3)
1281 if (v2.a != 2 || v2.b != 3)
1285 BlittableClass v3 = TestBlittableClass (null);
1287 if (v3.a != 42 || v3.b != 43)
1294 * Generic structures
1297 [StructLayout(LayoutKind.Sequential)]
1298 public struct Amd64Struct1Gen<T> {
1305 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct1")]
1306 public static extern Amd64Struct1Gen<int> mono_test_marshal_amd64_pass_return_struct1_gen (Amd64Struct1Gen<int> s);
1308 public static int test_0_amd64_struct1_gen () {
1309 Amd64Struct1Gen<int> s = new Amd64Struct1Gen<int> ();
1315 Amd64Struct1Gen<int> s2 = mono_test_marshal_amd64_pass_return_struct1_gen (s);
1317 return ((s2.i == 6) && (s2.j == -4) && (s2.k == 0x1000000) && (s2.l == 0x10000000)) ? 0 : 1;
1324 public static int test_0_marshal_byval_class () {
1325 SimpleObj obj0 = new SimpleObj ();
1329 if (class_marshal_test0 (obj0) != 0)
1335 public static int test_0_marshal_byval_class_null () {
1336 if (class_marshal_test4 (null) != 0)
1342 public static int test_0_marshal_out_class () {
1345 class_marshal_test1 (out obj1);
1347 if (obj1.str != "ABC")
1356 public static int test_0_marshal_string () {
1357 return string_marshal_test0 ("TEST0");
1360 public static int test_0_marshal_out_string () {
1363 string_marshal_test1 (out res);
1371 public static int test_0_marshal_byref_string () {
1372 string res = "TEST1";
1374 int r = string_marshal_test2 (ref res);
1382 public static int test_0_marshal_null_string () {
1383 return string_marshal_test3 (null);
1387 [DllImport ("libtest", EntryPoint="mono_test_stdcall_mismatch_1", CallingConvention=CallingConvention.StdCall)]
1388 public static extern int mono_test_stdcall_mismatch_1 (int a, int b, int c);
1390 /* Test mismatched called conventions, the native function is cdecl */
1391 public static int test_0_stdcall_mismatch_1 () {
1392 mono_test_stdcall_mismatch_1 (0, 1, 2);
1396 [DllImport ("libtest", EntryPoint="mono_test_stdcall_mismatch_2", CallingConvention=CallingConvention.Cdecl)]
1397 public static extern int mono_test_stdcall_mismatch_2 (int a, int b, int c);
1399 /* Test mismatched called conventions, the native function is stdcall */
1400 public static int test_0_stdcall_mismatch_2 () {
1401 mono_test_stdcall_mismatch_2 (0, 1, 2);
1406 [DllImport ("libtest", EntryPoint="mono_test_stdcall_name_mangling", CallingConvention=CallingConvention.StdCall)]
1407 public static extern int mono_test_stdcall_name_mangling (int a, int b, int c);
1409 public static int test_0_stdcall_name_mangling () {
1410 return mono_test_stdcall_name_mangling (0, 1, 2) == 3 ? 0 : 1;
1415 [DllImport ("libtest", EntryPoint="mono_test_marshal_pass_return_float")]
1416 public static extern float mono_test_marshal_pass_return_float (float f);
1418 public static int test_0_pass_return_float () {
1419 float f = mono_test_marshal_pass_return_float (1.5f);
1421 return (f == 2.5f) ? 0 : 1;
1425 * Pointers to structures can not be passed
1428 /* This seems to be allowed by MS in some cases */
1430 public struct CharInfo {
1431 public char Character;
1432 public short Attributes;
1435 [DllImport ("libtest", EntryPoint="mono_test_marshal_struct")]
1436 public static unsafe extern int mono_test_marshal_ptr_to_struct (CharInfo *ptr);
1438 public static unsafe int test_0_marshal_ptr_to_struct () {
1439 CharInfo [] buffer = new CharInfo [1];
1440 fixed (CharInfo *ptr = &buffer [0]) {
1442 mono_test_marshal_ptr_to_struct (ptr);
1445 catch (MarshalDirectiveException) {
1454 * LPWStr marshalling
1457 [DllImport("libtest", EntryPoint="test_lpwstr_marshal")]
1458 [return: MarshalAs(UnmanagedType.LPWStr)]
1459 private static extern string mono_test_marshal_lpwstr_marshal(
1460 [MarshalAs(UnmanagedType.LPWStr)] string s,
1463 [DllImport("libtest", EntryPoint="test_lpwstr_marshal", CharSet=CharSet.Unicode)]
1464 private static extern string mono_test_marshal_lpwstr_marshal2(
1468 [DllImport("libtest", EntryPoint="test_lpwstr_marshal_out")]
1469 private static extern void mono_test_marshal_lpwstr_out_marshal(
1470 [MarshalAs(UnmanagedType.LPWStr)] out string s);
1472 [DllImport("libtest", EntryPoint="test_lpwstr_marshal_out", CharSet=CharSet.Unicode)]
1473 private static extern void mono_test_marshal_lpwstr_out_marshal2(
1476 public static int test_0_pass_return_lwpstr () {
1479 mono_test_marshal_lpwstr_out_marshal (out s);
1485 mono_test_marshal_lpwstr_out_marshal2 (out s);
1493 public static int test_0_out_lwpstr () {
1496 string res = mono_test_marshal_lpwstr_marshal (s, s.Length);
1501 string res2 = mono_test_marshal_lpwstr_marshal2 (s, s.Length);
1510 * Byref bool marshalling
1513 [DllImport("libtest")]
1514 extern static int marshal_test_ref_bool
1517 [MarshalAs(UnmanagedType.I1)] ref bool b1,
1518 [MarshalAs(UnmanagedType.VariantBool)] ref bool b2,
1522 public static int test_0_pass_byref_bool () {
1523 for (int i = 0; i < 8; i++)
1525 bool b1 = (i & 4) != 0;
1526 bool b2 = (i & 2) != 0;
1527 bool b3 = (i & 1) != 0;
1528 bool orig_b1 = b1, orig_b2 = b2, orig_b3 = b3;
1529 if (marshal_test_ref_bool(i, ref b1, ref b2, ref b3) != 0)
1543 * Bool struct field marshalling
1549 [MarshalAs(UnmanagedType.I1)] public bool b1;
1550 [MarshalAs(UnmanagedType.VariantBool)] public bool b2;
1554 [DllImport("libtest")]
1555 extern static int marshal_test_bool_struct(ref BoolStruct s);
1557 public static int test_0_pass_bool_in_struct () {
1558 for (int i = 0; i < 8; i++)
1560 BoolStruct s = new BoolStruct();
1562 s.b1 = (i & 4) != 0;
1563 s.b2 = (i & 2) != 0;
1564 s.b3 = (i & 1) != 0;
1565 BoolStruct orig = s;
1566 if (marshal_test_bool_struct(ref s) != 0)
1568 if (s.b1 != !orig.b1)
1570 if (s.b2 != !orig.b2)
1572 if (s.b3 != !orig.b3)
1580 * Alignment of structs containing longs
1583 struct LongStruct2 {
1589 public LongStruct2 l;
1592 [DllImport("libtest")]
1593 extern static int mono_test_marshal_long_struct (ref LongStruct s);
1595 public static int test_47_pass_long_struct () {
1596 LongStruct s = new LongStruct ();
1598 s.l = new LongStruct2 ();
1601 return mono_test_marshal_long_struct (ref s);
1605 * Invoking pinvoke methods through delegates
1608 delegate int MyDelegate (string name);
1610 [DllImport ("libtest", EntryPoint="mono_test_puts_static")]
1611 public static extern int puts_static (string name);
1613 public static int test_0_invoke_pinvoke_through_delegate () {
1614 puts_static ("A simple Test for PInvoke 1");
1616 MyDelegate d = new MyDelegate (puts_static);
1617 d ("A simple Test for PInvoke 2");
1619 object [] args = {"A simple Test for PInvoke 3"};
1620 d.DynamicInvoke (args);
1626 * Missing virtual pinvoke methods
1631 public virtual object MyClone ()
1637 public class T2 : T {
1638 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1639 public override extern object MyClone ();
1642 public static int test_0_missing_virtual_pinvoke_method () {
1647 } catch (Exception ex) {
1655 * Marshalling of type 'object'
1658 [DllImport ("libtest", EntryPoint="mono_test_marshal_class")]
1659 public static extern SimpleClass mono_test_marshal_object (int i, int j, int k, object ss, int l);
1661 public static int test_0_marshal_object () {
1663 mono_test_marshal_object (0, 0, 0, null, 0);
1665 } catch (Exception) {
1671 * Marshalling of DateTime to OLE DATE (double)
1673 [DllImport ("libtest", EntryPoint="mono_test_marshal_date_time")]
1674 public static extern double mono_test_marshal_date_time (DateTime d, out DateTime d2);
1676 public static int test_0_marshal_date_time () {
1677 DateTime d = new DateTime (2009, 12, 6);
1679 double d3 = mono_test_marshal_date_time (d, out d2);
1688 * Calling pinvoke functions dynamically using calli
1691 [DllImport("libtest")]
1692 private static extern IntPtr mono_test_marshal_lookup_symbol (string fileName);
1694 delegate void CalliDel (IntPtr a, int[] f);
1696 public static int test_0_calli_dynamic () {
1697 /* we need the cdecl version because the icall convention demands it under Windows */
1698 IntPtr func = mono_test_marshal_lookup_symbol ("mono_test_marshal_inout_array_cdecl");
1700 DynamicMethod dm = new DynamicMethod ("calli", typeof (void), new Type [] { typeof (IntPtr), typeof (int[]) });
1702 var il = dm.GetILGenerator ();
1703 var signature = SignatureHelper.GetMethodSigHelper (CallingConvention.Cdecl, typeof (void));
1705 il.Emit (OpCodes.Ldarg, 1);
1706 signature.AddArgument (typeof (byte[]));
1708 il.Emit (OpCodes.Ldarg_0);
1710 il.Emit (OpCodes.Calli, signature);
1711 il.Emit (OpCodes.Ret);
1713 var f = (CalliDel)dm.CreateDelegate (typeof (CalliDel));
1715 int[] arr = new int [1000];
1716 for (int i = 0; i < 50; ++i)
1719 if (arr.Length != 1000)
1721 for (int i = 0; i < 50; ++i)
1722 if (arr [i] != 50 - i)
1729 /*char array marshaling */
1730 [DllImport ("libtest", EntryPoint="mono_test_marshal_ansi_char_array", CharSet=CharSet.Ansi)]
1731 public static extern int mono_test_marshal_ansi_char_array (char[] a1);
1733 public static int test_0_marshal_ansi_char_array () {
1734 char[] buf = new char [32];
1740 if (mono_test_marshal_ansi_char_array (buf) != 0)
1743 string s = new string (buf);
1744 if (s.StartsWith ("qwer"))
1750 /*char array marshaling */
1751 [DllImport ("libtest", EntryPoint="mono_test_marshal_unicode_char_array", CharSet=CharSet.Unicode)]
1752 public static extern int mono_test_marshal_unicode_char_array (char[] a1);
1754 public static int test_0_marshal_unicode_char_array () {
1755 char[] buf = new char [32];
1761 if (mono_test_marshal_unicode_char_array (buf) != 0)
1764 string s = new string (buf);
1765 if (s.StartsWith ("abcdef"))
1771 [DllImport ("libtest", EntryPoint="mono_test_marshal_lpstr")]
1772 public static extern int mono_test_marshal_lpstr ([MarshalAs(UnmanagedType.LPStr)] string str);
1774 public static int test_0_mono_test_marshal_lpstr () {
1777 if (mono_test_marshal_lpstr (str) != 0)
1783 [DllImport ("libtest", EntryPoint="mono_test_marshal_lpwstr")]
1784 public static extern int mono_test_marshal_lpwstr ([MarshalAs(UnmanagedType.LPWStr)] string str);
1786 public static int test_0_mono_test_marshal_lpwstr () {
1789 if (mono_test_marshal_lpwstr (str) != 0)
1796 [method: DllImport ("libtest", EntryPoint="mono_test_marshal_return_lpstr")]
1797 [return: MarshalAs(UnmanagedType.LPStr)]
1798 public static extern string mono_test_marshal_return_lpstr ();
1800 public static int test_0_mono_test_marshal_return_lpstr () {
1801 string str = mono_test_marshal_return_lpstr ();
1808 [method: DllImport ("libtest", EntryPoint="mono_test_marshal_return_lpwstr")]
1809 [return: MarshalAs(UnmanagedType.LPWStr)]
1810 public static extern string mono_test_marshal_return_lpwstr ();
1812 public static int test_0_mono_test_marshal_return_lpwstr () {
1813 string str = mono_test_marshal_return_lpwstr ();
1820 [DllImport ("libtest", EntryPoint="mono_test_has_thiscall")]
1821 public static extern int mono_test_has_thiscall ();
1823 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall1", CallingConvention=CallingConvention.ThisCall)]
1824 public static extern int mono_test_native_thiscall (int a);
1826 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall2", CallingConvention=CallingConvention.ThisCall)]
1827 public static extern int mono_test_native_thiscall (int a, int b);
1829 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall3", CallingConvention=CallingConvention.ThisCall)]
1830 public static extern int mono_test_native_thiscall (int a, int b, int c);
1832 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall1", CallingConvention=CallingConvention.ThisCall)]
1833 public static extern int mono_test_native_thiscall (TinyStruct a);
1835 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall2", CallingConvention=CallingConvention.ThisCall)]
1836 public static extern int mono_test_native_thiscall (TinyStruct a, int b);
1838 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall3", CallingConvention=CallingConvention.ThisCall)]
1839 public static extern int mono_test_native_thiscall (TinyStruct a, int b, int c);
1841 public static int test_0_native_thiscall ()
1843 if (mono_test_has_thiscall () == 0)
1846 if (mono_test_native_thiscall (1968329802) != 1968329802)
1849 if (mono_test_native_thiscall (268894549, 1212675791) != 1481570339)
1852 if (mono_test_native_thiscall (1288082683, -421187449, -1733670329) != -866775098)
1855 if (mono_test_native_thiscall (new TinyStruct(1968329802)) != 1968329802)
1858 if (mono_test_native_thiscall (new TinyStruct(268894549), 1212675791) != 1481570339)
1861 if (mono_test_native_thiscall (new TinyStruct(1288082683), -421187449, -1733670329) != -866775098)
1867 [DllImport ("libtest", EntryPoint = "mono_test_marshal_return_single_double_struct")]
1868 public static extern SingleDoubleStruct mono_test_marshal_return_single_double_struct ();
1870 public static int test_0_x86_single_double_struct_ret () {
1871 double d = mono_test_marshal_return_single_double_struct ().d;