2 using System.Runtime.InteropServices;
6 [DllImport ("libtest", EntryPoint="mono_test_byvalstr_gen")]
7 public static extern IntPtr mono_test_byvalstr_gen();
9 [DllImport ("libtest", EntryPoint="mono_test_byvalstr_check")]
10 public static extern int mono_test_byvalstr_check(IntPtr data, string correctString);
12 [DllImport ("libtest", EntryPoint="mono_test_byvalstr_check_unicode")]
13 public static extern int mono_test_byvalstr_check_unicode(ref ByValStrStruct_Unicode var, int test);
15 [StructLayout (LayoutKind.Sequential)]
16 public struct ByValStrStruct
18 [MarshalAs(UnmanagedType.ByValTStr, SizeConst=100)]
22 [StructLayout (LayoutKind.Sequential, CharSet=CharSet.Unicode)]
23 public struct ByValStrStruct_Unicode
25 [MarshalAs(UnmanagedType.ByValTStr, SizeConst=4)]
31 public unsafe static int Main ()
33 string testString = "A small string";
35 IntPtr udata = mono_test_byvalstr_gen();
37 ByValStrStruct data = new ByValStrStruct();
40 Marshal.StructureToPtr(data, udata, false);
42 int c = mono_test_byvalstr_check(udata, testString);
46 ByValStrStruct_Unicode a = new ByValStrStruct_Unicode ();
49 c = mono_test_byvalstr_check_unicode (ref a, 1);
54 c = mono_test_byvalstr_check_unicode (ref a, 2);
59 c = mono_test_byvalstr_check_unicode (ref a, 3);