From 4baa1d2bc2c7d8bb4c7181b83eac3146c0681666 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Fri, 6 Nov 2009 21:25:38 +0000 Subject: [PATCH] More removal of old defines svn path=/trunk/mcs/; revision=145609 --- .../AllowPartiallyTrustedCallersAttribute.cs | 2 - .../System.Security/CodeAccessPermission.cs | 13 -- .../HostProtectionException.cs | 3 - .../System.Security/HostSecurityManager.cs | 4 - .../HostSecurityManagerFlags.cs | 4 - .../System.Security/IEvidenceFactory.cs | 2 - .../corlib/System.Security/IPermission.cs | 2 - .../System.Security/ISecurityEncodable.cs | 2 - .../ISecurityPolicyEncodable.cs | 2 - .../corlib/System.Security/IStackWalk.cs | 2 - .../System.Security/NamedPermissionSet.cs | 4 - .../System.Security/PermissionBuilder.cs | 8 - .../corlib/System.Security/PermissionSet.cs | 145 ++---------------- .../PermissionSetCollection.cs | 3 - .../corlib/System.Security/PolicyLevelType.cs | 2 - .../corlib/System.Security/SecureString.cs | 4 - .../corlib/System.Security/SecurityContext.cs | 8 +- .../SecurityContextSwitcher.cs | 4 - .../SecurityCriticalAttribute.cs | 2 +- .../System.Security/SecurityCriticalScope.cs | 3 - .../corlib/System.Security/SecurityElement.cs | 22 +-- .../System.Security/SecurityException.cs | 52 +------ .../corlib/System.Security/SecurityManager.cs | 74 +-------- .../SecuritySafeCriticalAttribute.cs | 3 - .../corlib/System.Security/SecurityState.cs | 3 - .../SecurityTransparentAttribute.cs | 4 - .../SecurityTreatAsSafeAttribute.cs | 4 - .../corlib/System.Security/SecurityZone.cs | 2 - .../SuppressUnmanagedCodeSecurityAttribute.cs | 5 - .../UnverifiableCodeAttribute.cs | 2 - .../System.Security/VerificationException.cs | 2 - .../System.Security/XmlSyntaxException.cs | 2 - 32 files changed, 29 insertions(+), 365 deletions(-) diff --git a/mcs/class/corlib/System.Security/AllowPartiallyTrustedCallersAttribute.cs b/mcs/class/corlib/System.Security/AllowPartiallyTrustedCallersAttribute.cs index f372bd7d57c..cbe0765a4c4 100644 --- a/mcs/class/corlib/System.Security/AllowPartiallyTrustedCallersAttribute.cs +++ b/mcs/class/corlib/System.Security/AllowPartiallyTrustedCallersAttribute.cs @@ -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 { diff --git a/mcs/class/corlib/System.Security/CodeAccessPermission.cs b/mcs/class/corlib/System.Security/CodeAccessPermission.cs index c97d080a587..d6fb5d8d9de 100644 --- a/mcs/class/corlib/System.Security/CodeAccessPermission.cs +++ b/mcs/class/corlib/System.Security/CodeAccessPermission.cs @@ -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); diff --git a/mcs/class/corlib/System.Security/HostProtectionException.cs b/mcs/class/corlib/System.Security/HostProtectionException.cs index 70d20535c69..8d828bc216e 100644 --- a/mcs/class/corlib/System.Security/HostProtectionException.cs +++ b/mcs/class/corlib/System.Security/HostProtectionException.cs @@ -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 diff --git a/mcs/class/corlib/System.Security/HostSecurityManager.cs b/mcs/class/corlib/System.Security/HostSecurityManager.cs index ecd099ec34a..8b6c9c8c50d 100644 --- a/mcs/class/corlib/System.Security/HostSecurityManager.cs +++ b/mcs/class/corlib/System.Security/HostSecurityManager.cs @@ -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 diff --git a/mcs/class/corlib/System.Security/HostSecurityManagerFlags.cs b/mcs/class/corlib/System.Security/HostSecurityManagerFlags.cs index 2da516f77d9..54e69440b50 100644 --- a/mcs/class/corlib/System.Security/HostSecurityManagerFlags.cs +++ b/mcs/class/corlib/System.Security/HostSecurityManagerFlags.cs @@ -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 diff --git a/mcs/class/corlib/System.Security/IEvidenceFactory.cs b/mcs/class/corlib/System.Security/IEvidenceFactory.cs index 0e988aa987d..b15cb9c5b4a 100644 --- a/mcs/class/corlib/System.Security/IEvidenceFactory.cs +++ b/mcs/class/corlib/System.Security/IEvidenceFactory.cs @@ -30,9 +30,7 @@ using System.Security.Policy; namespace System.Security { -#if NET_2_0 [ComVisible (true)] -#endif public interface IEvidenceFactory { Evidence Evidence { get; } } diff --git a/mcs/class/corlib/System.Security/IPermission.cs b/mcs/class/corlib/System.Security/IPermission.cs index 78750475dc2..4155b32463d 100644 --- a/mcs/class/corlib/System.Security/IPermission.cs +++ b/mcs/class/corlib/System.Security/IPermission.cs @@ -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 diff --git a/mcs/class/corlib/System.Security/ISecurityEncodable.cs b/mcs/class/corlib/System.Security/ISecurityEncodable.cs index 238524a159f..06fd6f94477 100644 --- a/mcs/class/corlib/System.Security/ISecurityEncodable.cs +++ b/mcs/class/corlib/System.Security/ISecurityEncodable.cs @@ -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); diff --git a/mcs/class/corlib/System.Security/ISecurityPolicyEncodable.cs b/mcs/class/corlib/System.Security/ISecurityPolicyEncodable.cs index 13582e8754c..d2085ef8ef6 100644 --- a/mcs/class/corlib/System.Security/ISecurityPolicyEncodable.cs +++ b/mcs/class/corlib/System.Security/ISecurityPolicyEncodable.cs @@ -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); diff --git a/mcs/class/corlib/System.Security/IStackWalk.cs b/mcs/class/corlib/System.Security/IStackWalk.cs index 38a7ecdd0d5..1195a0993b4 100644 --- a/mcs/class/corlib/System.Security/IStackWalk.cs +++ b/mcs/class/corlib/System.Security/IStackWalk.cs @@ -31,9 +31,7 @@ using System.Runtime.InteropServices; namespace System.Security { -#if NET_2_0 [ComVisible (true)] -#endif public interface IStackWalk { void Assert (); diff --git a/mcs/class/corlib/System.Security/NamedPermissionSet.cs b/mcs/class/corlib/System.Security/NamedPermissionSet.cs index 7c1ca4d7305..85785bc0ec4 100644 --- a/mcs/class/corlib/System.Security/NamedPermissionSet.cs +++ b/mcs/class/corlib/System.Security/NamedPermissionSet.cs @@ -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 } } diff --git a/mcs/class/corlib/System.Security/PermissionBuilder.cs b/mcs/class/corlib/System.Security/PermissionBuilder.cs index 5764ade5f04..6deddeb4f11 100644 --- a/mcs/class/corlib/System.Security/PermissionBuilder.cs +++ b/mcs/class/corlib/System.Security/PermissionBuilder.cs @@ -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); diff --git a/mcs/class/corlib/System.Security/PermissionSet.cs b/mcs/class/corlib/System.Security/PermissionSet.cs index 1ac01aefc57..2a9b3e40c44 100644 --- a/mcs/class/corlib/System.Security/PermissionSet.cs +++ b/mcs/class/corlib/System.Security/PermissionSet.cs @@ -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 diff --git a/mcs/class/corlib/System.Security/PermissionSetCollection.cs b/mcs/class/corlib/System.Security/PermissionSetCollection.cs index 82cbb0b4914..c13c1efef77 100644 --- a/mcs/class/corlib/System.Security/PermissionSetCollection.cs +++ b/mcs/class/corlib/System.Security/PermissionSetCollection.cs @@ -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 diff --git a/mcs/class/corlib/System.Security/PolicyLevelType.cs b/mcs/class/corlib/System.Security/PolicyLevelType.cs index 749c6e0ea9c..24f583ec06b 100644 --- a/mcs/class/corlib/System.Security/PolicyLevelType.cs +++ b/mcs/class/corlib/System.Security/PolicyLevelType.cs @@ -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, diff --git a/mcs/class/corlib/System.Security/SecureString.cs b/mcs/class/corlib/System.Security/SecureString.cs index 8ed45714751..ba39ce7d5da 100644 --- a/mcs/class/corlib/System.Security/SecureString.cs +++ b/mcs/class/corlib/System.Security/SecureString.cs @@ -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 diff --git a/mcs/class/corlib/System.Security/SecurityContext.cs b/mcs/class/corlib/System.Security/SecurityContext.cs index e88c48f6fdc..bfa36d7715e 100644 --- a/mcs/class/corlib/System.Security/SecurityContext.cs +++ b/mcs/class/corlib/System.Security/SecurityContext.cs @@ -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 () { diff --git a/mcs/class/corlib/System.Security/SecurityContextSwitcher.cs b/mcs/class/corlib/System.Security/SecurityContextSwitcher.cs index f6b872acf96..78264a66a64 100644 --- a/mcs/class/corlib/System.Security/SecurityContextSwitcher.cs +++ b/mcs/class/corlib/System.Security/SecurityContextSwitcher.cs @@ -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 diff --git a/mcs/class/corlib/System.Security/SecurityCriticalAttribute.cs b/mcs/class/corlib/System.Security/SecurityCriticalAttribute.cs index 4586121b693..cec5b736674 100644 --- a/mcs/class/corlib/System.Security/SecurityCriticalAttribute.cs +++ b/mcs/class/corlib/System.Security/SecurityCriticalAttribute.cs @@ -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 | diff --git a/mcs/class/corlib/System.Security/SecurityCriticalScope.cs b/mcs/class/corlib/System.Security/SecurityCriticalScope.cs index ed73027e135..ec3eb76657f 100644 --- a/mcs/class/corlib/System.Security/SecurityCriticalScope.cs +++ b/mcs/class/corlib/System.Security/SecurityCriticalScope.cs @@ -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 diff --git a/mcs/class/corlib/System.Security/SecurityElement.cs b/mcs/class/corlib/System.Security/SecurityElement.cs index 7fd209bd6b7..9ba34115463 100644 --- a/mcs/class/corlib/System.Security/SecurityElement.cs +++ b/mcs/class/corlib/System.Security/SecurityElement.cs @@ -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)) diff --git a/mcs/class/corlib/System.Security/SecurityException.cs b/mcs/class/corlib/System.Security/SecurityException.cs index 817bc4c2f2b..5320a22c000 100644 --- a/mcs/class/corlib/System.Security/SecurityException.cs +++ b/mcs/class/corlib/System.Security/SecurityException.cs @@ -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) diff --git a/mcs/class/corlib/System.Security/SecurityManager.cs b/mcs/class/corlib/System.Security/SecurityManager.cs index d08b1f32e74..7040a08128f 100644 --- a/mcs/class/corlib/System.Security/SecurityManager.cs +++ b/mcs/class/corlib/System.Security/SecurityManager.cs @@ -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; - if (granted != null) { + 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) { + 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; - if ((granted != null) && !granted.IsUnrestricted ()) { - CodeAccessPermission grant = (CodeAccessPermission) granted.GetPermission (perm.GetType ()); - if (!perm.IsSubsetOf (grant)) { - return false; - } - } - - PermissionSet denied = a.DeniedPermissionSet; - 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; - } 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 ()) { diff --git a/mcs/class/corlib/System.Security/SecuritySafeCriticalAttribute.cs b/mcs/class/corlib/System.Security/SecuritySafeCriticalAttribute.cs index e43cc69619c..0b641438a43 100644 --- a/mcs/class/corlib/System.Security/SecuritySafeCriticalAttribute.cs +++ b/mcs/class/corlib/System.Security/SecuritySafeCriticalAttribute.cs @@ -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 diff --git a/mcs/class/corlib/System.Security/SecurityState.cs b/mcs/class/corlib/System.Security/SecurityState.cs index 88ceaeebf18..812aa8087ab 100644 --- a/mcs/class/corlib/System.Security/SecurityState.cs +++ b/mcs/class/corlib/System.Security/SecurityState.cs @@ -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 diff --git a/mcs/class/corlib/System.Security/SecurityTransparentAttribute.cs b/mcs/class/corlib/System.Security/SecurityTransparentAttribute.cs index 47145b85314..f5190aece27 100644 --- a/mcs/class/corlib/System.Security/SecurityTransparentAttribute.cs +++ b/mcs/class/corlib/System.Security/SecurityTransparentAttribute.cs @@ -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 diff --git a/mcs/class/corlib/System.Security/SecurityTreatAsSafeAttribute.cs b/mcs/class/corlib/System.Security/SecurityTreatAsSafeAttribute.cs index ba17e6db65d..a7af52e81f2 100644 --- a/mcs/class/corlib/System.Security/SecurityTreatAsSafeAttribute.cs +++ b/mcs/class/corlib/System.Security/SecurityTreatAsSafeAttribute.cs @@ -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 diff --git a/mcs/class/corlib/System.Security/SecurityZone.cs b/mcs/class/corlib/System.Security/SecurityZone.cs index 55894d2b384..8ca1ce62021 100644 --- a/mcs/class/corlib/System.Security/SecurityZone.cs +++ b/mcs/class/corlib/System.Security/SecurityZone.cs @@ -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, diff --git a/mcs/class/corlib/System.Security/SuppressUnmanagedCodeSecurityAttribute.cs b/mcs/class/corlib/System.Security/SuppressUnmanagedCodeSecurityAttribute.cs index 8de56a41811..defe471f417 100644 --- a/mcs/class/corlib/System.Security/SuppressUnmanagedCodeSecurityAttribute.cs +++ b/mcs/class/corlib/System.Security/SuppressUnmanagedCodeSecurityAttribute.cs @@ -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 { } } diff --git a/mcs/class/corlib/System.Security/UnverifiableCodeAttribute.cs b/mcs/class/corlib/System.Security/UnverifiableCodeAttribute.cs index 915173322fc..6c130c8bde6 100644 --- a/mcs/class/corlib/System.Security/UnverifiableCodeAttribute.cs +++ b/mcs/class/corlib/System.Security/UnverifiableCodeAttribute.cs @@ -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 { } diff --git a/mcs/class/corlib/System.Security/VerificationException.cs b/mcs/class/corlib/System.Security/VerificationException.cs index 5b986d61b1e..4e527a65a0c 100644 --- a/mcs/class/corlib/System.Security/VerificationException.cs +++ b/mcs/class/corlib/System.Security/VerificationException.cs @@ -34,9 +34,7 @@ using System.Runtime.Serialization; namespace System.Security { [Serializable] -#if NET_2_0 [ComVisible (true)] -#endif public class VerificationException : SystemException { // Constructors diff --git a/mcs/class/corlib/System.Security/XmlSyntaxException.cs b/mcs/class/corlib/System.Security/XmlSyntaxException.cs index e3a3845cd73..8bae8dde4b7 100644 --- a/mcs/class/corlib/System.Security/XmlSyntaxException.cs +++ b/mcs/class/corlib/System.Security/XmlSyntaxException.cs @@ -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 -- 2.25.1