[Test] Avoid MethodInfoTest.GetMethodBody failure when executed on a release (IL...
[mono.git] / mcs / class / corlib / System.Security / CodeAccessPermission.cs
index 152db9cf8b0a780ba422ef064d23a0d1f80f1bab..d6fb5d8d9dea5089c6aab58f49b23a4e0336bf21 100644 (file)
@@ -43,9 +43,8 @@ namespace System.Security {
 
        [Serializable]
        [SecurityPermission (SecurityAction.InheritanceDemand, ControlEvidence = true, ControlPolicy = true)]
-#if NET_2_0
        [ComVisible (true)]
-#endif
+       [MonoTODO ("CAS support is experimental (and unsupported).")]
        public abstract class CodeAccessPermission : IPermission, ISecurityEncodable, IStackWalk {
 
 
@@ -53,7 +52,7 @@ namespace System.Security {
                {
                }
 
-               [MonoTODO ("Imperative mode isn't supported")]
+               [MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
                public void Assert ()
                {
                        new PermissionSet (this).Assert ();
@@ -115,13 +114,12 @@ namespace System.Security {
                        new PermissionSet (this).CasOnlyDemand (3);
                }
 
-               [MonoTODO ("Imperative mode isn't supported")]
+               [MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
                public void Deny ()
                {
                        new PermissionSet (this).Deny ();
                }
 
-#if NET_2_0
                [ComVisible (false)]
                public override bool Equals (object obj)
                {
@@ -132,17 +130,14 @@ namespace System.Security {
                        CodeAccessPermission cap = (obj as CodeAccessPermission);
                        return (IsSubsetOf (cap) && cap.IsSubsetOf (this));
                }
-#endif
 
                public abstract void FromXml (SecurityElement elem);
 
-#if NET_2_0
                [ComVisible (false)]
                public override int GetHashCode ()
                {
                        return base.GetHashCode ();
                }
-#endif
 
                public abstract IPermission Intersect (IPermission target);
 
@@ -163,13 +158,13 @@ namespace System.Security {
                        return null;
                }
 
-               [MonoTODO ("Imperative mode isn't supported")]
+               [MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
                public void PermitOnly ()
                {
                        new PermissionSet (this).PermitOnly ();
                }
 
-               [MonoTODO ("Imperative mode isn't supported")]
+               [MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
                public static void RevertAll ()
                {
                        if (!SecurityManager.SecurityEnabled)
@@ -198,7 +193,7 @@ namespace System.Security {
                        }
                }
 
-               [MonoTODO ("Imperative mode isn't supported")]
+               [MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
                public static void RevertAssert ()
                {
                        if (!SecurityManager.SecurityEnabled)
@@ -213,7 +208,7 @@ namespace System.Security {
                        }
                }
 
-               [MonoTODO ("Imperative mode isn't supported")]
+               [MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
                public static void RevertDeny ()
                {
                        if (!SecurityManager.SecurityEnabled)
@@ -228,7 +223,7 @@ namespace System.Security {
                        }
                }
 
-               [MonoTODO ("Imperative mode isn't supported")]
+               [MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
                public static void RevertPermitOnly ()
                {
                        if (!SecurityManager.SecurityEnabled)
@@ -262,14 +257,7 @@ namespace System.Security {
                        case PermissionState.None:
                                break;
                        case PermissionState.Unrestricted:
-#if NET_2_0
                                // unrestricted permissions are possible for identiy permissions
-#else
-                               if (!allowUnrestricted) {
-                                       msg = Locale.GetText ("Unrestricted isn't not allowed for identity permissions.");
-                                       throw new ArgumentException (msg, "state");
-                               }
-#endif
                                break;
                        default:
                                msg = String.Format (Locale.GetText ("Invalid enum {0}"), state);
@@ -390,11 +378,15 @@ namespace System.Security {
                internal static void ThrowSecurityException (object demanded, string message, SecurityFrame frame,
                        SecurityAction action, IPermission failed)
                {
+#if NET_2_1
+                       throw new SecurityException (message);
+#else
                        Assembly a = frame.Assembly;
                        throw new SecurityException (Locale.GetText (message), 
                                a.UnprotectedGetName (), a.GrantedPermissionSet, 
                                a.DeniedPermissionSet, frame.Method, action, demanded, 
                                failed, a.UnprotectedGetEvidence ());
+#endif
                }
        }
 }