One more class init order test case (to test when inlining is involved).
[mono.git] / mono / tests / pinvoke3.cs
1 using System;
2 using System.Runtime.InteropServices;
3
4 public class Test {
5
6         [StructLayout (LayoutKind.Sequential)]
7         public struct SimpleStruct {
8                 public bool a;
9                 public bool b;
10                 public bool c;
11                 public string d;
12         }
13
14         public static int delegate_test (SimpleStruct ss)
15         {
16                 Console.WriteLine ("delegate called");
17                 Console.WriteLine ("A: " + ss.a);
18                 Console.WriteLine ("B: " + ss.b);
19                 Console.WriteLine ("C: " + ss.c);
20                 Console.WriteLine ("D: " + ss.d);
21                 
22                 if (!ss.a && ss.b && !ss.c && ss.d == "TEST")
23                         return 0;
24                 
25                 return 1;
26         }
27         
28         [DllImport ("libtest.so", EntryPoint="mono_test_marshal_delegate2")]
29         public static extern int mono_test_marshal_delegate2 (SimpleDelegate2 d);
30
31         public delegate int SimpleDelegate2 (SimpleStruct ss);
32
33         public static int Main () {
34                 
35                 SimpleDelegate2 d = new SimpleDelegate2 (delegate_test);
36
37                 if (mono_test_marshal_delegate2 (d) != 0)
38                         return 1;
39                 
40                 return 0;
41         }
42 }