Copied remotely
[mono.git] / mono / tests / pinvoke1.cs
1 using System;
2 using System.Runtime.InteropServices;
3 using System.Runtime.CompilerServices;
4
5 public class T {
6
7         public virtual object MyClone ()
8         {
9                 return null;
10         }
11
12 }
13
14 public class Test : T {
15
16         [MethodImplAttribute(MethodImplOptions.InternalCall)]
17         public override extern object MyClone ();
18
19         delegate int MyDelegate (string name);
20
21         [DllImport ("libtest", EntryPoint="mono_test_puts_static")]
22         public static extern int puts_static (string name);
23
24         public static int Main () {
25                 puts_static ("A simple Test for PInvoke 1");
26
27                 MyDelegate d = new MyDelegate (puts_static);
28                 d ("A simple Test for PInvoke 2");
29
30                 object [] args = {"A simple Test for PInvoke 3"};
31                 d.DynamicInvoke (args);
32                 
33                 int noimpl = 0;
34                 try {
35                         Test X = new Test ();
36                         X.MyClone ();
37                 } catch {
38                         noimpl = 1;
39                 }
40
41                 if (noimpl == 0)
42                         return 1;
43                 
44                 return 0;
45         }
46 }