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)]
65 public struct DelegateStruct {
67 public SimpleDelegate del;
68 [MarshalAs(UnmanagedType.FunctionPtr)]
69 public SimpleDelegate del2;
70 [MarshalAs(UnmanagedType.FunctionPtr)]
71 public SimpleDelegate del3;
74 [StructLayout (LayoutKind.Sequential)]
75 public struct SingleDoubleStruct {
79 /* sparcv9 has complex conventions when passing structs with doubles in them
80 by value, some simple tests for them */
81 [StructLayout (LayoutKind.Sequential)]
87 [StructLayout (LayoutKind.Sequential)]
88 public struct MixedPoint {
93 [StructLayout (LayoutKind.Sequential)]
94 public struct TinyStruct {
95 public TinyStruct (int i)
102 [StructLayout (LayoutKind.Sequential)]
103 public class SimpleClass {
114 [StructLayout (LayoutKind.Sequential)]
115 public class EmptyClass {
118 [StructLayout (LayoutKind.Sequential)]
119 public struct LongAlignStruct {
125 [StructLayout(LayoutKind.Sequential)]
126 public class BlittableClass
132 [StructLayout (LayoutKind.Sequential)]
139 [StructLayout(LayoutKind.Sequential)]
147 public AsAnyStruct(int i, int j, int k, String s) {
155 [StructLayout(LayoutKind.Sequential)]
163 public AsAnyClass(int i, int j, int k, String s) {
170 [DllImport ("libnot-found", EntryPoint="not_found")]
171 public static extern int mono_library_not_found ();
173 [DllImport ("libtest", EntryPoint="not_found")]
174 public static extern int mono_entry_point_not_found ();
176 [DllImport ("libtest.dll", EntryPoint="mono_test_marshal_char")]
177 public static extern int mono_test_marshal_char_2 (char a1);
179 [DllImport ("test", EntryPoint="mono_test_marshal_char")]
180 public static extern int mono_test_marshal_char_3 (char a1);
182 [DllImport ("libtest", EntryPoint="mono_test_marshal_char")]
183 public static extern int mono_test_marshal_char (char a1);
185 [DllImport ("libtest", EntryPoint="mono_test_marshal_char_array", CharSet=CharSet.Unicode)]
186 public static extern int mono_test_marshal_char_array (char[] a1);
188 [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_byref")]
189 public static extern int mono_test_marshal_bool_byref (int a, ref bool b, int c);
191 [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_in_as_I1_U1")]
192 public static extern int mono_test_marshal_bool_in_as_I1 ([MarshalAs (UnmanagedType.I1)] bool bTrue, [MarshalAs (UnmanagedType.I1)] bool bFalse);
194 [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_in_as_I1_U1")]
195 public static extern int mono_test_marshal_bool_in_as_U1 ([MarshalAs (UnmanagedType.U1)] bool bTrue, [MarshalAs (UnmanagedType.U1)] bool bFalse);
197 [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_out_as_I1_U1")]
198 public static extern int mono_test_marshal_bool_out_as_I1 ([MarshalAs (UnmanagedType.I1)] out bool bTrue, [MarshalAs (UnmanagedType.I1)] out bool bFalse);
200 [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_out_as_I1_U1")]
201 public static extern int mono_test_marshal_bool_out_as_U1 ([MarshalAs (UnmanagedType.U1)] out bool bTrue, [MarshalAs (UnmanagedType.U1)] out bool bFalse);
203 [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_ref_as_I1_U1")]
204 public static extern int mono_test_marshal_bool_ref_as_I1 ([MarshalAs (UnmanagedType.I1)] ref bool bTrue, [MarshalAs (UnmanagedType.I1)] ref bool bFalse);
206 [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_ref_as_I1_U1")]
207 public static extern int mono_test_marshal_bool_ref_as_U1 ([MarshalAs (UnmanagedType.U1)] ref bool bTrue, [MarshalAs (UnmanagedType.U1)] ref bool bFalse);
209 [DllImport ("libtest", EntryPoint="mono_test_marshal_array")]
210 public static extern int mono_test_marshal_array (int [] a1);
212 [DllImport ("libtest", EntryPoint="mono_test_marshal_empty_string_array")]
213 public static extern int mono_test_marshal_empty_string_array (string [] a1);
215 [DllImport ("libtest", EntryPoint="mono_test_marshal_string_array")]
216 public static extern int mono_test_marshal_string_array (string [] a1);
218 [DllImport ("libtest", EntryPoint="mono_test_marshal_unicode_string_array", CharSet=CharSet.Unicode)]
219 public static extern int mono_test_marshal_unicode_string_array (string [] a1, [MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPStr)]string [] a2);
221 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_array")]
222 public static extern int mono_test_marshal_stringbuilder_array (StringBuilder [] a1);
224 [DllImport ("libtest", EntryPoint="mono_test_marshal_inout_array")]
225 public static extern int mono_test_marshal_inout_array ([In, Out] int [] a1);
227 [DllImport ("libtest", EntryPoint="mono_test_marshal_out_array")]
228 public static extern int mono_test_marshal_out_array ([Out] [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int [] a1, int n);
230 [DllImport ("libtest", EntryPoint="mono_test_marshal_out_byref_array_out_size_param")]
231 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);
233 [DllImport ("libtest", EntryPoint="mono_test_marshal_inout_nonblittable_array", CharSet = CharSet.Unicode)]
234 public static extern int mono_test_marshal_inout_nonblittable_array ([In, Out] char [] a1);
236 [DllImport ("libtest", EntryPoint="mono_test_marshal_struct")]
237 public static extern int mono_test_marshal_struct (SimpleStruct ss);
239 [DllImport ("libtest", EntryPoint="mono_test_marshal_struct")]
240 public static extern int mono_test_marshal_struct_gen (SimpleStructGen<string> ss);
242 [DllImport ("libtest", EntryPoint="mono_test_marshal_struct2")]
243 public static extern int mono_test_marshal_struct2 (SimpleStruct2 ss);
245 [DllImport ("libtest", EntryPoint="mono_test_marshal_struct2_2")]
246 public static extern int mono_test_marshal_struct2_2 (int i, int j, int k, SimpleStruct2 ss);
248 [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_struct")]
249 public static extern int mono_test_marshal_byref_struct (ref SimpleStruct ss, bool a, bool b, bool c, String d);
251 [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_struct")]
252 public static extern int mono_test_marshal_byref_struct_in ([In] ref SimpleStruct ss, bool a, bool b, bool c, String d);
254 [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_struct")]
255 public static extern int mono_test_marshal_byref_struct_inout ([In, Out] ref SimpleStruct ss, bool a, bool b, bool c, String d);
257 [DllImport ("libtest", EntryPoint="mono_test_marshal_point")]
258 public static extern int mono_test_marshal_point (Point p);
260 [DllImport ("libtest", EntryPoint="mono_test_marshal_mixed_point")]
261 public static extern int mono_test_marshal_mixed_point (MixedPoint p);
263 [DllImport ("libtest", EntryPoint="mono_test_empty_struct")]
264 public static extern int mono_test_empty_struct (int a, EmptyStruct es, int b);
266 [DllImport ("libtest", EntryPoint="mono_test_marshal_lpstruct")]
267 public static extern int mono_test_marshal_lpstruct ([In, MarshalAs(UnmanagedType.LPStruct)] SimpleStruct ss);
269 [DllImport ("libtest", EntryPoint="mono_test_marshal_lpstruct_blittable")]
270 public static extern int mono_test_marshal_lpstruct_blittable ([In, MarshalAs(UnmanagedType.LPStruct)] Point p);
272 [DllImport ("libtest", EntryPoint="mono_test_marshal_struct_array")]
273 public static extern int mono_test_marshal_struct_array (SimpleStruct2[] ss);
275 [DllImport ("libtest", EntryPoint="mono_test_marshal_long_align_struct_array")]
276 public static extern int mono_test_marshal_long_align_struct_array (LongAlignStruct[] ss);
278 [DllImport ("libtest", EntryPoint="mono_test_marshal_class")]
279 public static extern SimpleClass mono_test_marshal_class (int i, int j, int k, SimpleClass ss, int l);
281 [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_class")]
282 public static extern int mono_test_marshal_byref_class (ref SimpleClass ss);
284 [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate")]
285 public static extern int mono_test_marshal_delegate (SimpleDelegate d);
287 [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate_struct")]
288 public static extern DelegateStruct mono_test_marshal_delegate_struct (DelegateStruct d);
290 [DllImport ("libtest", EntryPoint="mono_test_marshal_return_delegate")]
291 public static extern SimpleDelegate mono_test_marshal_return_delegate (SimpleDelegate d);
293 [DllImport ("libtest", EntryPoint="mono_test_return_vtype")]
294 public static extern SimpleStruct mono_test_return_vtype (IntPtr i);
296 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder")]
297 public static extern void mono_test_marshal_stringbuilder (StringBuilder sb, int len);
299 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_default")]
300 public static extern void mono_test_marshal_stringbuilder_default (StringBuilder sb, int len);
302 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_append")]
303 public static extern void mono_test_marshal_stringbuilder_append (StringBuilder sb, int len);
305 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_unicode", CharSet=CharSet.Unicode)]
306 public static extern void mono_test_marshal_stringbuilder_unicode (StringBuilder sb, int len);
308 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_out")]
309 public static extern void mono_test_marshal_stringbuilder_out (out StringBuilder sb);
311 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_ref")]
312 public static extern int mono_test_marshal_stringbuilder_ref (ref StringBuilder sb);
314 [DllImport ("libtest", EntryPoint="mono_test_marshal_stringbuilder_out_unicode", CharSet=CharSet.Unicode)]
315 public static extern void mono_test_marshal_stringbuilder_out_unicode (out StringBuilder sb);
317 [DllImport ("libtest", EntryPoint="mono_test_last_error", SetLastError=true)]
318 public static extern void mono_test_last_error (int err);
320 [DllImport ("libtest", EntryPoint="mono_test_asany")]
321 public static extern int mono_test_asany ([MarshalAs (UnmanagedType.AsAny)] object o, int what);
323 [DllImport ("libtest", EntryPoint="mono_test_asany", CharSet=CharSet.Unicode)]
324 public static extern int mono_test_asany_unicode ([MarshalAs (UnmanagedType.AsAny)] object o, int what);
326 [DllImport("libtest", EntryPoint="mono_test_marshal_asany_in")]
327 static extern void mono_test_asany_in ([MarshalAs(UnmanagedType.AsAny)][In] object obj);
329 [DllImport("libtest", EntryPoint="mono_test_marshal_asany_out")]
330 static extern void mono_test_asany_out ([MarshalAs(UnmanagedType.AsAny)][Out] object obj);
331 [DllImport("libtest", EntryPoint="mono_test_marshal_asany_inout")]
332 static extern void mono_test_asany_inout ([MarshalAs(UnmanagedType.AsAny)][In, Out] object obj);
334 [DllImport ("libtest")]
335 static extern int class_marshal_test0 (SimpleObj obj);
337 [DllImport ("libtest")]
338 static extern void class_marshal_test1 (out SimpleObj obj);
340 [DllImport ("libtest")]
341 static extern int class_marshal_test4 (SimpleObj obj);
343 [DllImport ("libtest")]
344 static extern int string_marshal_test0 (string str);
346 [DllImport ("libtest")]
347 static extern void string_marshal_test1 (out string str);
349 [DllImport ("libtest")]
350 static extern int string_marshal_test2 (ref string str);
352 [DllImport ("libtest")]
353 static extern int string_marshal_test3 (string str);
355 public delegate int SimpleDelegate (int a);
357 public static int Main (string[] args) {
358 return TestDriver.RunTests (typeof (Tests), args);
361 public static int test_0_marshal_char () {
362 return mono_test_marshal_char ('a');
365 public static int test_0_marshal_char_array () {
366 // a unicode char[] is implicitly marshalled as [Out]
367 char[] buf = new char [32];
368 mono_test_marshal_char_array (buf);
369 string s = new string (buf);
370 if (s.StartsWith ("abcdef"))
376 public static int test_1225_marshal_array () {
377 int [] a1 = new int [50];
378 for (int i = 0; i < 50; i++)
381 return mono_test_marshal_array (a1);
384 public static int test_1225_marshal_inout_array () {
385 int [] a1 = new int [50];
386 for (int i = 0; i < 50; i++)
389 int res = mono_test_marshal_inout_array (a1);
391 for (int i = 0; i < 50; i++)
392 if (a1 [i] != 50 - i) {
393 Console.WriteLine ("X: " + i + " " + a1 [i]);
400 public static int test_0_marshal_out_array () {
401 int [] a1 = new int [50];
403 int res = mono_test_marshal_out_array (a1, 0);
405 for (int i = 0; i < 50; i++)
407 Console.WriteLine ("X: " + i + " " + a1 [i]);
414 public static int test_0_marshal_out_byref_array_out_size_param () {
418 int res = mono_test_marshal_out_byref_array_out_size_param (out a1, out len);
421 for (int i = 0; i < len; i++)
427 public static int test_0_marshal_inout_nonblittable_array () {
428 char [] a1 = new char [10];
429 for (int i = 0; i < 10; i++)
430 a1 [i] = "Hello, World" [i];
432 int res = mono_test_marshal_inout_nonblittable_array (a1);
434 for (int i = 0; i < 10; i++)
441 public static int test_0_marshal_struct () {
442 SimpleStruct ss = new SimpleStruct ();
446 return mono_test_marshal_struct (ss);
449 public static int test_0_marshal_struct_gen () {
450 SimpleStructGen<string> ss = new SimpleStructGen<string> ();
454 return mono_test_marshal_struct_gen (ss);
457 public static int test_0_marshal_struct2 () {
458 SimpleStruct2 ss2 = new SimpleStruct2 ();
466 return mono_test_marshal_struct2 (ss2);
469 public static int test_0_marshal_struct3 () {
470 SimpleStruct2 ss2 = new SimpleStruct2 ();
478 return mono_test_marshal_struct2_2 (10, 11, 12, ss2);
481 public static int test_0_marshal_empty_struct () {
482 EmptyStruct es = new EmptyStruct ();
484 if (mono_test_empty_struct (1, es, 2) != 0)
490 public static int test_0_marshal_lpstruct () {
491 SimpleStruct ss = new SimpleStruct ();
495 return mono_test_marshal_lpstruct (ss);
498 public static int test_0_marshal_lpstruct_blittable () {
499 Point p = new Point ();
503 return mono_test_marshal_lpstruct_blittable (p);
506 public static int test_0_marshal_struct_array () {
507 SimpleStruct2[] ss_arr = new SimpleStruct2 [2];
509 SimpleStruct2 ss2 = new SimpleStruct2 ();
528 return mono_test_marshal_struct_array (ss_arr);
531 public static int test_105_marshal_long_align_struct_array () {
532 LongAlignStruct[] ss_arr = new LongAlignStruct [2];
534 LongAlignStruct ss = new LongAlignStruct ();
547 return mono_test_marshal_long_align_struct_array (ss_arr);
550 /* Test classes as arguments and return values */
551 public static int test_0_marshal_class () {
552 SimpleClass ss = new SimpleClass ();
560 SimpleClass res = mono_test_marshal_class (10, 11, 12, ss, 14);
563 if (! (res.a == ss.a && res.b == ss.b && res.c == ss.c &&
564 res.d == ss.d && res.e == ss.e && res.f == ss.f &&
565 res.g == ss.g && res.h == ss.h))
568 /* Test null arguments and results */
569 res = mono_test_marshal_class (10, 11, 12, null, 14);
576 public static int test_0_marshal_byref_class () {
577 SimpleClass ss = new SimpleClass ();
585 int res = mono_test_marshal_byref_class (ref ss);
586 if (ss.d != "TEST-RES")
592 public static int test_0_marshal_delegate () {
593 SimpleDelegate d = new SimpleDelegate (delegate_test);
595 return mono_test_marshal_delegate (d);
598 public static int test_34_marshal_instance_delegate () {
599 Tests t = new Tests ();
601 SimpleDelegate d = new SimpleDelegate (t.delegate_test_instance);
603 return mono_test_marshal_delegate (d);
606 /* Static delegates closed over their first argument */
607 public static int closed_delegate (Tests t, int a) {
608 return t.int_field + a;
611 public static int test_34_marshal_closed_static_delegate () {
612 Tests t = new Tests ();
614 SimpleDelegate d = (SimpleDelegate)Delegate.CreateDelegate (typeof (SimpleDelegate), t, typeof (Tests).GetMethod ("closed_delegate"));
616 return mono_test_marshal_delegate (d);
619 public static int test_0_marshal_return_delegate () {
620 SimpleDelegate d = new SimpleDelegate (delegate_test);
622 SimpleDelegate d2 = mono_test_marshal_return_delegate (d);
627 public static int test_0_marshal_delegate_struct () {
628 DelegateStruct s = new DelegateStruct ();
631 s.del = new SimpleDelegate (delegate_test);
632 s.del2 = new SimpleDelegate (delegate_test);
635 DelegateStruct res = mono_test_marshal_delegate_struct (s);
639 if (res.del (2) != 0)
641 if (res.del2 (2) != 0)
643 if (res.del3 != null)
649 [DllImport ("libtest", EntryPoint="mono_test_marshal_out_delegate")]
650 public static extern int mono_test_marshal_out_delegate (out SimpleDelegate d);
652 public static int test_3_marshal_out_delegate () {
653 SimpleDelegate d = null;
655 mono_test_marshal_out_delegate (out d);
660 public static int test_0_marshal_byref_struct () {
661 SimpleStruct s = new SimpleStruct ();
668 int res = mono_test_marshal_byref_struct (ref s, true, false, true, "ABC");
671 if (s.a != false || s.b != true || s.c != false || s.d != "DEF")
676 public static int test_0_marshal_byref_struct_in () {
677 SimpleStruct s = new SimpleStruct ();
684 int res = mono_test_marshal_byref_struct_in (ref s, true, false, true, "ABC");
687 if (s.a != true || s.b != false || s.c != true || s.d != "ABC")
692 public static int test_0_marshal_byref_struct_inout () {
693 SimpleStruct s = new SimpleStruct ();
700 int res = mono_test_marshal_byref_struct_inout (ref s, true, false, true, "ABC");
703 if (s.a != false || s.b != true || s.c != false || s.d != "DEF")
708 public static int test_0_marshal_point () {
709 Point pt = new Point();
713 return mono_test_marshal_point(pt);
716 public static int test_0_marshal_mixed_point () {
717 MixedPoint mpt = new MixedPoint();
721 return mono_test_marshal_mixed_point(mpt);
724 public static int test_0_marshal_bool_byref () {
726 if (mono_test_marshal_bool_byref (99, ref b, 100) != 1)
729 if (mono_test_marshal_bool_byref (99, ref b, 100) != 0)
737 public static int test_0_marshal_bool_as_I1 () {
741 if ((ret = mono_test_marshal_bool_in_as_I1 (true, false)) != 0)
744 if ((ret = mono_test_marshal_bool_out_as_I1 (out bTrue, out bFalse)) != 0)
753 if ((ret = mono_test_marshal_bool_ref_as_I1 (ref bTrue, ref bFalse)) != 0)
765 public static int test_0_marshal_bool_as_U1 () {
769 if ((ret = mono_test_marshal_bool_in_as_U1 (true, false)) != 0)
772 if ((ret = mono_test_marshal_bool_out_as_U1 (out bTrue, out bFalse)) != 0)
781 if ((ret = mono_test_marshal_bool_ref_as_U1 (ref bTrue, ref bFalse)) != 0)
793 public static int test_0_return_vtype () {
794 SimpleStruct ss = mono_test_return_vtype (new IntPtr (5));
796 if (!ss.a && ss.b && !ss.c && ss.d == "TEST" && ss.d2 == "TEST2")
802 public static int test_0_marshal_stringbuilder () {
803 StringBuilder sb = new StringBuilder(255);
805 mono_test_marshal_stringbuilder (sb, sb.Capacity);
806 String res = sb.ToString();
808 if (res != "This is my message. Isn't it nice?")
811 // Test StringBuilder with default capacity (16)
812 StringBuilder sb2 = new StringBuilder();
813 mono_test_marshal_stringbuilder_default (sb2, sb2.Capacity);
814 if (sb2.ToString () != "This is my messa")
820 public static int test_0_marshal_stringbuilder_append () {
821 const String in_sentinel = "MONO_";
822 const String out_sentinel = "CSHARP_";
823 const int iterations = 100;
824 StringBuilder sb = new StringBuilder(255);
825 StringBuilder check = new StringBuilder(255);
827 for (int i = 0; i < iterations; i++) {
828 sb.Append (in_sentinel[i % in_sentinel.Length]);
829 check.Append (out_sentinel[i % out_sentinel.Length]);
831 mono_test_marshal_stringbuilder_append (sb, sb.Length);
833 String res = sb.ToString();
834 String checkRev = check.ToString();
839 // Test StringBuilder with default capacity (16)
840 StringBuilder sb2 = new StringBuilder();
841 mono_test_marshal_stringbuilder_default (sb2, sb2.Capacity);
842 if (sb2.ToString () != "This is my messa")
848 public static int test_0_marshal_stringbuilder_unicode () {
849 StringBuilder sb = new StringBuilder(255);
850 mono_test_marshal_stringbuilder_unicode (sb, sb.Capacity);
851 String res = sb.ToString();
853 if (res != "This is my message. Isn't it nice?")
856 // Test StringBuilder with default capacity (16)
857 StringBuilder sb2 = new StringBuilder();
858 mono_test_marshal_stringbuilder_unicode (sb2, sb2.Capacity);
859 if (sb2.ToString () != "This is my messa")
865 public static int test_0_marshal_stringbuilder_out () {
867 mono_test_marshal_stringbuilder_out (out sb);
869 if (sb.ToString () != "This is my message. Isn't it nice?")
874 public static int test_0_marshal_stringbuilder_out_unicode () {
876 mono_test_marshal_stringbuilder_out_unicode (out sb);
878 if (sb.ToString () != "This is my message. Isn't it nice?")
883 public static int test_0_marshal_stringbuilder_ref () {
884 StringBuilder sb = new StringBuilder ();
886 int res = mono_test_marshal_stringbuilder_ref (ref sb);
890 if (sb.ToString () != "This is my message. Isn't it nice?")
895 public static int test_0_marshal_empty_string_array () {
896 return mono_test_marshal_empty_string_array (null);
899 public static int test_0_marshal_string_array () {
900 return mono_test_marshal_string_array (new String [] { "ABC", "DEF" });
903 public static int test_0_marshal_unicode_string_array () {
904 return mono_test_marshal_unicode_string_array (new String [] { "ABC", "DEF" }, new String [] { "ABC", "DEF" });
907 public static int test_0_marshal_stringbuilder_array () {
908 StringBuilder sb1 = new StringBuilder ("ABC");
909 StringBuilder sb2 = new StringBuilder ("DEF");
911 int res = mono_test_marshal_stringbuilder_array (new StringBuilder [] { sb1, sb2 });
914 if (sb1.ToString () != "DEF")
916 if (sb2.ToString () != "ABC")
921 public static int test_0_last_error () {
922 mono_test_last_error (5);
923 if (Marshal.GetLastWin32Error () == 5)
929 public static int test_0_entry_point_not_found () {
932 mono_entry_point_not_found ();
935 catch (EntryPointNotFoundException) {
941 public static int test_0_library_not_found () {
944 mono_library_not_found ();
947 catch (DllNotFoundException) {
953 /* Check that the runtime trims .dll from the library name */
954 public static int test_0_trim_dll_from_name () {
956 mono_test_marshal_char_2 ('A');
961 /* Check that the runtime adds lib to to the library name */
962 public static int test_0_add_lib_to_name () {
964 mono_test_marshal_char_3 ('A');
973 public static int test_0_asany () {
974 if (mono_test_asany (5, 1) != 0)
977 if (mono_test_asany ("ABC", 2) != 0)
980 SimpleStruct2 ss2 = new SimpleStruct2 ();
988 if (mono_test_asany (ss2, 3) != 0)
991 if (mono_test_asany_unicode ("ABC", 4) != 0)
997 mono_test_asany (c, 0);
1000 catch (ArgumentException) {
1004 mono_test_asany (new Object (), 0);
1007 catch (ArgumentException) {
1013 /* AsAny marshalling + [In, Out] */
1015 public static int test_0_asany_in () {
1017 AsAnyStruct str = new AsAnyStruct(1,2,3, "ABC");
1018 mono_test_asany_in (str);
1021 AsAnyClass cls = new AsAnyClass(1,2,3, "ABC");
1022 mono_test_asany_in (cls);
1023 if ((cls.i != 1) || (cls.j != 2) || (cls.k != 3))
1027 object obj = new AsAnyStruct(1,2,3, "ABC");
1028 mono_test_asany_in (obj);
1029 str = (AsAnyStruct)obj;
1030 if ((str.i != 1) || (str.j != 2) || (str.k != 3))
1036 public static int test_0_asany_out () {
1038 AsAnyStruct str = new AsAnyStruct(1,2,3, "ABC");
1039 mono_test_asany_out (str);
1042 AsAnyClass cls = new AsAnyClass(1,2,3, "ABC");
1043 mono_test_asany_out (cls);
1044 if ((cls.i != 10) || (cls.j != 20) || (cls.k != 30))
1048 object obj = new AsAnyStruct(1,2,3, "ABC");
1049 mono_test_asany_out (obj);
1050 str = (AsAnyStruct)obj;
1051 if ((str.i != 10) || (str.j != 20) || (str.k != 30))
1057 public static int test_0_asany_inout () {
1059 AsAnyStruct str = new AsAnyStruct(1,2,3, "ABC");
1060 mono_test_asany_inout (str);
1063 AsAnyClass cls = new AsAnyClass(1,2,3, "ABC");
1064 mono_test_asany_inout (cls);
1065 if ((cls.i != 10) || (cls.j != 20) || (cls.k != 30))
1069 object obj = new AsAnyStruct(1,2,3, "ABC");
1070 mono_test_asany_inout (obj);
1071 str = (AsAnyStruct)obj;
1072 if ((str.i != 10) || (str.j != 20) || (str.k != 30))
1078 /* Byref String Array */
1080 [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_string_array")]
1081 public static extern int mono_test_marshal_byref_string_array (ref string[] data);
1083 public static int test_0_byref_string_array () {
1085 string[] arr = null;
1087 if (mono_test_marshal_byref_string_array (ref arr) != 0)
1090 arr = new string[] { "Alpha", "Beta", "Gamma" };
1092 if (mono_test_marshal_byref_string_array (ref arr) != 1)
1095 /* FIXME: Test returned array and out case */
1101 * AMD64 small structs-by-value tests.
1104 /* TEST 1: 16 byte long INTEGER struct */
1106 [StructLayout(LayoutKind.Sequential)]
1107 public struct Amd64Struct1 {
1114 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct1")]
1115 public static extern Amd64Struct1 mono_test_marshal_amd64_pass_return_struct1 (Amd64Struct1 s);
1117 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct1_many_args")]
1118 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);
1120 public static int test_0_amd64_struct1 () {
1121 Amd64Struct1 s = new Amd64Struct1 ();
1127 Amd64Struct1 s2 = mono_test_marshal_amd64_pass_return_struct1 (s);
1129 return ((s2.i == 6) && (s2.j == -4) && (s2.k == 0x1000000) && (s2.l == 0x10000000)) ? 0 : 1;
1132 public static int test_0_amd64_struct1_many_args () {
1133 Amd64Struct1 s = new Amd64Struct1 ();
1139 Amd64Struct1 s2 = mono_test_marshal_amd64_pass_return_struct1_many_args (s, 1, 2, 3, 4, 5, 6, 7, 8);
1141 return ((s2.i == 6) && (s2.j == -4) && (s2.k == 0x1000000) && (s2.l == 0x10000000 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8)) ? 0 : 1;
1144 /* TEST 2: 8 byte long INTEGER struct */
1146 [StructLayout(LayoutKind.Sequential)]
1147 public struct Amd64Struct2 {
1152 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct2")]
1153 public static extern Amd64Struct2 mono_test_marshal_amd64_pass_return_struct2 (Amd64Struct2 s);
1155 public static int test_0_amd64_struct2 () {
1156 Amd64Struct2 s = new Amd64Struct2 ();
1160 Amd64Struct2 s2 = mono_test_marshal_amd64_pass_return_struct2 (s);
1162 return ((s2.i == 6) && (s2.j == -4)) ? 0 : 1;
1165 /* TEST 3: 4 byte long INTEGER struct */
1167 [StructLayout(LayoutKind.Sequential)]
1168 public struct Amd64Struct3 {
1172 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct3")]
1173 public static extern Amd64Struct3 mono_test_marshal_amd64_pass_return_struct3 (Amd64Struct3 s);
1175 public static int test_0_amd64_struct3 () {
1176 Amd64Struct3 s = new Amd64Struct3 ();
1179 Amd64Struct3 s2 = mono_test_marshal_amd64_pass_return_struct3 (s);
1181 return (s2.i == -4) ? 0 : 1;
1184 /* Test 4: 16 byte long FLOAT struct */
1186 [StructLayout(LayoutKind.Sequential)]
1187 public struct Amd64Struct4 {
1188 public double d1, d2;
1191 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct4")]
1192 public static extern Amd64Struct4 mono_test_marshal_amd64_pass_return_struct4 (Amd64Struct4 s);
1194 public static int test_0_amd64_struct4 () {
1195 Amd64Struct4 s = new Amd64Struct4 ();
1199 Amd64Struct4 s2 = mono_test_marshal_amd64_pass_return_struct4 (s);
1201 return (s2.d1 == 6.0 && s2.d2 == -4.0) ? 0 : 1;
1208 /* Test 5: Float HFA */
1210 [StructLayout(LayoutKind.Sequential)]
1211 public struct TestStruct5 {
1212 public float d1, d2;
1215 [DllImport ("libtest", EntryPoint="mono_test_marshal_ia64_pass_return_struct5")]
1216 public static extern TestStruct5 mono_test_marshal_ia64_pass_return_struct5 (double d1, double d2, TestStruct5 s, int i, double f3, double f4);
1218 public static int test_0_ia64_struct5 () {
1219 TestStruct5 s = new TestStruct5 ();
1223 TestStruct5 s2 = mono_test_marshal_ia64_pass_return_struct5 (1.0, 2.0, s, 5, 3.0, 4.0);
1225 return (s2.d1 == 13.0 && s2.d2 == 7.0) ? 0 : 1;
1228 /* Test 6: Double HFA */
1230 [StructLayout(LayoutKind.Sequential)]
1231 public struct TestStruct6 {
1232 public double d1, d2;
1235 [DllImport ("libtest", EntryPoint="mono_test_marshal_ia64_pass_return_struct6")]
1236 public static extern TestStruct6 mono_test_marshal_ia64_pass_return_struct6 (double d1, double d2, TestStruct6 s, int i, double f3, double f4);
1238 public static int test_0_ia64_struct6 () {
1239 TestStruct6 s = new TestStruct6 ();
1243 TestStruct6 s2 = mono_test_marshal_ia64_pass_return_struct6 (1.0, 2.0, s, 3, 4.0, 5.0);
1245 return (s2.d1 == 12.0 && s2.d2 == 3.0) ? 0 : 1;
1248 /* Blittable class */
1249 [DllImport("libtest")]
1250 private static extern BlittableClass TestBlittableClass (BlittableClass vl);
1252 public static int test_0_marshal_blittable_class () {
1253 BlittableClass v1 = new BlittableClass ();
1255 /* Since it is blittable, it looks like it is passed as in/out */
1256 BlittableClass v2 = TestBlittableClass (v1);
1258 if (v1.a != 2 || v1.b != 3)
1261 if (v2.a != 2 || v2.b != 3)
1265 BlittableClass v3 = TestBlittableClass (null);
1267 if (v3.a != 42 || v3.b != 43)
1274 * Generic structures
1277 [StructLayout(LayoutKind.Sequential)]
1278 public struct Amd64Struct1Gen<T> {
1285 [DllImport ("libtest", EntryPoint="mono_test_marshal_amd64_pass_return_struct1")]
1286 public static extern Amd64Struct1Gen<int> mono_test_marshal_amd64_pass_return_struct1_gen (Amd64Struct1Gen<int> s);
1288 public static int test_0_amd64_struct1_gen () {
1289 Amd64Struct1Gen<int> s = new Amd64Struct1Gen<int> ();
1295 Amd64Struct1Gen<int> s2 = mono_test_marshal_amd64_pass_return_struct1_gen (s);
1297 return ((s2.i == 6) && (s2.j == -4) && (s2.k == 0x1000000) && (s2.l == 0x10000000)) ? 0 : 1;
1304 public static int test_0_marshal_byval_class () {
1305 SimpleObj obj0 = new SimpleObj ();
1309 if (class_marshal_test0 (obj0) != 0)
1315 public static int test_0_marshal_byval_class_null () {
1316 if (class_marshal_test4 (null) != 0)
1322 public static int test_0_marshal_out_class () {
1325 class_marshal_test1 (out obj1);
1327 if (obj1.str != "ABC")
1336 public static int test_0_marshal_string () {
1337 return string_marshal_test0 ("TEST0");
1340 public static int test_0_marshal_out_string () {
1343 string_marshal_test1 (out res);
1351 public static int test_0_marshal_byref_string () {
1352 string res = "TEST1";
1354 int r = string_marshal_test2 (ref res);
1362 public static int test_0_marshal_null_string () {
1363 return string_marshal_test3 (null);
1367 [DllImport ("libtest", EntryPoint="mono_test_stdcall_mismatch_1", CallingConvention=CallingConvention.StdCall)]
1368 public static extern int mono_test_stdcall_mismatch_1 (int a, int b, int c);
1370 /* Test mismatched called conventions, the native function is cdecl */
1371 public static int test_0_stdcall_mismatch_1 () {
1372 mono_test_stdcall_mismatch_1 (0, 1, 2);
1376 [DllImport ("libtest", EntryPoint="mono_test_stdcall_mismatch_2", CallingConvention=CallingConvention.Cdecl)]
1377 public static extern int mono_test_stdcall_mismatch_2 (int a, int b, int c);
1379 /* Test mismatched called conventions, the native function is stdcall */
1380 public static int test_0_stdcall_mismatch_2 () {
1381 mono_test_stdcall_mismatch_2 (0, 1, 2);
1386 [DllImport ("libtest", EntryPoint="mono_test_stdcall_name_mangling", CallingConvention=CallingConvention.StdCall)]
1387 public static extern int mono_test_stdcall_name_mangling (int a, int b, int c);
1389 public static int test_0_stdcall_name_mangling () {
1390 return mono_test_stdcall_name_mangling (0, 1, 2) == 3 ? 0 : 1;
1395 [DllImport ("libtest", EntryPoint="mono_test_marshal_pass_return_float")]
1396 public static extern float mono_test_marshal_pass_return_float (float f);
1398 public static int test_0_pass_return_float () {
1399 float f = mono_test_marshal_pass_return_float (1.5f);
1401 return (f == 2.5f) ? 0 : 1;
1405 * Pointers to structures can not be passed
1408 /* This seems to be allowed by MS in some cases */
1410 public struct CharInfo {
1411 public char Character;
1412 public short Attributes;
1415 [DllImport ("libtest", EntryPoint="mono_test_marshal_struct")]
1416 public static unsafe extern int mono_test_marshal_ptr_to_struct (CharInfo *ptr);
1418 public static unsafe int test_0_marshal_ptr_to_struct () {
1419 CharInfo [] buffer = new CharInfo [1];
1420 fixed (CharInfo *ptr = &buffer [0]) {
1422 mono_test_marshal_ptr_to_struct (ptr);
1425 catch (MarshalDirectiveException) {
1434 * LPWStr marshalling
1437 [DllImport("libtest", EntryPoint="test_lpwstr_marshal")]
1438 [return: MarshalAs(UnmanagedType.LPWStr)]
1439 private static extern string mono_test_marshal_lpwstr_marshal(
1440 [MarshalAs(UnmanagedType.LPWStr)] string s,
1443 [DllImport("libtest", EntryPoint="test_lpwstr_marshal", CharSet=CharSet.Unicode)]
1444 private static extern string mono_test_marshal_lpwstr_marshal2(
1448 [DllImport("libtest", EntryPoint="test_lpwstr_marshal_out")]
1449 private static extern void mono_test_marshal_lpwstr_out_marshal(
1450 [MarshalAs(UnmanagedType.LPWStr)] out string s);
1452 [DllImport("libtest", EntryPoint="test_lpwstr_marshal_out", CharSet=CharSet.Unicode)]
1453 private static extern void mono_test_marshal_lpwstr_out_marshal2(
1456 public static int test_0_pass_return_lwpstr () {
1459 mono_test_marshal_lpwstr_out_marshal (out s);
1465 mono_test_marshal_lpwstr_out_marshal2 (out s);
1473 public static int test_0_out_lwpstr () {
1476 string res = mono_test_marshal_lpwstr_marshal (s, s.Length);
1481 string res2 = mono_test_marshal_lpwstr_marshal2 (s, s.Length);
1490 * Byref bool marshalling
1493 [DllImport("libtest")]
1494 extern static int marshal_test_ref_bool
1497 [MarshalAs(UnmanagedType.I1)] ref bool b1,
1498 [MarshalAs(UnmanagedType.VariantBool)] ref bool b2,
1502 public static int test_0_pass_byref_bool () {
1503 for (int i = 0; i < 8; i++)
1505 bool b1 = (i & 4) != 0;
1506 bool b2 = (i & 2) != 0;
1507 bool b3 = (i & 1) != 0;
1508 bool orig_b1 = b1, orig_b2 = b2, orig_b3 = b3;
1509 if (marshal_test_ref_bool(i, ref b1, ref b2, ref b3) != 0)
1523 * Bool struct field marshalling
1529 [MarshalAs(UnmanagedType.I1)] public bool b1;
1530 [MarshalAs(UnmanagedType.VariantBool)] public bool b2;
1534 [DllImport("libtest")]
1535 extern static int marshal_test_bool_struct(ref BoolStruct s);
1537 public static int test_0_pass_bool_in_struct () {
1538 for (int i = 0; i < 8; i++)
1540 BoolStruct s = new BoolStruct();
1542 s.b1 = (i & 4) != 0;
1543 s.b2 = (i & 2) != 0;
1544 s.b3 = (i & 1) != 0;
1545 BoolStruct orig = s;
1546 if (marshal_test_bool_struct(ref s) != 0)
1548 if (s.b1 != !orig.b1)
1550 if (s.b2 != !orig.b2)
1552 if (s.b3 != !orig.b3)
1560 * Alignment of structs containing longs
1563 struct LongStruct2 {
1569 public LongStruct2 l;
1572 [DllImport("libtest")]
1573 extern static int mono_test_marshal_long_struct (ref LongStruct s);
1575 public static int test_47_pass_long_struct () {
1576 LongStruct s = new LongStruct ();
1578 s.l = new LongStruct2 ();
1581 return mono_test_marshal_long_struct (ref s);
1585 * Invoking pinvoke methods through delegates
1588 delegate int MyDelegate (string name);
1590 [DllImport ("libtest", EntryPoint="mono_test_puts_static")]
1591 public static extern int puts_static (string name);
1593 public static int test_0_invoke_pinvoke_through_delegate () {
1594 puts_static ("A simple Test for PInvoke 1");
1596 MyDelegate d = new MyDelegate (puts_static);
1597 d ("A simple Test for PInvoke 2");
1599 object [] args = {"A simple Test for PInvoke 3"};
1600 d.DynamicInvoke (args);
1606 * Missing virtual pinvoke methods
1611 public virtual object MyClone ()
1617 public class T2 : T {
1618 [MethodImplAttribute(MethodImplOptions.InternalCall)]
1619 public override extern object MyClone ();
1622 public static int test_0_missing_virtual_pinvoke_method () {
1627 } catch (Exception ex) {
1635 * Marshalling of type 'object'
1638 [DllImport ("libtest", EntryPoint="mono_test_marshal_class")]
1639 public static extern SimpleClass mono_test_marshal_object (int i, int j, int k, object ss, int l);
1641 public static int test_0_marshal_object () {
1643 mono_test_marshal_object (0, 0, 0, null, 0);
1645 } catch (Exception) {
1651 * Marshalling of DateTime to OLE DATE (double)
1653 [DllImport ("libtest", EntryPoint="mono_test_marshal_date_time")]
1654 public static extern double mono_test_marshal_date_time (DateTime d, out DateTime d2);
1656 public static int test_0_marshal_date_time () {
1657 DateTime d = new DateTime (2009, 12, 6);
1659 double d3 = mono_test_marshal_date_time (d, out d2);
1668 * Calling pinvoke functions dynamically using calli
1671 [DllImport("libtest")]
1672 private static extern IntPtr mono_test_marshal_lookup_symbol (string fileName);
1674 delegate void CalliDel (IntPtr a, int[] f);
1676 public static int test_0_calli_dynamic () {
1677 /* we need the cdecl version because the icall convention demands it under Windows */
1678 IntPtr func = mono_test_marshal_lookup_symbol ("mono_test_marshal_inout_array_cdecl");
1680 DynamicMethod dm = new DynamicMethod ("calli", typeof (void), new Type [] { typeof (IntPtr), typeof (int[]) });
1682 var il = dm.GetILGenerator ();
1683 var signature = SignatureHelper.GetMethodSigHelper (CallingConvention.Cdecl, typeof (void));
1685 il.Emit (OpCodes.Ldarg, 1);
1686 signature.AddArgument (typeof (byte[]));
1688 il.Emit (OpCodes.Ldarg_0);
1690 il.Emit (OpCodes.Calli, signature);
1691 il.Emit (OpCodes.Ret);
1693 var f = (CalliDel)dm.CreateDelegate (typeof (CalliDel));
1695 int[] arr = new int [1000];
1696 for (int i = 0; i < 50; ++i)
1699 if (arr.Length != 1000)
1701 for (int i = 0; i < 50; ++i)
1702 if (arr [i] != 50 - i)
1709 /*char array marshaling */
1710 [DllImport ("libtest", EntryPoint="mono_test_marshal_ansi_char_array", CharSet=CharSet.Ansi)]
1711 public static extern int mono_test_marshal_ansi_char_array (char[] a1);
1713 public static int test_0_marshal_ansi_char_array () {
1714 char[] buf = new char [32];
1720 if (mono_test_marshal_ansi_char_array (buf) != 0)
1723 string s = new string (buf);
1724 if (s.StartsWith ("qwer"))
1730 /*char array marshaling */
1731 [DllImport ("libtest", EntryPoint="mono_test_marshal_unicode_char_array", CharSet=CharSet.Unicode)]
1732 public static extern int mono_test_marshal_unicode_char_array (char[] a1);
1734 public static int test_0_marshal_unicode_char_array () {
1735 char[] buf = new char [32];
1741 if (mono_test_marshal_unicode_char_array (buf) != 0)
1744 string s = new string (buf);
1745 if (s.StartsWith ("abcdef"))
1751 [DllImport ("libtest", EntryPoint="mono_test_marshal_lpstr")]
1752 public static extern int mono_test_marshal_lpstr ([MarshalAs(UnmanagedType.LPStr)] string str);
1754 public static int test_0_mono_test_marshal_lpstr () {
1757 if (mono_test_marshal_lpstr (str) != 0)
1763 [DllImport ("libtest", EntryPoint="mono_test_marshal_lpwstr")]
1764 public static extern int mono_test_marshal_lpwstr ([MarshalAs(UnmanagedType.LPWStr)] string str);
1766 public static int test_0_mono_test_marshal_lpwstr () {
1769 if (mono_test_marshal_lpwstr (str) != 0)
1776 [method: DllImport ("libtest", EntryPoint="mono_test_marshal_return_lpstr")]
1777 [return: MarshalAs(UnmanagedType.LPStr)]
1778 public static extern string mono_test_marshal_return_lpstr ();
1780 public static int test_0_mono_test_marshal_return_lpstr () {
1781 string str = mono_test_marshal_return_lpstr ();
1788 [method: DllImport ("libtest", EntryPoint="mono_test_marshal_return_lpwstr")]
1789 [return: MarshalAs(UnmanagedType.LPWStr)]
1790 public static extern string mono_test_marshal_return_lpwstr ();
1792 public static int test_0_mono_test_marshal_return_lpwstr () {
1793 string str = mono_test_marshal_return_lpwstr ();
1800 [DllImport ("libtest", EntryPoint="mono_test_has_thiscall")]
1801 public static extern int mono_test_has_thiscall ();
1803 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall1", CallingConvention=CallingConvention.ThisCall)]
1804 public static extern int mono_test_native_thiscall (int a);
1806 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall2", CallingConvention=CallingConvention.ThisCall)]
1807 public static extern int mono_test_native_thiscall (int a, int b);
1809 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall3", CallingConvention=CallingConvention.ThisCall)]
1810 public static extern int mono_test_native_thiscall (int a, int b, int c);
1812 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall1", CallingConvention=CallingConvention.ThisCall)]
1813 public static extern int mono_test_native_thiscall (TinyStruct a);
1815 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall2", CallingConvention=CallingConvention.ThisCall)]
1816 public static extern int mono_test_native_thiscall (TinyStruct a, int b);
1818 [DllImport ("libtest", EntryPoint = "_mono_test_native_thiscall3", CallingConvention=CallingConvention.ThisCall)]
1819 public static extern int mono_test_native_thiscall (TinyStruct a, int b, int c);
1821 public static int test_0_native_thiscall ()
1823 if (mono_test_has_thiscall () == 0)
1826 if (mono_test_native_thiscall (1968329802) != 1968329802)
1829 if (mono_test_native_thiscall (268894549, 1212675791) != 1481570339)
1832 if (mono_test_native_thiscall (1288082683, -421187449, -1733670329) != -866775098)
1835 if (mono_test_native_thiscall (new TinyStruct(1968329802)) != 1968329802)
1838 if (mono_test_native_thiscall (new TinyStruct(268894549), 1212675791) != 1481570339)
1841 if (mono_test_native_thiscall (new TinyStruct(1288082683), -421187449, -1733670329) != -866775098)
1847 [DllImport ("libtest", EntryPoint = "mono_test_marshal_return_single_double_struct")]
1848 public static extern SingleDoubleStruct mono_test_marshal_return_single_double_struct ();
1850 public static int test_0_x86_single_double_struct_ret () {
1851 double d = mono_test_marshal_return_single_double_struct ().d;