[runtime] Overwrite stacktrace for exception on re-throw. Fixes #1856.
[mono.git] / mono / tests / cas / linkdemand / cas3.cs
1 using System;
2 using System.Security;
3 using System.Security.Permissions;
4
5 [assembly: SecurityPermission (SecurityAction.RequestRefuse, ControlPrincipal=true)]
6
7 public class Program {
8
9         [SecurityPermission (SecurityAction.LinkDemand, ControlPrincipal=true)]
10         public static int Test ()
11         {
12                 return 0;
13         }
14
15         // we throw as soon as we try to compile this
16         static void DeepTest ()
17         {
18                 Test ();
19         }
20
21         // no problem compiling Test as linking to DeepTest is possible
22         static void Test (int i)
23         {
24                 if (i == 200) {
25                         DeepTest ();
26                 }
27         }
28
29         static int Main ()
30         {
31                 int err = 2;
32                 int i = 0;
33                 try {
34                         for (i=0; i < 256; i++) {
35                                 Test (i);
36                         }
37                         Console.WriteLine ("*{0}* Iteration Completed", err);
38                 }
39                 catch (SecurityException) {
40                         err = (i == 200) ? 0 : 1;
41                         Console.WriteLine ("*{0}* Iteration Count: {1}", err, i);
42                 }
43                 return err;
44         }
45 }