More removal of old defines
authorMiguel de Icaza <miguel@gnome.org>
Fri, 6 Nov 2009 21:25:38 +0000 (21:25 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Fri, 6 Nov 2009 21:25:38 +0000 (21:25 -0000)
svn path=/trunk/mcs/; revision=145609

32 files changed:
mcs/class/corlib/System.Security/AllowPartiallyTrustedCallersAttribute.cs
mcs/class/corlib/System.Security/CodeAccessPermission.cs
mcs/class/corlib/System.Security/HostProtectionException.cs
mcs/class/corlib/System.Security/HostSecurityManager.cs
mcs/class/corlib/System.Security/HostSecurityManagerFlags.cs
mcs/class/corlib/System.Security/IEvidenceFactory.cs
mcs/class/corlib/System.Security/IPermission.cs
mcs/class/corlib/System.Security/ISecurityEncodable.cs
mcs/class/corlib/System.Security/ISecurityPolicyEncodable.cs
mcs/class/corlib/System.Security/IStackWalk.cs
mcs/class/corlib/System.Security/NamedPermissionSet.cs
mcs/class/corlib/System.Security/PermissionBuilder.cs
mcs/class/corlib/System.Security/PermissionSet.cs
mcs/class/corlib/System.Security/PermissionSetCollection.cs
mcs/class/corlib/System.Security/PolicyLevelType.cs
mcs/class/corlib/System.Security/SecureString.cs
mcs/class/corlib/System.Security/SecurityContext.cs
mcs/class/corlib/System.Security/SecurityContextSwitcher.cs
mcs/class/corlib/System.Security/SecurityCriticalAttribute.cs
mcs/class/corlib/System.Security/SecurityCriticalScope.cs
mcs/class/corlib/System.Security/SecurityElement.cs
mcs/class/corlib/System.Security/SecurityException.cs
mcs/class/corlib/System.Security/SecurityManager.cs
mcs/class/corlib/System.Security/SecuritySafeCriticalAttribute.cs
mcs/class/corlib/System.Security/SecurityState.cs
mcs/class/corlib/System.Security/SecurityTransparentAttribute.cs
mcs/class/corlib/System.Security/SecurityTreatAsSafeAttribute.cs
mcs/class/corlib/System.Security/SecurityZone.cs
mcs/class/corlib/System.Security/SuppressUnmanagedCodeSecurityAttribute.cs
mcs/class/corlib/System.Security/UnverifiableCodeAttribute.cs
mcs/class/corlib/System.Security/VerificationException.cs
mcs/class/corlib/System.Security/XmlSyntaxException.cs

index f372bd7d57c835293fe012ede0cfeda0e1edf98b..cbe0765a4c4b6a1f72dff5810d132ca965761a18 100644 (file)
@@ -31,9 +31,7 @@ using System.Runtime.InteropServices;
 
 namespace System.Security {
 
-#if NET_2_0
        [ComVisible (true)]
-#endif
        [AttributeUsage (AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
        public sealed class AllowPartiallyTrustedCallersAttribute : Attribute {
 
index c97d080a5875c5732659572ae76c54246219bf32..d6fb5d8d9dea5089c6aab58f49b23a4e0336bf21 100644 (file)
@@ -43,9 +43,7 @@ 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 {
 
@@ -122,7 +120,6 @@ namespace System.Security {
                        new PermissionSet (this).Deny ();
                }
 
-#if NET_2_0
                [ComVisible (false)]
                public override bool Equals (object obj)
                {
@@ -133,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);
 
@@ -263,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);
index 70d20535c6944507c8da377d2dff70b52846b85e..8d828bc216e8d522ed755093880ce2cc2bf8af85 100644 (file)
@@ -26,7 +26,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
 
 using System.Runtime.InteropServices;
 using System.Runtime.Serialization;
@@ -90,5 +89,3 @@ namespace System.Security {
                }
        }
 }
-
-#endif
index ecd099ec34a0b02e909896c2dab33ec29367ab37..8b6c9c8c50d372eb39364131457906fd13cd0145 100644 (file)
@@ -26,8 +26,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 using System.Reflection;
 using System.Runtime.Hosting;
 using System.Runtime.InteropServices;
@@ -103,5 +101,3 @@ namespace System.Security {
                }
        }
 }
-
-#endif
index 2da516f77d9e3e7a7f877d386a16201673ce3d3f..54e69440b50624c985cc4f66337b7bfbef09c108 100644 (file)
@@ -26,8 +26,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 using System.Runtime.InteropServices;
 
 namespace System.Security {
@@ -45,5 +43,3 @@ namespace System.Security {
                AllFlags = HostAppDomainEvidence | HostPolicyLevel | HostAssemblyEvidence | HostDetermineApplicationTrust | HostResolvePolicy
        }
 }
-
-#endif
index 0e988aa987d2336fe9bc782fbe6eb7fa1b7746aa..b15cb9c5b4a2726555dbd190e95ba99856b2a1bd 100644 (file)
@@ -30,9 +30,7 @@ using System.Security.Policy;
 
 namespace System.Security {
 
-#if NET_2_0
        [ComVisible (true)]
-#endif
        public interface IEvidenceFactory {
                Evidence Evidence { get; }
        }
index 78750475dc2e7636c9da46a17682efe413f1c4fb..4155b32463d48b8310fbb632a7f064b9e392098d 100644 (file)
@@ -31,9 +31,7 @@ using System.Runtime.InteropServices;
 
 namespace System.Security {
 
-#if NET_2_0
        [ComVisible (true)]
-#endif
 #if NET_2_1 && !MONOTOUCH
        public interface IPermission {
 #else
index 238524a159f4c46a01ec5a506ec87f3b63e5e688..06fd6f944774b85a3f45d4522ea51820dafe5140 100644 (file)
@@ -31,9 +31,7 @@ using System.Runtime.InteropServices;
 
 namespace System.Security {
 
-#if NET_2_0
        [ComVisible (true)]
-#endif
        public interface ISecurityEncodable {
 
                void FromXml (SecurityElement e);
index 13582e8754c38ee387d4c0e0ad3cbaed2db2522d..d2085ef8ef66080064b9ed0d4cb20236a876cd18 100644 (file)
@@ -32,9 +32,7 @@ using System.Security.Policy;
 
 namespace System.Security {
 
-#if NET_2_0
        [ComVisible (true)]
-#endif
        public interface ISecurityPolicyEncodable {
 
                void FromXml (SecurityElement e, PolicyLevel level);
index 38a7ecdd0d55c0564051fffa7d43af03c1a385fe..1195a0993b467e24b63f703a00f56c28218b4c85 100644 (file)
@@ -31,9 +31,7 @@ using System.Runtime.InteropServices;
 
 namespace System.Security {
 
-#if NET_2_0
        [ComVisible (true)]
-#endif
        public interface IStackWalk {
 
                void Assert ();
index 7c1ca4d730580e1715f974fb18b6ba680f69dac1..85785bc0ec4b889da7689f632aba6c7c0c0fc8cb 100644 (file)
@@ -34,9 +34,7 @@ using System.Security.Permissions;
 
 namespace System.Security {
 
-#if NET_2_0
        [ComVisible (true)]
-#endif
        [Serializable]
        public sealed class NamedPermissionSet : PermissionSet {
 
@@ -124,7 +122,6 @@ namespace System.Security {
                        return se;
                }
 
-#if NET_2_0
                [ComVisible (false)]
                public override bool Equals (object obj)
                {
@@ -147,6 +144,5 @@ namespace System.Security {
                        // description is never part of the hash code
                        return hc;
                }
-#endif
        }
 }
index 5764ade5f043b8c89aae3739758e067f7fff5f11..6deddeb4f11522e7363a3cc51e7ef29a0a131a4e 100644 (file)
@@ -30,11 +30,7 @@ using System.Security.Permissions;
 
 namespace System.Security {
 
-#if NET_2_0
        internal static class PermissionBuilder {
-#else
-       internal class PermissionBuilder {
-#endif
                private static object[] psNone = new object [1] { PermissionState.None };
 
                // can be used to create an empty or an unrestricted permission from any valid type
@@ -89,11 +85,7 @@ namespace System.Security {
                        Type classType = Type.GetType (fullname);
                        if (classType == null) {
                                string msg = Locale.GetText ("Can't create an instance of permission class {0}.");
-#if NET_2_0
                                throw new TypeLoadException (String.Format (msg, fullname));
-#else
-                               throw new ArgumentException (String.Format (msg, fullname));
-#endif
                        }
                        IPermission p = Create (classType);
                        p.FromXml (se);
index 1ac01aefc570a1b0c17db5df6ffc48336567945d..2a9b3e40c444df354ced988184df249f27ce822a 100644 (file)
@@ -46,9 +46,7 @@ namespace System.Security {
        [Serializable]
        // Microsoft public key - i.e. only MS signed assembly can inherit from PermissionSet (1.x) or (2.0) FullTrust assemblies
        [StrongNameIdentityPermission (SecurityAction.InheritanceDemand, PublicKey="002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293")]
-#if NET_2_0
        [ComVisible (true)]
-#endif
        [MonoTODO ("CAS support is experimental (and unsupported).")]
        public class PermissionSet: ISecurityEncodable, ICollection, IEnumerable, IStackWalk, IDeserializationCallback {
 
@@ -86,11 +84,6 @@ namespace System.Security {
                                foreach (IPermission p in permSet.list)
                                        list.Add (p);
                        }
-#if !NET_2_0
-                       else {
-                               state = PermissionState.Unrestricted;
-                       }
-#endif
                }
 
                internal PermissionSet (string xml)
@@ -116,24 +109,15 @@ namespace System.Security {
 
                // methods
 
-#if NET_2_0
                public IPermission AddPermission (IPermission perm)
-#else
-               public virtual IPermission AddPermission (IPermission perm)
-#endif
                {
                        if ((perm == null) || _readOnly)
                                return perm;
 
                        // we don't add to an unrestricted permission set unless...
                        if (state == PermissionState.Unrestricted) {
-#if NET_2_0
                                // identity permissions can be unrestricted under 2.x
                                {
-#else
-                               // we're adding identity permission as they don't support unrestricted
-                               if (perm is IUnrestrictedPermission) {
-#endif
                                        // we return the union of the permission with unrestricted
                                        // which results in a permission of the same type initialized 
                                        // with PermissionState.Unrestricted
@@ -155,11 +139,7 @@ namespace System.Security {
 
                [MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
                [SecurityPermission (SecurityAction.Demand, Assertion = true)]
-#if NET_2_0
                public void Assert ()
-#else
-               public virtual void Assert ()
-#endif
                {
                        int count = this.Count;
 
@@ -208,11 +188,7 @@ namespace System.Security {
                        }
                }
 
-#if NET_2_0
                public void Demand ()
-#else
-               public virtual void Demand ()
-#endif
                {
                        // Note: SecurityEnabled only applies to CAS permissions
                        // so we're not checking for it (yet)
@@ -289,11 +265,7 @@ namespace System.Security {
                }
 
                [MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
-#if NET_2_0
                public void Deny ()
-#else
-               public virtual void Deny ()
-#endif
                {
                        if (!SecurityManager.SecurityEnabled)
                                return;
@@ -319,11 +291,9 @@ namespace System.Security {
 
                        if (CodeAccessPermission.IsUnrestricted (et)) {
                                state = PermissionState.Unrestricted;
-#if NET_2_0
                                // no need to continue for an unrestricted permission
                                // because identity permissions now "supports" unrestricted
                                return;
-#endif
                        } else {
                                state = PermissionState.None;
                        }
@@ -345,16 +315,11 @@ namespace System.Security {
                        }
                }
 
-#if NET_2_0
                public IEnumerator GetEnumerator ()
-#else
-               public virtual IEnumerator GetEnumerator ()
-#endif
                {
                        return list.GetEnumerator ();
                }
 
-#if NET_2_0
                public bool IsSubsetOf (PermissionSet target)
                {
                        // if target is empty we must be empty too
@@ -366,44 +331,29 @@ namespace System.Security {
                                return true;
                        if (this.IsUnrestricted ())
                                return false;
-#else
-               public virtual bool IsSubsetOf (PermissionSet target)
-               {
-#endif
+
                        if (this.IsUnrestricted () && ((target == null) || !target.IsUnrestricted ()))
                                return false;
 
                        // if each of our permission is (a) present and (b) a subset of target
                        foreach (IPermission p in list) {
-#if !NET_2_0
-                               if (target == null) {
-                                       if (!p.IsSubsetOf (null))
-                                               return false;
-                               } else
-#endif
-                               {
-                                       // non CAS permissions must be evaluated for unrestricted
-                                       Type t = p.GetType ();
-                                       IPermission i = null;
-                                       if (target.IsUnrestricted () && (p is CodeAccessPermission) && (p is IUnrestrictedPermission)) {
-                                               i = (IPermission) Activator.CreateInstance (t, psUnrestricted);
-                                       } else {
-                                               i = target.GetPermission (t);
-                                       }
-
-                                       if (!p.IsSubsetOf (i))
-                                               return false; // not a subset (condition b)
+                               // non CAS permissions must be evaluated for unrestricted
+                               Type t = p.GetType ();
+                               IPermission i = null;
+                               if (target.IsUnrestricted () && (p is CodeAccessPermission) && (p is IUnrestrictedPermission)) {
+                                       i = (IPermission) Activator.CreateInstance (t, psUnrestricted);
+                               } else {
+                                       i = target.GetPermission (t);
                                }
+                               
+                               if (!p.IsSubsetOf (i))
+                                       return false; // not a subset (condition b)
                        }
                        return true;
                }
 
                [MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
-#if NET_2_0
                public void PermitOnly ()
-#else
-               public virtual void PermitOnly ()
-#endif
                {
                        if (!SecurityManager.SecurityEnabled)
                                return;
@@ -484,11 +434,7 @@ namespace System.Security {
                                }
                                else if (outFormat.StartsWith ("XML")) {
                                        string msg = String.Format (Locale.GetText ("Can't convert from {0} to {1}"), inFormat, outFormat);
-#if NET_2_0
                                        throw new XmlSyntaxException (msg);
-#else
-                                       throw new ArgumentException (msg);
-#endif
                                }
                        }
                        else {
@@ -499,11 +445,7 @@ namespace System.Security {
                        throw new SerializationException (String.Format (Locale.GetText ("Unknown output format {0}."), outFormat));
                }
 
-#if NET_2_0
                public IPermission GetPermission (Type permClass)
-#else
-               public virtual IPermission GetPermission (Type permClass)
-#endif
                {
                        if ((permClass == null) || (list.Count == 0))
                                return null;
@@ -516,11 +458,7 @@ namespace System.Security {
                        return null;
                }
 
-#if NET_2_0
                public PermissionSet Intersect (PermissionSet other)
-#else
-               public virtual PermissionSet Intersect (PermissionSet other)
-#endif
                {
                        // no intersection possible
                        if ((other == null) || (other.IsEmpty ()) || (this.IsEmpty ()))
@@ -531,7 +469,6 @@ namespace System.Security {
                                state = PermissionState.Unrestricted;
 
                        PermissionSet interSet = null;
-#if NET_2_0
                        // much simpler with 2.0
                        if (state == PermissionState.Unrestricted) {
                                interSet = new PermissionSet (state);
@@ -543,19 +480,6 @@ namespace System.Security {
                                interSet = new PermissionSet (state);
                                InternalIntersect (interSet, this, other, false);
                        }
-#else
-                       interSet = new PermissionSet (state);
-                       if (state == PermissionState.Unrestricted) {
-                               InternalIntersect (interSet, this, other, true);
-                               InternalIntersect (interSet, other, this, true);
-                       } else if (this.IsUnrestricted ()) {
-                               InternalIntersect (interSet, this, other, true);
-                       } else if (other.IsUnrestricted ()) {
-                               InternalIntersect (interSet, other, this, true);
-                       } else {
-                               InternalIntersect (interSet, this, other, false);
-                       }
-#endif
                        return interSet;
                }
 
@@ -568,23 +492,15 @@ namespace System.Security {
                                        // add intersection for this type
                                        intersect.AddPermission (p.Intersect (i));
                                }
-#if NET_2_0
                                // unrestricted is possible for indentity permissions
                                else if (unrestricted) {
-#else
-                               else if (unrestricted && (p is IUnrestrictedPermission)) {
-#endif
                                        intersect.AddPermission (p);
                                }
                                // or reject!
                        }
                }
 
-#if NET_2_0
                public bool IsEmpty ()
-#else
-               public virtual bool IsEmpty ()
-#endif
                {
                        // note: Unrestricted isn't empty
                        if (state == PermissionState.Unrestricted)
@@ -600,20 +516,12 @@ namespace System.Security {
                        return true;
                }
 
-#if NET_2_0
                public bool IsUnrestricted ()
-#else
-               public virtual bool IsUnrestricted ()
-#endif
                {
                        return (state == PermissionState.Unrestricted);
                }
 
-#if NET_2_0
                public IPermission RemovePermission (Type permClass)
-#else
-               public virtual IPermission RemovePermission (Type permClass)
-#endif
                {
                        if ((permClass == null) || _readOnly)
                                return null;
@@ -627,25 +535,16 @@ namespace System.Security {
                        return null;
                }
 
-#if NET_2_0
                public IPermission SetPermission (IPermission perm)
-#else
-               public virtual IPermission SetPermission (IPermission perm)
-#endif
                {
                        if ((perm == null) || _readOnly)
                                return perm;
-#if NET_2_0
                        IUnrestrictedPermission u = (perm as IUnrestrictedPermission);
                        if (u == null) {
                                state = PermissionState.None;
                        } else {
                                state = u.IsUnrestricted () ? state : PermissionState.None;
                        }
-#else
-                       if (perm is IUnrestrictedPermission)
-                               state = PermissionState.None;
-#endif
                        RemovePermission (perm.GetType ());
                        list.Add (perm);
                        return perm;
@@ -671,35 +570,15 @@ namespace System.Security {
                        return se;
                }
 
-#if NET_2_0
                public PermissionSet Union (PermissionSet other)
-#else
-               public virtual PermissionSet Union (PermissionSet other)
-#endif
                {
                        if (other == null)
                                return this.Copy ();
 
                        PermissionSet copy = null;
                        if (this.IsUnrestricted () || other.IsUnrestricted ()) {
-#if NET_2_0
                                // there are no child elements in unrestricted permission sets
                                return new PermissionSet (PermissionState.Unrestricted);
-#else
-                               copy = this.Copy ();
-                               // so we keep the "right" type (e.g. NamedPermissionSet)
-                               copy.Clear ();
-                               copy.state = PermissionState.Unrestricted;
-                               // copy all permissions that do not implement IUnrestrictedPermission
-                               foreach (IPermission p in this.list) {
-                                       if (!(p is IUnrestrictedPermission))
-                                               copy.AddPermission (p);
-                               }
-                               foreach (IPermission p in other.list) {
-                                       if (!(p is IUnrestrictedPermission))
-                                               copy.AddPermission (p);
-                               }
-#endif
                        } else {
                                copy = this.Copy ();
                                // PermissionState.None -> copy all permissions
@@ -738,7 +617,6 @@ namespace System.Security {
                {
                }
 
-#if NET_2_0
                [ComVisible (false)]
                public override bool Equals (object obj)
                {
@@ -777,7 +655,6 @@ namespace System.Security {
                {
                        CodeAccessPermission.RevertAssert ();
                }
-#endif
 
                // internal
 
index 82cbb0b491476c14a94bb02f9a341965d012c149..c13c1efef77cffd8a1a2ba48bc5d61622b8ffef2 100644 (file)
@@ -26,8 +26,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 using System.Collections;
 using System.Runtime.InteropServices;
 using System.Security.Permissions;
@@ -217,4 +215,3 @@ namespace System.Security {
        }
 }
 
-#endif
index 749c6e0ea9c280e54b6f20b83eb831648a95c9b9..24f583ec06b4c9ce1989763bb7ace9f423ca6ea1 100644 (file)
@@ -32,9 +32,7 @@ using System.Runtime.InteropServices;
 namespace System.Security {
 
        [Serializable]
-#if NET_2_0
        [ComVisible (true)]
-#endif
        public enum PolicyLevelType {
                User = 0x0,
                Machine,
index 8ed4571475124e96f3f9fa649c0cb14fb1b1b635..ba39ce7d5da4c0a1d80e1f80db48c36c238db15a 100644 (file)
@@ -26,8 +26,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 using System.Globalization;
 using System.Reflection;
 using System.Runtime.CompilerServices;
@@ -304,5 +302,3 @@ namespace System.Security {
                }
        }
 }
-
-#endif
index e88c48f6fdcd412983c36500ad761fe06bc285b4..bfa36d7715eae2d1a5ddc6d540897074f0fda3bc 100644 (file)
@@ -33,11 +33,7 @@ using System.Threading;
 
 namespace System.Security {
 
-#if NET_2_0
        public sealed class SecurityContext {
-#else
-       internal sealed class SecurityContext {
-#endif
                private bool _capture;
                private IntPtr _winid;
                private CompressedStack _stack;
@@ -124,7 +120,7 @@ namespace System.Security {
                        sc.FlowSuppressed = false;
                        sc.WindowsIdentityFlowSuppressed = false;
                }
-#if NET_2_0
+
                // if you got the context then you can use it
                [SecurityPermission (SecurityAction.Assert, ControlPrincipal = true)]
                [SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)]
@@ -154,7 +150,7 @@ namespace System.Security {
                                        Thread.CurrentPrincipal = original;
                        }
                }
-#endif
+
                [SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)]
                static public AsyncFlowControl SuppressFlow ()
                {
index f6b872acf96c3f498933506779cddd1b9ffd140b..78264a66a64ab03855edb7dce470b4abb56a1996 100644 (file)
@@ -26,8 +26,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 using System;
 using System.Runtime.ConstrainedExecution;
 using System.Runtime.InteropServices;
@@ -76,5 +74,3 @@ namespace System.Security {
 #endif
        }
 }
-
-#endif
index 4586121b69369fadabb0c1c13c98f31b8418d143..cec5b73667402836553dc4a772b1e1973d64b96d 100644 (file)
@@ -41,7 +41,7 @@ namespace System.Security {
                }
        }
 
-#elif NET_2_0
+#else
 
        [MonoTODO ("Only supported by the runtime when CoreCLR is enabled")]
        [AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct |
index ed73027e135ba53d1920e940e92a02ead4bd31d9..ec3eb76657fba8e8f8cbfdd3635338df9ec45be9 100644 (file)
@@ -26,8 +26,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 namespace System.Security {
 
        public enum SecurityCriticalScope {
@@ -36,4 +34,3 @@ namespace System.Security {
        }
 }
 
-#endif
index 7fd209bd6b7aa0ce3444f55cf6364a9e8df7d12c..9ba34115463047338079e8c56c78cb7d49f2e8f8 100644 (file)
@@ -38,9 +38,7 @@ using Mono.Xml;
 
 namespace System.Security {
 
-#if NET_2_0
        [ComVisible (true)]
-#endif
        [Serializable]
        public sealed class SecurityElement 
        {
@@ -232,13 +230,11 @@ namespace System.Security {
                        return ((sa == null) ? null : sa.Value);
                }
 
-#if NET_2_0
                [ComVisible (false)]
                public SecurityElement Copy ()
                {
                        return new SecurityElement (this);
                }
-#endif
 
                public bool Equal (SecurityElement other)
                {
@@ -332,12 +328,7 @@ namespace System.Security {
                        return sb.ToString ();
                }
 
-#if NET_2_0
-               public
-#else
-               internal
-#endif
-               static SecurityElement FromString (string xml)
+               public static SecurityElement FromString (string xml)
                {
                        if (xml == null)
                                throw new ArgumentNullException ("xml");
@@ -419,24 +410,13 @@ namespace System.Security {
                
                private void ToXml (ref StringBuilder s, int level)
                {
-#if ! NET_2_0
-                       s.Append (' ', level * 3);
-#endif
                        s.Append ("<");
                        s.Append (tag);
                        
                        if (attributes != null) {
-#if NET_2_0
                                s.Append (" ");
-#endif
                                for (int i=0; i < attributes.Count; i++) {
                                        SecurityAttribute sa = (SecurityAttribute) attributes [i];
-#if ! NET_2_0
-                                       s.Append (" ");
-                                       // all other attributes must align with the first one
-                                       if (i != 0)
-                                               s.Append (' ', (level * 3) + tag.Length + 1);
-#endif
                                        s.Append (sa.Name)
                                         .Append ("=\"")
                                         .Append (Escape (sa.Value))
index 817bc4c2f2bf4cd2e3b5317cf7ff8e4e65a04423..5320a22c0006207f10cee34356af012fa73b149e 100644 (file)
@@ -40,9 +40,7 @@ using System.Text;
 namespace System.Security {
 
        [Serializable]
-#if NET_2_0
-       [ComVisible (true)]
-#endif
+       [ComVisible (true)]
        public class SecurityException : SystemException {
                // Fields
                string permissionState;
@@ -55,9 +53,6 @@ namespace System.Security {
                private MethodInfo _method;
                private Evidence _evidence;
 
-#if !NET_2_0
-       #pragma warning disable 169
-#endif
                private SecurityAction _action;
                private object _denyset;
                private object _permitset;
@@ -65,13 +60,8 @@ namespace System.Security {
                private string _url;
                private SecurityZone _zone;
                
-#if !NET_2_0
-       #pragma warning restore 169
-#endif 
-
                // Properties
 
-#if NET_2_0
                [ComVisible (false)]
                public SecurityAction Action {
                        get { return _action; }
@@ -116,26 +106,15 @@ namespace System.Security {
                        get { return _zone; }
                        set { _zone = value; }
                }
-#endif
 
-#if NET_2_0
                [ComVisible (false)]
-               public 
-#else
-               internal
-#endif
-               object Demanded {
+               public object Demanded {
                        [SecurityPermission (SecurityAction.Demand, ControlEvidence=true, ControlPolicy=true)]
                        get { return _demanded; }
                        set { _demanded = value; }
                }
 
-#if NET_2_0
-               public 
-#else
-               internal
-#endif
-               IPermission FirstPermissionThatFailed {
+               public IPermission FirstPermissionThatFailed {
                        [SecurityPermission (SecurityAction.Demand, ControlEvidence=true, ControlPolicy=true)]
                        get { return _firstperm; }
                        set { _firstperm = value; }
@@ -144,35 +123,26 @@ namespace System.Security {
                public string PermissionState {
                        [SecurityPermission (SecurityAction.Demand, ControlEvidence=true, ControlPolicy=true)]
                        get { return permissionState; }
-#if NET_2_0
                        set { permissionState = value; }
-#endif
                }
 
                public Type PermissionType {
                        get { return permissionType; }
-#if NET_2_0
                        set { permissionType = value; }
-#endif
                }
 
-#if NET_1_1
                public string GrantedSet {
                        [SecurityPermission (SecurityAction.Demand, ControlEvidence=true, ControlPolicy=true)]
                        get { return _granted; }
-#if NET_2_0
                        set { _granted = value; }
-#endif
                }
 
                public string RefusedSet {
                        [SecurityPermission (SecurityAction.Demand, ControlEvidence=true, ControlPolicy=true)]
                        get { return _refused; }
-#if NET_2_0
                        set { _refused = value; }
-#endif
                }
-#endif
+
                // Constructors
 
                public SecurityException ()
@@ -231,12 +201,7 @@ namespace System.Security {
                        _refused = refused.ToString ();
                }
 
-#if NET_2_0
-               public
-#else
-               internal
-#endif
-               SecurityException (string message, object deny, object permitOnly, MethodInfo method, 
+               public SecurityException (string message, object deny, object permitOnly, MethodInfo method, 
                        object demanded, IPermission permThatFailed)
                        : base (message)
                {
@@ -248,12 +213,7 @@ namespace System.Security {
                        _firstperm = permThatFailed;
                }
 
-#if NET_2_0
-               public
-#else
-               internal
-#endif
-               SecurityException (string message, AssemblyName assemblyName, PermissionSet grant, 
+               public SecurityException (string message, AssemblyName assemblyName, PermissionSet grant, 
                        PermissionSet refused, MethodInfo method, SecurityAction action, object demanded, 
                        IPermission permThatFailed, Evidence evidence)
                        : base (message)
index d08b1f32e743c5d4782c8c0d840c769250b4f7c6..7040a08128fe7b361fd958c0c49575fae96df782 100644 (file)
@@ -52,16 +52,8 @@ namespace System.Security {
                public RuntimeDeclSecurityEntry choice;
        }
 
-#if NET_2_0
        [ComVisible (true)]
        public static class SecurityManager {
-#else
-       public sealed class SecurityManager {
-
-               private SecurityManager ()
-               {
-               }
-#endif
                private static object _lockObject;
                private static ArrayList _hierarchy;
                private static IPermission _unmanagedCode;
@@ -86,9 +78,7 @@ namespace System.Security {
                        set;
                }
 
-#if NET_2_0
                [Obsolete ("The security manager cannot be turned off on MS runtime")]
-#endif
                extern public static bool SecurityEnabled {
                        [MethodImplAttribute (MethodImplOptions.InternalCall)]
                        get;
@@ -100,7 +90,6 @@ namespace System.Security {
 
                // methods
 
-#if NET_1_1
                // NOTE: This method doesn't show in the class library status page because
                // it cannot be "found" with the StrongNameIdentityPermission for ECMA key.
                // But it's there!
@@ -112,7 +101,6 @@ namespace System.Security {
                        zone = new ArrayList ();
                        origin = new ArrayList ();
                }
-#endif
 
                public static bool IsGranted (IPermission perm)
                {
@@ -126,23 +114,15 @@ namespace System.Security {
                        // - Not affected by overrides (like Assert, Deny and PermitOnly)
                        // - calls IsSubsetOf even for non CAS permissions
                        //   (i.e. it does call Demand so any code there won't be executed)
-#if NET_2_0
                        // with 2.0 identity permission are unrestrictable
                        return IsGranted (Assembly.GetCallingAssembly (), perm);
-#else
-                       if (perm is IUnrestrictedPermission)
-                               return IsGranted (Assembly.GetCallingAssembly (), perm);
-                       else
-                               return IsGrantedRestricted (Assembly.GetCallingAssembly (), perm);
-#endif
                }
 
-#if !NET_2_0
-               // only for permissions that do not implement IUnrestrictedPermission
-               internal static bool IsGrantedRestricted (Assembly a, IPermission perm)
+               // note: in 2.0 *all* permissions (including identity permissions) support unrestricted
+               internal static bool IsGranted (Assembly a, IPermission perm)
                {
-                       PermissionSet granted = a.GrantedPermissionSet;\r
-                       if (granted != null) {\r
+                       PermissionSet granted = a.GrantedPermissionSet;
+                       if ((granted != null) && !granted.IsUnrestricted ()) {
                                CodeAccessPermission grant = (CodeAccessPermission) granted.GetPermission (perm.GetType ());
                                if (!perm.IsSubsetOf (grant)) {
                                        return false;
@@ -150,35 +130,15 @@ namespace System.Security {
                        }
 
                        PermissionSet denied = a.DeniedPermissionSet;
-                       if (denied != null) {\r
+                       if ((denied != null) && !denied.IsEmpty ()) {
+                               if (denied.IsUnrestricted ())
+                                       return false;
                                CodeAccessPermission refuse = (CodeAccessPermission) a.DeniedPermissionSet.GetPermission (perm.GetType ());
                                if ((refuse != null) && perm.IsSubsetOf (refuse))
                                        return false;
                        }
                        return true;
                }
-#endif
-               // note: in 2.0 *all* permissions (including identity permissions) support unrestricted
-               internal static bool IsGranted (Assembly a, IPermission perm)
-               {
-                       PermissionSet granted = a.GrantedPermissionSet;\r
-                       if ((granted != null) && !granted.IsUnrestricted ()) {\r
-                               CodeAccessPermission grant = (CodeAccessPermission) granted.GetPermission (perm.GetType ());\r
-                               if (!perm.IsSubsetOf (grant)) {\r
-                                       return false;\r
-                               }\r
-                       }\r
-\r
-                       PermissionSet denied = a.DeniedPermissionSet;\r
-                       if ((denied != null) && !denied.IsEmpty ()) {\r
-                               if (denied.IsUnrestricted ())\r
-                                       return false;\r
-                               CodeAccessPermission refuse = (CodeAccessPermission) a.DeniedPermissionSet.GetPermission (perm.GetType ());\r
-                               if ((refuse != null) && perm.IsSubsetOf (refuse))\r
-                                       return false;\r
-                       }\r
-                       return true;\r
-               }
 
                internal static IPermission CheckPermissionSet (Assembly a, PermissionSet ps, bool noncas)
                {
@@ -188,18 +148,8 @@ namespace System.Security {
                        foreach (IPermission p in ps) {
                                // note: this may contains non CAS permissions
                                if ((!noncas) && (p is CodeAccessPermission)) {
-#if NET_2_0
                                        if (!IsGranted (a, p))
                                                return p;
-#else
-                                       if (p is IUnrestrictedPermission) {
-                                               if (!IsGranted (a, p))
-                                                       return p;
-                                       } else {
-                                               if (!IsGrantedRestricted (a, p))
-                                                       return p;
-                                       }
-#endif
                                } else {
                                        // but non-CAS will throw on failure...
                                        try {
@@ -222,13 +172,8 @@ namespace System.Security {
                        PermissionSet granted = ad.GrantedPermissionSet;
                        if (granted == null)
                                return null;
-#if NET_2_0
                        if (granted.IsUnrestricted ())
                                return null;
-#else
-                       if ((granted.Count == 0) && granted.IsUnrestricted ())
-                               return null;
-#endif
                        if (ps.IsUnrestricted ())
                                return new SecurityPermission (SecurityPermissionFlag.NoFlags);
 
@@ -318,7 +263,6 @@ namespace System.Security {
                        return ps;
                }
 
-#if NET_2_0
                [MonoTODO ("(2.0) more tests are needed")]
                public static PermissionSet ResolvePolicy (Evidence[] evidences)
                {
@@ -355,7 +299,6 @@ namespace System.Security {
                        ResolveIdentityPermissions (ps, evidence);
                        return ps;
                }
-#endif
 
                static private SecurityPermission _execution = new SecurityPermission (SecurityPermissionFlag.Execution);
 
@@ -488,11 +431,10 @@ namespace System.Security {
 
                internal static void ResolveIdentityPermissions (PermissionSet ps, Evidence evidence)
                {
-#if NET_2_0
                        // in 2.0 identity permissions can now be unrestricted
                        if (ps.IsUnrestricted ())
                                return;
-#endif
+
                        // Only host evidence are used for policy resolution
                        IEnumerator ee = evidence.GetHostEnumerator ();
                        while (ee.MoveNext ()) {
index e43cc69619c29ab94df4451cb6a7ea68eb81e6cd..0b641438a43102eb6bbfc4ae378ae7a1ecc3510e 100644 (file)
@@ -26,8 +26,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 namespace System.Security {
 
 #if !NET_2_1 || MONOTOUCH
@@ -42,4 +40,3 @@ namespace System.Security {
        }
 }
 
-#endif
index 88ceaeebf189d6b5706f0f5890cb75601461604c..812aa8087ab2b076526e3a070eaec03eae4f3dee 100644 (file)
@@ -26,8 +26,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 namespace System.Security {
 
        // available in FX2.0 with service pack 1, including the 2.0 shipped as part of FX3.5
@@ -49,5 +47,4 @@ namespace System.Security {
        }
 }
 
-#endif
 
index 47145b85314843996a51ef0ecc41bbaa36237460..f5190aece2763bfa0d09c69399bda4a5a3d98791 100644 (file)
@@ -26,8 +26,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 namespace System.Security {
 
 #if !NET_2_1 || MONOTOUCH
@@ -41,5 +39,3 @@ namespace System.Security {
                }
        }
 }
-
-#endif
index ba17e6db65d708bb2c2dfa9c2a4f6c2f79bc873e..a7af52e81f2ac660dc6410f25eacd1c26dfc8fb8 100644 (file)
@@ -26,8 +26,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 namespace System.Security {
 
        [AttributeUsage (AttributeTargets.All, AllowMultiple=false, Inherited=false)]
@@ -40,5 +38,3 @@ namespace System.Security {
                }
        }
 }
-
-#endif
index 55894d2b3841aaca1b2494f2b6e2e9c154fa71d0..8ca1ce620217644205472397aed470cf7fc7e072 100644 (file)
@@ -32,9 +32,7 @@ using System.Runtime.InteropServices;
 namespace System.Security {
 
        [Serializable]
-#if NET_2_0
        [ComVisible (true)]
-#endif
        public enum SecurityZone {
                MyComputer = 0x0,
                Intranet,
index 8de56a41811ed5ee1c71939c16de635833b00948..defe471f4173aa59afa72981a93e5b476d19e323 100644 (file)
@@ -31,15 +31,10 @@ using System.Runtime.InteropServices;
 
 namespace System.Security {
 
-#if NET_2_0
        [AttributeUsage (AttributeTargets.Class | AttributeTargets.Method | 
                AttributeTargets.Interface | AttributeTargets.Delegate, 
                AllowMultiple=true, Inherited=false)]
        [ComVisible (true)]
-#else
-       [AttributeUsage (AttributeTargets.Class | AttributeTargets.Method |
-                        AttributeTargets.Interface, AllowMultiple=true, Inherited=false)]
-#endif
        public sealed class SuppressUnmanagedCodeSecurityAttribute : Attribute {
        }
 }
index 915173322fc7f9710ab7a792da7ed418c69f5a07..6c130c8bde67761ce34b04ce5a4f17cec25b6671 100644 (file)
@@ -31,9 +31,7 @@ using System.Runtime.InteropServices;
 
 namespace System.Security {
 
-#if NET_2_0
        [ComVisible (true)]
-#endif
        [AttributeUsage (AttributeTargets.Module, AllowMultiple=true, Inherited=false)]
        public sealed class UnverifiableCodeAttribute : Attribute {
        }
index 5b986d61b1e7bb4833929a3d60f98b27f65a56af..4e527a65a0cf7a1f9e536ff14328132dc77f55ca 100644 (file)
@@ -34,9 +34,7 @@ using System.Runtime.Serialization;
 namespace System.Security {
 
        [Serializable]
-#if NET_2_0
        [ComVisible (true)]
-#endif
        public class VerificationException : SystemException {
        
                // Constructors
index e3a3845cd73dd3963652fadcf6337ab622628530..8bae8dde4b7cadc35cf8568bc91f5be726b34bba 100644 (file)
@@ -34,9 +34,7 @@ using System.Runtime.Serialization;
 namespace System.Security {
 
        [Serializable]
-#if NET_2_0
        [ComVisible (true)]
-#endif
        public sealed class XmlSyntaxException : SystemException {
 
                // Constructors