New test.
[mono.git] / mono / tests / cas / linkdemand / icall1.cs
1 using System;
2 using System.Runtime.CompilerServices;
3 using System.Security;
4
5 namespace System {
6
7         // private internal call for Mono runtime
8         public class Environment {
9
10                 [MethodImplAttribute (MethodImplOptions.InternalCall)]
11                 public extern static string internalGetGacPath ();
12         }
13
14         // private internal call for MS runtime
15         // http://msdn.microsoft.com/msdnmag/issues/04/11/NETMatters/
16         public class Guid {
17
18                 public Guid ()
19                 {
20                 }
21
22                 [MethodImpl (MethodImplOptions.InternalCall)]
23 #if NET_2_0
24                 public extern void CompleteGuid ();
25 #else
26                 public extern bool CompleteGuid ();
27 #endif
28         }
29 }
30
31 public class Program {
32
33         static bool RunningOnMono ()
34         {
35                 bool mono = (Type.GetType ("Mono.Math.BigInteger") != null); 
36                 Console.WriteLine ("Running on {0} runtime...", mono ? "Mono" : "Microsoft");
37                 return mono;
38         }
39
40         static int Main ()
41         {
42                 try {
43                         string result = null;
44                         if (RunningOnMono ()) {
45                                 result = Environment.internalGetGacPath ();
46                         } else {
47                                 System.Guid g = new System.Guid ();
48 #if NET_2_0
49                                 g.CompleteGuid ();
50                                 result = "completed";
51 #else
52                                 result = g.CompleteGuid ().ToString ();
53 #endif
54                         }
55 #if NET_2_0
56                         Console.WriteLine ("*0* Expected internal call: {0}", result);
57 #else
58                         Console.WriteLine ("*0* Unexpected (1.x) but accepted (like 2.x) internal call: {0}", result);
59 #endif
60                         return 0;
61                 }
62                 catch (SecurityException se) {
63 #if NET_2_0
64                         Console.WriteLine ("*1* Unexpected SecurityException\n{0}", se);
65                         return 1;
66 #else
67                         Console.WriteLine ("*0* Expected (1.x) SecurityException\n{0}", se);
68                         return 0;
69 #endif
70                 }
71                 catch (Exception e) {
72                         Console.WriteLine ("*2* Unexpected exception\n{0}", e);
73                         return 2;
74                 }
75         }
76 }