"disable_omit_fp" can now be included in MONO_DEBUG
[mono-project.git] / mcs / tests / test-311.cs
blob1db5487ecaf086f907d0f478fae8d40dce3b43c3
1 using System;
2 using System.Security;
3 using System.Security.Permissions;
5 [assembly: SecurityPermission (SecurityAction.RequestMinimum, Execution=true)]
6 [assembly: SecurityPermission (SecurityAction.RequestOptional, Unrestricted=true)]
7 [assembly: SecurityPermission (SecurityAction.RequestRefuse, SkipVerification=true)]
9 [SecurityPermission (SecurityAction.LinkDemand, ControlPrincipal=true)]
10 struct LinkDemandStruct {
11 internal string Info;
14 [SecurityPermission (SecurityAction.Demand, ControlAppDomain=true)]
15 public class Program {
17 private static string _message = "Hello Mono!";
18 private LinkDemandStruct info;
20 [SecurityPermission (SecurityAction.InheritanceDemand, ControlAppDomain=true)]
21 public Program () {
22 info = new LinkDemandStruct ();
23 info.Info = ":-)";
26 public static string Message {
27 [SecurityPermission (SecurityAction.PermitOnly, ControlEvidence=true)]
28 get { return _message; }
29 [SecurityPermission (SecurityAction.Assert, ControlThread=true)]
30 set { _message = value; }
33 [SecurityPermission (SecurityAction.Deny, UnmanagedCode=true)]
34 private bool DenyMethod () {
35 return false;
38 [SiteIdentityPermission (SecurityAction.PermitOnly)]
39 [PermissionSet (SecurityAction.PermitOnly, Unrestricted=true)]
40 [PermissionSet (SecurityAction.PermitOnly, Unrestricted=false)]
41 public void Test2 ()
45 [PermissionSet (SecurityAction.PermitOnly, Unrestricted=true)]
46 [PermissionSet (SecurityAction.PermitOnly, Unrestricted=false)]
47 public void Test3 ()
51 [EnvironmentPermission (SecurityAction.Demand, Unrestricted=true)]
52 public void Test4 ()
56 [SecurityPermission (SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlEvidence, UnmanagedCode=true)]
57 [SecurityPermission (SecurityAction.Demand, Flags = SecurityPermissionFlag.AllFlags, UnmanagedCode=true)]
58 public static int Main (string[] args)
60 // TODO: this will not be working for .NET 2.0 as attributes are decoded back
61 Type program = typeof (Program);
63 if (program.GetCustomAttributes (true).Length != 0)
64 return 1;
66 if (program.GetConstructor (System.Type.EmptyTypes).GetCustomAttributes (true).Length != 0)
67 return 2;
69 if (program.GetProperty ("Message").GetSetMethod ().GetCustomAttributes (true).Length != 0)
70 return 3;
72 if (program.GetMethod ("Main").GetCustomAttributes (true).Length != 0)
73 return 4;
75 if (program.GetMethod ("Test2").GetCustomAttributes (true).Length != 0)
76 return 5;
78 Type test2 = typeof (Test2);
79 if (test2.GetCustomAttributes (true).Length != 0)
80 return 6;
82 Console.WriteLine ("OK");
83 return 0;
87 [SecurityPermission (SecurityAction.Demand, ControlAppDomain=true)]
88 public partial class Test2 {}
90 [SecurityPermission (SecurityAction.Demand, ControlAppDomain=true)]
91 public partial class Test2 {}