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
{
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)]
22 info
= new LinkDemandStruct ();
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 () {
38 [SiteIdentityPermission (SecurityAction
.PermitOnly
)]
39 [PermissionSet (SecurityAction
.PermitOnly
, Unrestricted
=true)]
40 [PermissionSet (SecurityAction
.PermitOnly
, Unrestricted
=false)]
45 [PermissionSet (SecurityAction
.PermitOnly
, Unrestricted
=true)]
46 [PermissionSet (SecurityAction
.PermitOnly
, Unrestricted
=false)]
51 [EnvironmentPermission (SecurityAction
.Demand
, Unrestricted
=true)]
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)
66 if (program
.GetConstructor (System
.Type
.EmptyTypes
).GetCustomAttributes (true).Length
!= 0)
69 if (program
.GetProperty ("Message").GetSetMethod ().GetCustomAttributes (true).Length
!= 0)
72 if (program
.GetMethod ("Main").GetCustomAttributes (true).Length
!= 0)
75 if (program
.GetMethod ("Test2").GetCustomAttributes (true).Length
!= 0)
78 Type test2
= typeof (Test2
);
79 if (test2
.GetCustomAttributes (true).Length
!= 0)
82 Console
.WriteLine ("OK");
87 [SecurityPermission (SecurityAction
.Demand
, ControlAppDomain
=true)]
88 public partial class Test2
{}
90 [SecurityPermission (SecurityAction
.Demand
, ControlAppDomain
=true)]
91 public partial class Test2
{}