Browse Source

[bcl] Make mono cas opt-in features instead of opt-out for mobile profiles

Marek Safar 9 years ago
parent
commit
ed989a8e9e
65 changed files with 212 additions and 196 deletions
  1. 1 1
      mcs/build/profiles/basic.make
  2. 1 1
      mcs/build/profiles/build.make
  3. 0 1
      mcs/build/profiles/mobile.make
  4. 0 1
      mcs/build/profiles/mobile_static.make
  5. 0 1
      mcs/build/profiles/monodroid.make
  6. 0 1
      mcs/build/profiles/monotouch_runtime.make
  7. 1 1
      mcs/build/profiles/net_4_x.make
  8. 0 1
      mcs/build/profiles/xammac.make
  9. 6 6
      mcs/class/System.XML/Test/System.Xml/XmlSecureResolverTests.cs
  10. 1 1
      mcs/class/corlib/System.Reflection/MonoAssembly.cs
  11. 39 16
      mcs/class/corlib/System.Security/CodeAccessPermission.cs
  12. 0 2
      mcs/class/corlib/System.Security/PermissionSet.cs
  13. 1 1
      mcs/class/corlib/Test/System.Security/CodeAccessPermissionTest.cs
  14. 1 1
      mcs/class/corlib/Test/System.Threading/ExecutionContextCas.cs
  15. 4 4
      mcs/class/referencesource/System.Data.Linq/misc/SecurityUtils.cs
  16. 1 1
      mcs/class/referencesource/System.Data.SqlXml/System/Xml/Xsl/XsltOld/Compiler.cs
  17. 2 2
      mcs/class/referencesource/System.Data/System/Data/Common/AdapterUtil.cs
  18. 2 2
      mcs/class/referencesource/System.Data/System/Data/XMLSchema.cs
  19. 3 3
      mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/ClassDataContract.cs
  20. 1 1
      mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/Globals.cs
  21. 2 2
      mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerContext.cs
  22. 1 1
      mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerWriteContext.cs
  23. 12 12
      mcs/class/referencesource/System.ServiceModel.Internals/System/Runtime/PartialTrustHelpers.cs
  24. 10 10
      mcs/class/referencesource/System.Xml/System/Xml/XmlSecureResolver.cs
  25. 1 1
      mcs/class/referencesource/System.Xml/System/Xml/XmlSecureResolverAsync.cs
  26. 1 1
      mcs/class/referencesource/System.Xml/System/Xml/Xslt/XslTransform.cs
  27. 2 2
      mcs/class/referencesource/System/compmod/system/componentmodel/DebugReflectPropertyDescriptor.cs
  28. 1 1
      mcs/class/referencesource/System/compmod/system/componentmodel/DebugTypeDescriptor.cs
  29. 4 4
      mcs/class/referencesource/System/compmod/system/componentmodel/IntSecurity.cs
  30. 4 4
      mcs/class/referencesource/System/compmod/system/componentmodel/ReflectPropertyDescriptor.cs
  31. 4 4
      mcs/class/referencesource/System/compmod/system/componentmodel/ReflectTypeDescriptionProvider.cs
  32. 6 6
      mcs/class/referencesource/System/compmod/system/componentmodel/TypeDescriptor.cs
  33. 1 1
      mcs/class/referencesource/System/compmod/system/componentmodel/Win32Exception.cs
  34. 6 6
      mcs/class/referencesource/System/compmod/system/componentmodel/design/DesigntimeLicenseContext.cs
  35. 2 2
      mcs/class/referencesource/System/compmod/system/diagnostics/Trace.cs
  36. 2 2
      mcs/class/referencesource/System/compmod/system/diagnostics/TraceEventCache.cs
  37. 1 1
      mcs/class/referencesource/System/compmod/system/diagnostics/TraceInternal.cs
  38. 2 2
      mcs/class/referencesource/System/misc/SecurityUtils.cs
  39. 4 4
      mcs/class/referencesource/System/net/System/Net/AuthenticationManager.cs
  40. 2 2
      mcs/class/referencesource/System/net/System/Net/CredentialCache.cs
  41. 2 2
      mcs/class/referencesource/System/net/System/Net/Internal.cs
  42. 1 1
      mcs/class/referencesource/System/net/System/Net/NetworkInformation/NetworkInterface.cs
  43. 2 2
      mcs/class/referencesource/System/net/System/Net/ServicePoint.cs
  44. 5 5
      mcs/class/referencesource/System/net/System/Net/WebRequest.cs
  45. 6 6
      mcs/class/referencesource/System/net/System/Net/_SecureChannel.cs
  46. 9 9
      mcs/class/referencesource/System/net/System/Net/_SpnDictionary.cs
  47. 2 2
      mcs/class/referencesource/System/net/System/Net/webclient.cs
  48. 2 2
      mcs/class/referencesource/System/net/System/Net/webproxy.cs
  49. 1 1
      mcs/class/referencesource/System/net/System/UriScheme.cs
  50. 4 4
      mcs/class/referencesource/System/regex/system/text/regularexpressions/Regex.cs
  51. 9 9
      mcs/class/referencesource/System/regex/system/text/regularexpressions/RegexCompiler.cs
  52. 1 1
      mcs/class/referencesource/System/regex/system/text/regularexpressions/RegexGroup.cs
  53. 1 1
      mcs/class/referencesource/System/regex/system/text/regularexpressions/RegexMatch.cs
  54. 1 1
      mcs/class/referencesource/System/regex/system/text/regularexpressions/compiledregexrunnerfactory.cs
  55. 1 1
      mcs/class/referencesource/System/sys/system/collections/concurrent/ConcurrentBag.cs
  56. 1 1
      mcs/class/referencesource/mscorlib/system/exception.cs
  57. 4 4
      mcs/class/referencesource/mscorlib/system/io/__error.cs
  58. 3 3
      mcs/class/referencesource/mscorlib/system/io/fileinfo.cs
  59. 6 6
      mcs/class/referencesource/mscorlib/system/io/filesysteminfo.cs
  60. 2 2
      mcs/class/referencesource/mscorlib/system/io/unmanagedmemorystream.cs
  61. 2 2
      mcs/class/referencesource/mscorlib/system/resources/filebasedresourcegroveler.cs
  62. 3 3
      mcs/class/referencesource/mscorlib/system/resources/resourcewriter.cs
  63. 2 2
      mcs/class/referencesource/mscorlib/system/rttype.cs
  64. 2 2
      mcs/class/referencesource/mscorlib/system/runtime/interopservices/runtimeenvironment.cs
  65. 8 8
      mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryobjectreader.cs

+ 1 - 1
mcs/build/profiles/basic.make

@@ -18,7 +18,7 @@ endif
 
 MCS = $(with_mono_path) $(INTERNAL_GMCS)
 
-PROFILE_MCS_FLAGS = -d:NET_4_0 -d:NET_4_5 -d:MONO -d:BOOTSTRAP_BASIC -nowarn:1699 -d:DISABLE_CAS_USE -lib:$(topdir)/class/lib/$(PROFILE)
+PROFILE_MCS_FLAGS = -d:NET_4_0 -d:NET_4_5 -d:MONO -d:BOOTSTRAP_BASIC -nowarn:1699 -lib:$(topdir)/class/lib/$(PROFILE)
 NO_SIGN_ASSEMBLY = yes
 NO_TEST = yes
 NO_INSTALL = yes

+ 1 - 1
mcs/build/profiles/build.make

@@ -13,7 +13,7 @@ profile-check:
 	@:
 
 DEFAULT_REFERENCES = -r:$(topdir)/class/lib/$(PROFILE)/mscorlib.dll
-PROFILE_MCS_FLAGS = -d:NET_4_0 -d:NET_4_5 -d:MONO -d:DISABLE_CAS_USE -nowarn:1699 -nostdlib $(DEFAULT_REFERENCES)
+PROFILE_MCS_FLAGS = -d:NET_4_0 -d:NET_4_5 -d:MONO -nowarn:1699 -nostdlib $(DEFAULT_REFERENCES)
 
 NO_SIGN_ASSEMBLY = yes
 NO_TEST = yes

+ 0 - 1
mcs/build/profiles/mobile.make

@@ -23,7 +23,6 @@ PROFILE_MCS_FLAGS = \
 	-d:NET_4_0 \
 	-d:NET_4_5 \
 	-d:MONO \
-	-d:DISABLE_CAS_USE \
 	-nowarn:1699 \
 	-nostdlib \
 	$(DEFAULT_REFERENCES) \

+ 0 - 1
mcs/build/profiles/mobile_static.make

@@ -21,7 +21,6 @@ PROFILE_MCS_FLAGS = \
 	-d:NET_4_0 \
 	-d:NET_4_5 \
 	-d:MONO \
-	-d:DISABLE_CAS_USE \
 	-d:MOBILE,MOBILE_STATIC,MOBILE_LEGACY \
 	-d:FULL_AOT_RUNTIME \
 	-d:DISABLE_REMOTING \

+ 0 - 1
mcs/build/profiles/monodroid.make

@@ -21,7 +21,6 @@ PROFILE_MCS_FLAGS = \
 	-d:NET_4_0 \
 	-d:NET_4_5 \
 	-d:MONO \
-	-d:DISABLE_CAS_USE \
 	-d:MOBILE,MOBILE_LEGACY \
 	-d:MOBILE_DYNAMIC \
 	-d:MONODROID \

+ 0 - 1
mcs/build/profiles/monotouch_runtime.make

@@ -23,7 +23,6 @@ PROFILE_MCS_FLAGS = \
 	-d:NET_4_5 \
 	-d:MOBILE,MOBILE_LEGACY \
 	-d:MONO \
-	-d:DISABLE_CAS_USE \
 	-d:MONOTOUCH \
 	-d:DISABLE_REMOTING \
 	-d:DISABLE_COM \

+ 1 - 1
mcs/build/profiles/net_4_x.make

@@ -11,7 +11,7 @@ profile-check:
 	@:
 
 DEFAULT_REFERENCES = -r:$(topdir)/class/lib/$(PROFILE)/mscorlib.dll
-PROFILE_MCS_FLAGS = -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:DISABLE_CAS_USE  -nowarn:1699 -nostdlib $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
+PROFILE_MCS_FLAGS = -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO  -nowarn:1699 -nostdlib $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
 
 FRAMEWORK_VERSION = 4.5
 XBUILD_VERSION = 4.0

+ 0 - 1
mcs/build/profiles/xammac.make

@@ -19,7 +19,6 @@ PROFILE_MCS_FLAGS = \
 	-d:NET_4_0 \
 	-d:NET_4_5 \
 	-d:MONO \
-	-d:DISABLE_CAS_USE  \
 	-d:MOBILE \
 	-d:MOBILE_DYNAMIC \
 	-d:XAMMAC \

+ 6 - 6
mcs/class/System.XML/Test/System.Xml/XmlSecureResolverTests.cs

@@ -51,17 +51,17 @@ namespace MonoTests.System.Xml
 		public void CreateEvidenceForUrl_Basic ()
 		{
 			Evidence e = XmlSecureResolver.CreateEvidenceForUrl (null);
-#if DISABLE_CAS_USE
-			Assert.IsNull (e);
-#else
+#if FEATURE_MONO_CAS
 			Assert.AreEqual (0, e.Count, "null");
+#else
+			Assert.IsNull (e);
 #endif
 
 			e = XmlSecureResolver.CreateEvidenceForUrl (String.Empty);
-#if DISABLE_CAS_USE
-			Assert.IsNull (e);
-#else
+#if FEATURE_MONO_CAS
 			Assert.AreEqual (0, e.Count, "String.Empty");
+#else
+			Assert.IsNull (e);
 #endif
 		}
 

+ 1 - 1
mcs/class/corlib/System.Reflection/MonoAssembly.cs

@@ -129,7 +129,7 @@ namespace System.Reflection {
 
                 if (!suppressSecurityChecks)
                 {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
 #pragma warning disable 618
                     new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
 #pragma warning restore 618

+ 39 - 16
mcs/class/corlib/System.Security/CodeAccessPermission.cs

@@ -52,8 +52,8 @@ namespace System.Security {
 		{
 		}
 
-#if MOBILE && DISABLE_CAS_USE
-		[Obsolete ("CAS support is removed by linker", true)]
+#if MOBILE
+		[Conditional ("FEATURE_MONO_CAS")]
 #else
 		[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
 #endif
@@ -64,8 +64,8 @@ namespace System.Security {
 
 		public abstract IPermission Copy ();
 
-#if MOBILE && DISABLE_CAS_USE
-		[Obsolete ("CAS support is removed by linker", true)]
+#if MOBILE
+		[Conditional ("FEATURE_MONO_CAS")]
 #endif
 		public void Demand ()
 		{
@@ -77,8 +77,8 @@ namespace System.Security {
 			new PermissionSet (this).CasOnlyDemand (3);
 		}
 
-#if MOBILE && DISABLE_CAS_USE
-		[Obsolete ("CAS support is removed by linker", true)]
+#if MOBILE
+		[Conditional ("FEATURE_MONO_CAS")]
 #else
 		[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
 #endif
@@ -125,8 +125,8 @@ namespace System.Security {
 			return null;
 		}
 
-#if MOBILE && DISABLE_CAS_USE
-		[Obsolete ("CAS support is removed by linker", true)]
+#if MOBILE
+		[Conditional ("FEATURE_MONO_CAS")]
 #else
 		[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
 #endif
@@ -135,8 +135,8 @@ namespace System.Security {
 			new PermissionSet (this).PermitOnly ();
 		}
 
-#if MOBILE && DISABLE_CAS_USE
-		[Obsolete ("CAS support is removed by linker", true)]
+#if MOBILE
+		[Conditional ("FEATURE_MONO_CAS")]
 #else
 		[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
 #endif
@@ -147,8 +147,8 @@ namespace System.Security {
 			throw new NotImplementedException ();
 		}
 
-#if MOBILE && DISABLE_CAS_USE
-		[Obsolete ("CAS support is removed by linker", true)]
+#if MOBILE
+		[Conditional ("FEATURE_MONO_CAS")]
 #else
 		[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
 #endif
@@ -159,8 +159,8 @@ namespace System.Security {
 			throw new NotImplementedException ();
 		}
 
-#if MOBILE && DISABLE_CAS_USE
-		[Obsolete ("CAS support is removed by linker", true)]
+#if MOBILE
+		[Conditional ("FEATURE_MONO_CAS")]
 #else
 		[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
 #endif
@@ -171,8 +171,8 @@ namespace System.Security {
 			throw new NotImplementedException ();
 		}
 
-#if MOBILE && DISABLE_CAS_USE
-		[Obsolete ("CAS support is removed by linker", true)]
+#if MOBILE
+		[Conditional ("FEATURE_MONO_CAS")]
 #else
 		[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
 #endif
@@ -264,5 +264,28 @@ namespace System.Security {
 			msg = String.Format (msg, target.GetType (), expected);
 			throw new ArgumentException (msg, "target");
 		}
+
+#if MOBILE
+		// Workaround for CS0629
+		void IStackWalk.Assert ()
+		{
+		}
+
+		void IStackWalk.Deny ()
+		{
+		}
+
+		void IStackWalk.PermitOnly ()
+		{
+		}
+
+		void IStackWalk.Demand ()
+		{
+		}
+
+		void IPermission.Demand ()
+		{
+		}
+#endif
 	}
 }

+ 0 - 2
mcs/class/corlib/System.Security/PermissionSet.cs

@@ -625,9 +625,7 @@ namespace System.Security {
 		// FIXME what's it doing here? There's probably a reason this was added here.
 		static public void RevertAssert ()
 		{
-#if !DISABLE_CAS_USE
 			CodeAccessPermission.RevertAssert ();
-#endif
 		}
 
 		// internal

+ 1 - 1
mcs/class/corlib/Test/System.Security/CodeAccessPermissionTest.cs

@@ -7,7 +7,7 @@
 // (C) 2004 Motus Technologies Inc. (http://www.motus.com)
 //
 
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
 
 using NUnit.Framework;
 using System;

+ 1 - 1
mcs/class/corlib/Test/System.Threading/ExecutionContextCas.cs

@@ -25,7 +25,7 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
 
 using System;
 using System.Security;

+ 4 - 4
mcs/class/referencesource/System.Data.Linq/misc/SecurityUtils.cs

@@ -37,7 +37,7 @@ namespace System.Windows.Forms
     /// </devdoc>
     internal static class SecurityUtils {
 
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
         private static volatile ReflectionPermission memberAccessPermission = null;
         private static volatile ReflectionPermission restrictedMemberAccessPermission = null;
 
@@ -62,7 +62,7 @@ namespace System.Windows.Forms
 #endif
 
         private static void DemandReflectionAccess(Type type) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             try {
                 MemberAccessPermission.Demand();
             }
@@ -74,7 +74,7 @@ namespace System.Windows.Forms
 
         [SecuritySafeCritical]
         private static void DemandGrantSet(Assembly assembly) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             PermissionSet targetGrantSet = assembly.PermissionSet;
             targetGrantSet.AddPermission(RestrictedMemberAccessPermission);
             targetGrantSet.Demand();
@@ -82,7 +82,7 @@ namespace System.Windows.Forms
         }
 
         private static bool HasReflectionPermission(Type type) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             try {
                 DemandReflectionAccess(type);
                 return true;

+ 1 - 1
mcs/class/referencesource/System.Data.SqlXml/System/Xml/Xsl/XsltOld/Compiler.cs

@@ -164,7 +164,7 @@ namespace System.Xml.Xsl.XsltOld {
         // The World of Compile
         //
         internal void Compile(NavigatorInput input, XmlResolver xmlResolver, Evidence evidence) {
-#if DISABLE_CAS_USE
+#if !FEATURE_MONO_CAS
             evidence = null;
 #endif
             Debug.Assert(input != null);

+ 2 - 2
mcs/class/referencesource/System.Data/System/Data/Common/AdapterUtil.cs

@@ -2125,7 +2125,7 @@ namespace System.Data.Common {
         [ResourceExposure(ResourceScope.Machine)]
         [ResourceConsumption(ResourceScope.Machine)]
         static internal Stream GetFileStream(string filename) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             (new FileIOPermission(FileIOPermissionAccess.Read, filename)).Assert();
             try {
                 return new FileStream(filename,FileMode.Open,FileAccess.Read,FileShare.Read);
@@ -2141,7 +2141,7 @@ namespace System.Data.Common {
         [ResourceExposure(ResourceScope.Machine)]
         [ResourceConsumption(ResourceScope.Machine)]
         static internal FileVersionInfo GetVersionInfo(string filename) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             (new FileIOPermission(FileIOPermissionAccess.Read, filename)).Assert(); // MDAC 62038
             try {
                 return FileVersionInfo.GetVersionInfo(filename); // MDAC 60411

+ 2 - 2
mcs/class/referencesource/System.Data/System/Data/XMLSchema.cs

@@ -22,7 +22,7 @@ namespace System.Data {
     internal class XMLSchema {
 
         internal static TypeConverter GetConverter(Type type) { 
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             HostProtectionAttribute protAttrib = new HostProtectionAttribute();
             protAttrib.SharedState = true;
             CodeAccessPermission permission = (CodeAccessPermission)protAttrib.CreatePermission();
@@ -32,7 +32,7 @@ namespace System.Data {
                 return TypeDescriptor.GetConverter(type);
             }
             finally {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 CodeAccessPermission.RevertAssert(); 
 #endif
             }

+ 3 - 3
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/ClassDataContract.cs

@@ -580,9 +580,7 @@ namespace System.Runtime.Serialization
         internal bool RequiresMemberAccessForWrite(SecurityException securityException)
         {
 
-#if DISABLE_CAS_USE
-            return true;
-#else
+#if FEATURE_MONO_CAS
             EnsureMethodsImported();
 
             if (!IsTypeVisible(UnderlyingType))
@@ -662,6 +660,8 @@ namespace System.Runtime.Serialization
             }
 
             return false;
+#else
+            return true;
 #endif
         }
 #endif

+ 1 - 1
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/Globals.cs

@@ -1105,7 +1105,7 @@ namespace System.Runtime.Serialization
             }
         }
 
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
         [Fx.Tag.SecurityNote(Critical = "Holds instance of SecurityPermission that we will Demand for SerializationFormatter."
             + " Should not be modified to something else.")]
         [SecurityCritical]

+ 2 - 2
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerContext.cs

@@ -89,7 +89,7 @@ namespace System.Runtime.Serialization
         [SecuritySafeCritical]
         public void DemandSerializationFormatterPermission()
         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             if (!demandedSerializationFormatterPermission)
             {
                 Globals.SerializationFormatterPermission.Demand();
@@ -103,7 +103,7 @@ namespace System.Runtime.Serialization
         [SecuritySafeCritical]
         public void DemandMemberAccessPermission()
         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             if (!demandedMemberAccessPermission)
             {
                 Globals.MemberAccessPermission.Demand();

+ 1 - 1
mcs/class/referencesource/System.Runtime.Serialization/System/Runtime/Serialization/XmlObjectSerializerWriteContext.cs

@@ -494,7 +494,7 @@ namespace System.Runtime.Serialization
         [MethodImpl(MethodImplOptions.NoInlining)]
         internal void GetObjectData(ISerializable obj, SerializationInfo serInfo, StreamingContext context)
         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             // Demand the serialization formatter permission every time
             Globals.SerializationFormatterPermission.Demand();
 #endif

+ 12 - 12
mcs/class/referencesource/System.ServiceModel.Internals/System/Runtime/PartialTrustHelpers.cs

@@ -36,9 +36,7 @@ namespace System.Runtime
         [SecurityCritical]
         internal static bool IsInFullTrust()
         {
-#if DISABLE_CAS_USE
-            return true;
-#else
+#if FEATURE_MONO_CAS
             if (!SecurityManager.CurrentThreadRequiresSecurityContextCapture())
             {
                 return true;
@@ -53,6 +51,8 @@ namespace System.Runtime
             {
                 return false;
             }
+#else
+            return true;
 #endif
         }
 #if FEATURE_COMPRESSEDSTACK
@@ -114,11 +114,11 @@ namespace System.Runtime
         [SecurityCritical]
         internal static bool CheckAppDomainPermissions(PermissionSet permissions)
         {
-#if DISABLE_CAS_USE
-            return true;
-#else
+#if FEATURE_MONO_CAS
             return AppDomain.CurrentDomain.IsHomogenous &&
                    permissions.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet);
+#else
+            return true;
 #endif
         }
 
@@ -126,12 +126,12 @@ namespace System.Runtime
         [SecurityCritical]
         internal static bool HasEtwPermissions()
         {
-#if DISABLE_CAS_USE
-            return true;
-#else
+#if FEATURE_MONO_CAS
             //Currently unrestricted permissions are required to create Etw provider. 
             PermissionSet permissions = new PermissionSet(PermissionState.Unrestricted);
             return CheckAppDomainPermissions(permissions);
+#else
+            return true;
 #endif
         }
 
@@ -142,9 +142,7 @@ namespace System.Runtime
             [SecuritySafeCritical]
             get
             {
-#if DISABLE_CAS_USE
-                return true;
-#else
+#if FEATURE_MONO_CAS
                 if (!checkedForFullTrust)
                 {
                     inFullTrust = AppDomain.CurrentDomain.IsFullyTrusted;
@@ -152,6 +150,8 @@ namespace System.Runtime
                 }
 
                 return inFullTrust;
+#else
+                return true;
 #endif
             }
         }

+ 10 - 10
mcs/class/referencesource/System.Xml/System/Xml/XmlSecureResolver.cs

@@ -15,23 +15,23 @@ namespace System.Xml {
     [PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
     public partial class XmlSecureResolver : XmlResolver {
         XmlResolver resolver;
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
         PermissionSet permissionSet;
 #endif
 
-#if DISABLE_CAS_USE
-        public XmlSecureResolver(XmlResolver resolver, string securityUrl) : this(resolver, (PermissionSet) null) {}
-
-        public XmlSecureResolver(XmlResolver resolver, Evidence evidence) : this(resolver, (PermissionSet) null) {}
-#else
+#if FEATURE_MONO_CAS
         public XmlSecureResolver(XmlResolver resolver, string securityUrl) : this(resolver, CreateEvidenceForUrl(securityUrl)) {}
 
         public XmlSecureResolver(XmlResolver resolver, Evidence evidence) : this(resolver, SecurityManager.GetStandardSandbox(evidence)) {}
+#else
+        public XmlSecureResolver(XmlResolver resolver, string securityUrl) : this(resolver, (PermissionSet) null) {}
+
+        public XmlSecureResolver(XmlResolver resolver, Evidence evidence) : this(resolver, (PermissionSet) null) {}
 #endif
 
         public XmlSecureResolver(XmlResolver resolver, PermissionSet permissionSet) {
             this.resolver = resolver;
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             this.permissionSet = permissionSet;
 #endif
         }
@@ -41,7 +41,7 @@ namespace System.Xml {
         }
 
         public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             permissionSet.PermitOnly();
 #endif
             return resolver.GetEntity(absoluteUri, role, ofObjectToReturn);
@@ -54,7 +54,7 @@ namespace System.Xml {
         }
 
         public static Evidence CreateEvidenceForUrl(string securityUrl) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             Evidence evidence = new Evidence();
             if (securityUrl != null && securityUrl.Length > 0) {
                 evidence.AddHostEvidence(new Url(securityUrl));
@@ -79,7 +79,7 @@ namespace System.Xml {
 #endif
         }
 
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
         [Serializable]
         private class UncDirectory : EvidenceBase, IIdentityPermissionFactory {
             private string uncDir;

+ 1 - 1
mcs/class/referencesource/System.Xml/System/Xml/XmlSecureResolverAsync.cs

@@ -7,7 +7,7 @@ namespace System.Xml {
     [PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
     public partial class XmlSecureResolver : XmlResolver {
         public override Task<object> GetEntityAsync(Uri absoluteUri, string role, Type ofObjectToReturn) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             permissionSet.PermitOnly();
 #endif
             return resolver.GetEntityAsync(absoluteUri, role, ofObjectToReturn);

+ 1 - 1
mcs/class/referencesource/System.Xml/System/Xml/Xslt/XslTransform.cs

@@ -116,7 +116,7 @@ namespace System.Xml.Xsl {
             if (stylesheet == null) {
                 throw new ArgumentNullException("stylesheet");
             }
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             if (evidence == null) {
                 evidence = new Evidence();
             }

+ 2 - 2
mcs/class/referencesource/System/compmod/system/componentmodel/DebugReflectPropertyDescriptor.cs

@@ -380,7 +380,7 @@ namespace System.ComponentModel {
                     else {
                         args = new Type[] {receiverType};
                     }
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                     IntSecurity.FullReflection.Assert();
 #endif
                     try {
@@ -456,7 +456,7 @@ namespace System.ComponentModel {
                     else {
                         args = new Type[] {receiverType};
                     }
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                     IntSecurity.FullReflection.Assert();
 #endif
                     try {

+ 1 - 1
mcs/class/referencesource/System/compmod/system/componentmodel/DebugTypeDescriptor.cs

@@ -1163,7 +1163,7 @@ namespace System.ComponentModel {
             ///      a single object to be re-used for more than one type. 
             /// </devdoc> 
             private object CreateInstance(Type type) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 if ((!(type.IsPublic || type.IsNestedPublic)) && (type.Assembly == typeof(DebugTypeDescriptor).Assembly)) {
                     IntSecurity.FullReflection.Demand();
                 }

+ 4 - 4
mcs/class/referencesource/System/compmod/system/componentmodel/IntSecurity.cs

@@ -11,15 +11,13 @@ namespace System.ComponentModel {
 
     [HostProtection(SharedState = true)]
     internal static class IntSecurity {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
         public static readonly CodeAccessPermission UnmanagedCode = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
         public static readonly CodeAccessPermission FullReflection = new ReflectionPermission(PermissionState.Unrestricted);
 #endif
 
         public static string UnsafeGetFullPath(string fileName) {
-#if DISABLE_CAS_USE
-			return System.IO.Path.GetFullPath(fileName);
-#else
+#if FEATURE_MONO_CAS
             string full = fileName;
 
             FileIOPermission fiop = new FileIOPermission(PermissionState.None);
@@ -32,6 +30,8 @@ namespace System.ComponentModel {
                 CodeAccessPermission.RevertAssert();
             }
             return full;
+#else
+            return System.IO.Path.GetFullPath(fileName);
 #endif
         }
     }

+ 4 - 4
mcs/class/referencesource/System/compmod/system/componentmodel/ReflectPropertyDescriptor.cs

@@ -417,12 +417,12 @@ namespace System.ComponentModel {
                     else {
                         args = new Type[] {receiverType};
                     }
-#if !DISABLE_CAS_USE                    
+#if FEATURE_MONO_CAS
                     IntSecurity.FullReflection.Assert();
                     try {
 #endif
                         resetMethod = FindMethod(componentClass, "Reset" + Name, args, typeof(void), /* publicOnly= */ false);
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                     }
                     finally {
                         CodeAccessPermission.RevertAssert();
@@ -524,13 +524,13 @@ namespace System.ComponentModel {
                         args = new Type[] {receiverType};
                     }
                     
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                     IntSecurity.FullReflection.Assert();
                     try {
 #endif
                         shouldSerializeMethod = FindMethod(componentClass, "ShouldSerialize" + Name,
                                                          args, typeof(Boolean), /* publicOnly= */ false);
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                     }
                     finally {
                         CodeAccessPermission.RevertAssert();

+ 4 - 4
mcs/class/referencesource/System/compmod/system/componentmodel/ReflectTypeDescriptionProvider.cs

@@ -1635,12 +1635,12 @@ namespace System.ComponentModel {
                         Type converterType = GetTypeFromName(instanceAttr.ConverterTypeName);
                         if (converterType != null && typeof(TypeConverter).IsAssignableFrom(converterType)) 
                         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                             try {
                                 IntSecurity.FullReflection.Assert();
 #endif
                                 return (TypeConverter)ReflectTypeDescriptionProvider.CreateInstance(converterType, _type);
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                             } finally {
                                 CodeAccessPermission.RevertAssert();
                             }
@@ -1665,12 +1665,12 @@ namespace System.ComponentModel {
                         Type converterType = GetTypeFromName(typeAttr.ConverterTypeName);
                         if (converterType != null && typeof(TypeConverter).IsAssignableFrom(converterType)) 
                         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                             try {
                                 IntSecurity.FullReflection.Assert();
 #endif
                                 _converter = (TypeConverter)ReflectTypeDescriptionProvider.CreateInstance(converterType, _type);
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                             } finally {
                                 CodeAccessPermission.RevertAssert();
                             }

+ 6 - 6
mcs/class/referencesource/System/compmod/system/componentmodel/TypeDescriptor.cs

@@ -365,7 +365,7 @@ namespace System.ComponentModel
             {
                 throw new ArgumentNullException("type");
             }
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             PermissionSet typeDescriptorPermission = new PermissionSet(PermissionState.None);
             typeDescriptorPermission.AddPermission(new TypeDescriptorPermission(TypeDescriptorPermissionFlags.RestrictedRegistrationAccess));
 
@@ -401,7 +401,7 @@ namespace System.ComponentModel
             {
                 throw new ArgumentNullException("instance");
             }
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             Type type = instance.GetType();
 
             PermissionSet typeDescriptorPermission = new PermissionSet(PermissionState.None);
@@ -475,12 +475,12 @@ namespace System.ComponentModel
                     // sense that they provide a public API while not necessarily being public themselves. As such,
                     // we need to allow instantiation of internal TypeDescriptionProviders. See the thread attached
                     // to VSWhidbey #500522 for a more detailed discussion.
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                     IntSecurity.FullReflection.Assert();
                     try {
 #endif
                         prov = (TypeDescriptionProvider)Activator.CreateInstance(providerType);
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                     }
                     finally {
                         CodeAccessPermission.RevertAssert();
@@ -3244,7 +3244,7 @@ namespace System.ComponentModel
             {
                 throw new ArgumentNullException("type");
             }
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             PermissionSet typeDescriptorPermission = new PermissionSet(PermissionState.None);
             typeDescriptorPermission.AddPermission(new TypeDescriptorPermission(TypeDescriptorPermissionFlags.RestrictedRegistrationAccess));
 
@@ -3279,7 +3279,7 @@ namespace System.ComponentModel
             {
                 throw new ArgumentNullException("instance");
             }
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             Type type = instance.GetType();
 
             PermissionSet typeDescriptorPermission = new PermissionSet(PermissionState.None);

+ 1 - 1
mcs/class/referencesource/System/compmod/system/componentmodel/Win32Exception.cs

@@ -75,7 +75,7 @@ namespace System.ComponentModel {
         }
 
         protected Win32Exception(SerializationInfo info, StreamingContext context) : base (info, context) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             IntSecurity.UnmanagedCode.Demand();
 #endif
             nativeErrorCode = info.GetInt32("NativeErrorCode");

+ 6 - 6
mcs/class/referencesource/System/compmod/system/componentmodel/design/DesigntimeLicenseContext.cs

@@ -93,7 +93,7 @@ namespace System.ComponentModel.Design {
                     Debug.WriteLineIf(RuntimeLicenseContextSwitch.TraceVerbose,"rawfile: " + rawFile);
                     string codeBase;
                     
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                     // FileIOPermission is required for ApplicationBase in URL-hosted domains
                     FileIOPermission perm = new FileIOPermission(PermissionState.Unrestricted);
                     perm.Assert();
@@ -133,7 +133,7 @@ namespace System.ComponentModel.Design {
                             // file://fullpath/foo.exe
                             //
                             string fileName;
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                             FileIOPermission perm = new FileIOPermission(PermissionState.Unrestricted);
                             perm.Assert();
                             try
@@ -166,7 +166,7 @@ namespace System.ComponentModel.Design {
                     else if(!resourceAssembly.IsDynamic) { // EscapedCodeBase won't be supported by emitted assemblies anyway
                         Debug.WriteLineIf(RuntimeLicenseContextSwitch.TraceVerbose,"resourceAssembly is not null");
                         string fileName;
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                         FileIOPermission perm = new FileIOPermission(PermissionState.Unrestricted);
                         perm.Assert();
 #endif
@@ -176,7 +176,7 @@ namespace System.ComponentModel.Design {
                         }
                         finally
                         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                             CodeAccessPermission.RevertAssert();
 #endif
                         }
@@ -258,7 +258,7 @@ namespace System.ComponentModel.Design {
 
         static Stream OpenRead(Uri resourceUri) {
             Stream result = null;
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             PermissionSet perms = new PermissionSet(PermissionState.Unrestricted);
 
             perms.Assert();
@@ -271,7 +271,7 @@ namespace System.ComponentModel.Design {
             catch (Exception e) {
                 Debug.Fail(e.ToString());
             }
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             finally {
                 CodeAccessPermission.RevertAssert();
             }

+ 2 - 2
mcs/class/referencesource/System/compmod/system/diagnostics/Trace.cs

@@ -30,7 +30,7 @@ namespace System.Diagnostics {
         public static TraceListenerCollection Listeners {
             [HostProtection(SharedState=true)]
             get {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 // Do a full damand
                 new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
 #endif
@@ -113,7 +113,7 @@ namespace System.Diagnostics {
         /// </devdoc>
         [System.Diagnostics.Conditional("TRACE")]
         public static void Close() {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             // Do a full damand
             new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
  #endif

+ 2 - 2
mcs/class/referencesource/System/compmod/system/diagnostics/TraceEventCache.cs

@@ -30,7 +30,7 @@ namespace System.Diagnostics {
             get {
                 if (stackTrace == null)
                     stackTrace = Environment.StackTrace;
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 else
                     new EnvironmentPermission(PermissionState.Unrestricted).Demand();
 #endif
@@ -77,7 +77,7 @@ namespace System.Diagnostics {
         [ResourceExposure(ResourceScope.None)]
         [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
         private static void InitProcessInfo() {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             // Demand unmanaged code permission
             new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
 #endif

+ 1 - 1
mcs/class/referencesource/System/compmod/system/diagnostics/TraceInternal.cs

@@ -62,7 +62,7 @@ namespace System.Diagnostics {
         internal static string AppName {
             get {
                 if (appName == null) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                     new EnvironmentPermission(EnvironmentPermissionAccess.Read, "Path").Assert();
 #endif
                     appName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);

+ 2 - 2
mcs/class/referencesource/System/misc/SecurityUtils.cs

@@ -60,7 +60,7 @@ namespace System.Windows.Forms
         }
 
         private static void DemandReflectionAccess(Type type) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             try {
                 MemberAccessPermission.Demand();
             }
@@ -72,7 +72,7 @@ namespace System.Windows.Forms
 
         [SecuritySafeCritical]
         private static void DemandGrantSet(Assembly assembly) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             PermissionSet targetGrantSet = assembly.PermissionSet;
             targetGrantSet.AddPermission(RestrictedMemberAccessPermission);
             targetGrantSet.Demand();

+ 4 - 4
mcs/class/referencesource/System/net/System/Net/AuthenticationManager.cs

@@ -139,7 +139,7 @@ namespace System.Net {
 
             set 
             {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 ExceptionHelper.ControlPolicyPermission.Demand();
 #endif
                 Instance.CredentialPolicy = value;
@@ -205,7 +205,7 @@ namespace System.Net {
         /// </devdoc>
         public static void Register(IAuthenticationModule authenticationModule) 
         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             ExceptionHelper.UnmanagedPermission.Demand();
 #endif
             Instance.Register(authenticationModule);
@@ -216,7 +216,7 @@ namespace System.Net {
         /// </devdoc>
         public static void Unregister(IAuthenticationModule authenticationModule) 
         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             ExceptionHelper.UnmanagedPermission.Demand();
 #endif
             Instance.Unregister(authenticationModule);
@@ -227,7 +227,7 @@ namespace System.Net {
         /// </devdoc>
         public static void Unregister(string authenticationScheme) 
         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             ExceptionHelper.UnmanagedPermission.Demand();
 #endif
             Instance.Unregister(authenticationScheme);

+ 2 - 2
mcs/class/referencesource/System/net/System/Net/CredentialCache.cs

@@ -302,7 +302,7 @@ namespace System.Net {
             get {
                 //This check will not allow to use local user credentials at will.
                 //Hence the username will not be exposed to the network
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 new EnvironmentPermission(EnvironmentPermissionAccess.Read, "USERNAME").Demand();
 #endif
                 return SystemNetworkCredential.defaultCredential;
@@ -313,7 +313,7 @@ namespace System.Net {
             get {
                 //This check will not allow to use local user credentials at will.
                 //Hence the username will not be exposed to the network
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 new EnvironmentPermission(EnvironmentPermissionAccess.Read, "USERNAME").Demand();
 #endif
                 return SystemNetworkCredential.defaultCredential;

+ 2 - 2
mcs/class/referencesource/System/net/System/Net/Internal.cs

@@ -143,7 +143,7 @@ namespace System.Net {
 
         private static void DemandCallback(object state)
         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             ((CodeAccessPermission) state).Demand();
 #endif
         }
@@ -966,7 +966,7 @@ namespace System.Net {
 
     internal static class ExceptionHelper
     {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
         internal static readonly KeyContainerPermission KeyContainerPermissionOpen = new KeyContainerPermission(KeyContainerPermissionFlags.Open);
         internal static readonly WebPermission WebPermissionUnrestricted = new WebPermission(NetworkAccess.Connect);
         internal static readonly SecurityPermission UnmanagedPermission = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);

+ 1 - 1
mcs/class/referencesource/System/net/System/Net/NetworkInformation/NetworkInterface.cs

@@ -8,7 +8,7 @@ namespace System.Net.NetworkInformation
     {
         /// Returns objects that describe the network interfaces on the local computer.
         public static NetworkInterface[] GetAllNetworkInterfaces(){
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             (new NetworkInformationPermission(NetworkInformationAccess.Read)).Demand();
 #endif
             return SystemNetworkInterface.GetNetworkInterfaces();

+ 2 - 2
mcs/class/referencesource/System/net/System/Net/ServicePoint.cs

@@ -93,7 +93,7 @@ namespace System.Net {
                 return m_BindIPEndPointDelegate;
             }
             set {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 ExceptionHelper.InfrastructurePermission.Demand();
 #endif
                 m_BindIPEndPointDelegate = value;
@@ -460,7 +460,7 @@ namespace System.Net {
                     throw new NotSupportedException(SR.GetString(SR.net_servicePointAddressNotSupportedInHostMode));
                 }
 
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 // Don't let low-trust apps discover the proxy information.
                 if (m_ProxyServicePoint)
                 {

+ 5 - 5
mcs/class/referencesource/System/net/System/Net/WebRequest.cs

@@ -365,7 +365,7 @@ namespace System.Net {
                 throw new ArgumentNullException("creator");
             }
 
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
 
@@ -622,7 +622,7 @@ namespace System.Net {
                 return RequestCacheManager.GetBinding(string.Empty).Policy;
             }
             set {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 // This is a replacement of RequestCachePermission demand since we are not including the latest in the product.
                 ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
@@ -1108,7 +1108,7 @@ namespace System.Net {
         {
             get
             {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
                 return InternalDefaultWebProxy;
@@ -1116,7 +1116,7 @@ namespace System.Net {
 
             set
             {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
                 InternalDefaultWebProxy = value;
@@ -1128,7 +1128,7 @@ namespace System.Net {
         //
         public static IWebProxy GetSystemWebProxy()
         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
             return InternalGetSystemWebProxy();

+ 6 - 6
mcs/class/referencesource/System/net/System/Net/_SecureChannel.cs

@@ -381,7 +381,7 @@ namespace System.Net.Security {
                 // demand the same permissions, then we should remove our
                 // demand here.
                 //
-                #if !DISABLE_CAS_USE
+                #if FEATURE_MONO_CAS
                 ExceptionHelper.KeyContainerPermissionOpen.Demand(); 
                 #endif
                 
@@ -437,7 +437,7 @@ namespace System.Net.Security {
                             // For v 1.1 compat We want to ensure the store is opened under the **process** acount.
                             //
                             try {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                                 using (WindowsIdentity.Impersonate(IntPtr.Zero))
 #endif
                                 {
@@ -583,7 +583,7 @@ namespace System.Net.Security {
         //          Note: We call a user certificate selection delegate under permission
         //          assert but the signature of the delegate is unique so it's safe
         //
-        #if !DISABLE_CAS_USE
+        #if FEATURE_MONO_CAS
         [StorePermission(SecurityAction.Assert, Unrestricted=true)]
         #endif
         private bool AcquireClientCredentials(ref byte[] thumbPrint)
@@ -826,7 +826,7 @@ namespace System.Net.Security {
         //          Note: We call a user certificate selection delegate under permission
         //          assert but the signature of the delegate is unique so it's safe
         //
-        #if !DISABLE_CAS_USE
+        #if FEATURE_MONO_CAS
         [StorePermission(SecurityAction.Assert, Unrestricted=true)]
         #endif
         private bool AcquireServerCredentials(ref byte[] thumbPrint)
@@ -906,7 +906,7 @@ namespace System.Net.Security {
                 //
                 // For v 1.1 compat We want to ensure the credential are accessed under >>process<< acount.
                 //
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 using (WindowsIdentity.Impersonate(IntPtr.Zero))
 #endif
                 {
@@ -1285,7 +1285,7 @@ namespace System.Net.Security {
         //SECURITY: The scenario is allowed in semitrust StorePermission is asserted for Chain.Build
         //          A user callback has unique signature so it is safe to call it under permisison assert.
         //
-        #if !DISABLE_CAS_USE
+        #if FEATURE_MONO_CAS
         [StorePermission(SecurityAction.Assert, Unrestricted=true)]
         #endif
         internal bool VerifyRemoteCertificate(RemoteCertValidationCallback remoteCertValidationCallback)

+ 9 - 9
mcs/class/referencesource/System/net/System/Net/_SpnDictionary.cs

@@ -43,7 +43,7 @@ namespace System.Net {
         //
         public override int Count {
             get {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
                 return m_SyncTable.Count;
@@ -108,7 +108,7 @@ namespace System.Net {
         //
         public override ICollection Keys {
             get {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
                 return m_SyncTable.Keys;
@@ -118,7 +118,7 @@ namespace System.Net {
         public override object SyncRoot {
             [HostProtection(Synchronization=true)]
             get {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
                 return m_SyncTable;
@@ -127,7 +127,7 @@ namespace System.Net {
         //
         public override ICollection Values {
             get {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
                 if (m_ValuesWrapper == null)
@@ -144,7 +144,7 @@ namespace System.Net {
         }
         //
         public override void Clear() {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
             m_SyncTable.Clear();
@@ -156,7 +156,7 @@ namespace System.Net {
         }
         //
         public override bool ContainsValue(string value) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
             foreach (SpnToken spnToken in m_SyncTable.Values)
@@ -169,7 +169,7 @@ namespace System.Net {
 
         // We have to unwrap the SpnKey and just expose the Spn
         public override void CopyTo(Array array, int index) {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
             CheckCopyToArguments(array, index, Count);
@@ -183,7 +183,7 @@ namespace System.Net {
         }
         //
         public override IEnumerator GetEnumerator() {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
 
@@ -211,7 +211,7 @@ namespace System.Net {
             try {
                 Uri uri = new Uri(key);
                 key = uri.GetParts(UriComponents.Scheme | UriComponents.Host | UriComponents.Port | UriComponents.Path, UriFormat.SafeUnescaped);
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 new WebPermission(NetworkAccess.Connect, new Uri(key)).Demand();
 #endif
             }

+ 2 - 2
mcs/class/referencesource/System/net/System/Net/webclient.cs

@@ -238,7 +238,7 @@ namespace System.Net {
         /// </devdoc>
         public IWebProxy Proxy {
             get {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
                 if (!m_ProxySet) {
@@ -248,7 +248,7 @@ namespace System.Net {
                 }
             }
             set {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
                 m_Proxy = value;

+ 2 - 2
mcs/class/referencesource/System/net/System/Net/webproxy.cs

@@ -414,7 +414,7 @@ namespace System.Net {
         /// </devdoc>
         [Obsolete("This method has been deprecated. Please use the proxy selected for you by default. http://go.microsoft.com/fwlink/?linkid=14202")]
         public static WebProxy GetDefaultProxy() {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
             return new WebProxy(true);
@@ -437,7 +437,7 @@ namespace System.Net {
             if (useRegistry) {
                 // just make the proxy advanced, don't populate with any settings
                 // note - this will happen in the context of the user performing the deserialization (their proxy settings get read)
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 ExceptionHelper.WebPermissionUnrestricted.Demand();
 #endif
                 UnsafeUpdateFromRegistry();

+ 1 - 1
mcs/class/referencesource/System/net/System/UriScheme.cs

@@ -166,7 +166,7 @@ namespace System {
         //
         public static void Register(UriParser uriParser, string schemeName, int defaultPort)
         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             ExceptionHelper.InfrastructurePermission.Demand();
 #endif
             if (uriParser == null)

+ 4 - 4
mcs/class/referencesource/System/regex/system/text/regularexpressions/Regex.cs

@@ -405,7 +405,7 @@ namespace System.Text.RegularExpressions {
         * This method is internal virtual so the jit does not inline it.
         */
         [
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             HostProtection(MayLeakOnAbort=true),
 #endif
             MethodImplAttribute(MethodImplOptions.NoInlining)
@@ -1195,7 +1195,7 @@ namespace System.Text.RegularExpressions {
 #if !(SILVERLIGHT || FULL_AOT_RUNTIME)
         /// <devdoc>
         /// </devdoc>
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
         [HostProtection(MayLeakOnAbort=true)]
 #endif
         [ResourceExposure(ResourceScope.Machine)] // The AssemblyName is interesting.
@@ -1208,7 +1208,7 @@ namespace System.Text.RegularExpressions {
 
         /// <devdoc>
         /// </devdoc>
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
         [HostProtection(MayLeakOnAbort=true)]
 #endif
         [ResourceExposure(ResourceScope.Machine)] // The AssemblyName is interesting.
@@ -1218,7 +1218,7 @@ namespace System.Text.RegularExpressions {
             CompileToAssemblyInternal(regexinfos, assemblyname, attributes, null);
         }
 
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
         [HostProtection(MayLeakOnAbort=true)]
 #endif
         [ResourceExposure(ResourceScope.Machine)]

+ 9 - 9
mcs/class/referencesource/System/regex/system/text/regularexpressions/RegexCompiler.cs

@@ -131,7 +131,7 @@ namespace System.Text.RegularExpressions {
             // <SECREVIEW> Regex only generates string manipulation, so this is ok.
             // </SECREVIEW>      
 
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             new ReflectionPermission(PermissionState.Unrestricted).Assert();
 #endif
             try {
@@ -172,7 +172,7 @@ namespace System.Text.RegularExpressions {
 #endif
             }
             finally {
-#if !DISABLE_CAS_USE 
+#if FEATURE_MONO_CAS 
                 CodeAccessPermission.RevertAssert();
 #endif
             }
@@ -197,14 +197,14 @@ namespace System.Text.RegularExpressions {
 
             // <SECREVIEW> Regex only generates string manipulation, so this is ok.
             // </SECREVIEW>         
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             new ReflectionPermission(PermissionState.Unrestricted).Assert();
 #endif
             try {
                 factory = c.FactoryInstanceFromCode(code, options);
             }
             finally {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 CodeAccessPermission.RevertAssert();
 #endif
             }
@@ -239,7 +239,7 @@ namespace System.Text.RegularExpressions {
         
                 Type factory;
         
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 new ReflectionPermission(PermissionState.Unrestricted).Assert();
 #endif
                 try {
@@ -247,7 +247,7 @@ namespace System.Text.RegularExpressions {
                     c.GenerateRegexType(pattern, options, fullname, regexes[i].IsPublic, code, tree, factory, mTimeout);
                 }
                 finally {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                     CodeAccessPermission.RevertAssert();
 #endif
                 }
@@ -3049,7 +3049,7 @@ namespace System.Text.RegularExpressions {
             // SECREVIEW : Regex only generates string manipulation, so this is
             //           : ok.
             //
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             new ReflectionPermission(PermissionState.Unrestricted).Assert();
 #endif
             try {
@@ -3061,7 +3061,7 @@ namespace System.Text.RegularExpressions {
                 CustomAttributeBuilder transparencyAttribute = new CustomAttributeBuilder(transparencyCtor, new object[0]);
                 assemblyAttributes.Add(transparencyAttribute);
 
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 ConstructorInfo securityRulesCtor = typeof(SecurityRulesAttribute).GetConstructor(new Type[] { typeof(SecurityRuleSet) });
                 CustomAttributeBuilder securityRulesAttribute =
                     new CustomAttributeBuilder(securityRulesCtor, new object[] { SecurityRuleSet.Level2 });
@@ -3087,7 +3087,7 @@ namespace System.Text.RegularExpressions {
                 }
             }
             finally {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 CodeAccessPermission.RevertAssert();
 #endif
             }

+ 1 - 1
mcs/class/referencesource/System/regex/system/text/regularexpressions/RegexGroup.cs

@@ -77,7 +77,7 @@ namespace System.Text.RegularExpressions {
         ///       multiple threads.</para>
         /// </devdoc>
 #if !SILVERLIGHT
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
         [HostProtection(Synchronization=true)]
 #endif
         static public Group Synchronized(Group inner) {

+ 1 - 1
mcs/class/referencesource/System/regex/system/text/regularexpressions/RegexMatch.cs

@@ -201,7 +201,7 @@ namespace System.Text.RegularExpressions {
         /// </devdoc>
 
 #if !SILVERLIGHT
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
         [HostProtection(Synchronization=true)]
 #endif
         static public Match Synchronized(Match inner) {

+ 1 - 1
mcs/class/referencesource/System/regex/system/text/regularexpressions/compiledregexrunnerfactory.cs

@@ -28,7 +28,7 @@ namespace System.Text.RegularExpressions {
         protected internal override RegexRunner CreateInstance() {
             CompiledRegexRunner runner = new CompiledRegexRunner();
 
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             new ReflectionPermission(PermissionState.Unrestricted).Assert();
 #endif
             runner.SetDelegates((NoParamDelegate)       goMethod.CreateDelegate(typeof(NoParamDelegate)),

+ 1 - 1
mcs/class/referencesource/System/sys/system/collections/concurrent/ConcurrentBag.cs

@@ -52,7 +52,7 @@ namespace System.Collections.Concurrent
     [ComVisible(false)]
     [DebuggerTypeProxy(typeof(SystemThreadingCollection_IProducerConsumerCollectionDebugView<>))]
     [DebuggerDisplay("Count = {Count}")]
-#if !(FEATURE_NETCORE || DISABLE_CAS_USE)
+#if !FEATURE_NETCORE
     [HostProtection(Synchronization = true, ExternalThreading = true)]
 #endif
     public class ConcurrentBag<T> : IProducerConsumerCollection<T>, IReadOnlyCollection<T>

+ 1 - 1
mcs/class/referencesource/mscorlib/system/exception.cs

@@ -989,7 +989,7 @@ namespace System {
         [System.Security.SecurityCritical]  // auto-generated
         internal virtual String InternalToString()
         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             try 
             {
 #pragma warning disable 618

+ 4 - 4
mcs/class/referencesource/mscorlib/system/io/__error.cs

@@ -96,9 +96,7 @@ namespace System.IO {
             if (!isFullyQualified && !isInvalidPath)
                 return path;
 
-#if DISABLE_CAS_USE
-            bool safeToReturn = !isInvalidPath;
-#else
+#if FEATURE_MONO_CAS
             bool safeToReturn = false;
             try {
                 if (!isInvalidPath) {
@@ -119,7 +117,9 @@ namespace System.IO {
                 // from Security.Util.StringExpressionSet.CanonicalizePath when ':' is found in the path
                 // beyond string index position 1.  
             }
-#endif // DISABLE_CAS_USE
+#else
+            bool safeToReturn = !isInvalidPath;
+#endif // FEATURE_MONO_CAS
             if (!safeToReturn) {
                 if (Path.IsDirectorySeparator(path[path.Length - 1]))
                     path = Environment.GetResourceString("IO.IO_NoPermissionToDirectoryName");

+ 3 - 3
mcs/class/referencesource/mscorlib/system/io/fileinfo.cs

@@ -130,7 +130,7 @@ namespace System.IO {
         [System.Security.SecurityCritical]  // auto-generated
         private FileInfo(SerializationInfo info, StreamingContext context) : base(info, context)
         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
 #if !FEATURE_CORECLR
             new FileIOPermission(FileIOPermissionAccess.Read, new String[] { FullPath }, false, false).Demand();
 #endif
@@ -187,7 +187,7 @@ namespace System.IO {
                 String directoryName = Path.GetDirectoryName(FullPath);
                 if (directoryName != null)
                 {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
 #if FEATURE_CORECLR
                     FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, DisplayPath, FullPath);
                     state.EnsureState();
@@ -338,7 +338,7 @@ namespace System.IO {
         [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
         public override void Delete()
         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
 #if FEATURE_CORECLR
             FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Write, DisplayPath, FullPath);
             state.EnsureState();

+ 6 - 6
mcs/class/referencesource/mscorlib/system/io/filesysteminfo.cs

@@ -18,7 +18,7 @@
 using System;
 using System.Collections;
 using System.Security;
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
 using System.Security.Permissions;
 #endif
 using Microsoft.Win32;
@@ -30,7 +30,7 @@ using System.Diagnostics.Contracts;
 
 namespace System.IO {
     [Serializable]
-#if !FEATURE_CORECLR && !DISABLE_CAS_USE
+#if !FEATURE_CORECLR && FEATURE_MONO_CAS
     [FileIOPermissionAttribute(SecurityAction.InheritanceDemand,Unrestricted=true)]
 #endif
     [ComVisible(true)]
@@ -102,7 +102,7 @@ namespace System.IO {
                     demandDir = Directory.GetDemandDir(FullPath, true);
                 else
                     demandDir = FullPath;
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
 #if FEATURE_CORECLR
                 FileSecurityState sourceState = new FileSecurityState(FileSecurityStateAccess.PathDiscovery, String.Empty, demandDir);
                 sourceState.EnsureState();
@@ -124,7 +124,7 @@ namespace System.IO {
                     demandDir = Directory.GetDemandDir(FullPath, true);
                 else
                     demandDir = FullPath;
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
 #if !FEATURE_CORECLR
                 new FileIOPermission(FileIOPermissionAccess.PathDiscovery, demandDir).Demand();
 #endif
@@ -351,7 +351,7 @@ namespace System.IO {
             [System.Security.SecuritySafeCritical]
             #endif
             set {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
 #if !FEATURE_CORECLR
                 new FileIOPermission(FileIOPermissionAccess.Write, FullPath).Demand();
 #endif
@@ -384,7 +384,7 @@ namespace System.IO {
         [ComVisible(false)]
         public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
         {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
 #if !FEATURE_CORECLR
             new FileIOPermission(FileIOPermissionAccess.PathDiscovery, FullPath).Demand();
 #endif

+ 2 - 2
mcs/class/referencesource/mscorlib/system/io/unmanagedmemorystream.cs

@@ -163,7 +163,7 @@ namespace System.IO {
             if (_isOpen) {
                 throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CalledTwice"));
             }
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             if (!skipSecurityCheck) {
 #pragma warning disable 618
                 new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
@@ -244,7 +244,7 @@ namespace System.IO {
             if (_isOpen)
                 throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CalledTwice"));
 
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             if (!skipSecurityCheck)
 #pragma warning disable 618
                 new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();

+ 2 - 2
mcs/class/referencesource/mscorlib/system/resources/filebasedresourcegroveler.cs

@@ -51,7 +51,7 @@ namespace System.Resources {
             // Don't use Assembly manifest, but grovel on disk for a file.
             try
             {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 new System.Security.Permissions.FileIOPermission(System.Security.Permissions.PermissionState.Unrestricted).Assert();
 #endif
 
@@ -79,7 +79,7 @@ namespace System.Resources {
             }
             finally
             {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 System.Security.CodeAccessPermission.RevertAssert();
 #endif
             }

+ 3 - 3
mcs/class/referencesource/mscorlib/system/resources/resourcewriter.cs

@@ -350,13 +350,13 @@ namespace System.Resources {
             // write to the temp directory (enforced via a Windows ACL).  Fall back to a MemoryStream.
             Stream dataSection = null;  // Either a FileStream or a MemoryStream
             String tempFile = null;
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             PermissionSet permSet = new PermissionSet(PermissionState.None);
             permSet.AddPermission(new EnvironmentPermission(PermissionState.Unrestricted));
             permSet.AddPermission(new FileIOPermission(PermissionState.Unrestricted));
 #endif
             try {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 permSet.Assert();
 #endif
                 tempFile = Path.GetTempFileName();
@@ -375,7 +375,7 @@ namespace System.Resources {
                 dataSection = new MemoryStream();
             }
             finally {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 PermissionSet.RevertAssert();
 #endif
             }

+ 2 - 2
mcs/class/referencesource/mscorlib/system/rttype.cs

@@ -5328,7 +5328,7 @@ namespace System
                             throw new MissingMethodException(Environment.GetResourceString("MissingConstructor_Name", FullName));
                         }
 
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                         // If we're creating a delegate, we're about to call a
                         // constructor taking an integer to represent a target
                         // method. Since this is very difficult (and expensive)
@@ -5359,7 +5359,7 @@ namespace System
                             new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
 #endif // FEATURE_CORECLR
                         }
-#endif // !DISABLE_CAS_USE
+#endif // FEATURE_MONO_CAS
                         if (invokeMethod.GetParametersNoCopy().Length == 0)
                         {
                             if (args.Length != 0)

+ 2 - 2
mcs/class/referencesource/mscorlib/system/runtime/interopservices/runtimeenvironment.cs

@@ -110,7 +110,7 @@ namespace System.Runtime.InteropServices {
                 return null;
 #endif
             String dir = GetRuntimeDirectoryImpl();
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
             new FileIOPermission(FileIOPermissionAccess.PathDiscovery, dir).Demand();
 #endif
             return dir;
@@ -143,7 +143,7 @@ namespace System.Runtime.InteropServices {
                 String path = sb.ToString();
 #endif
                 
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 // Do security check
                 new FileIOPermission(FileIOPermissionAccess.PathDiscovery, path).Demand();
 #endif

+ 8 - 8
mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryobjectreader.cs

@@ -71,7 +71,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
         private BinaryMethodReturn binaryMethodReturn;
         private bool bIsCrossAppDomain;
 #endif        
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
         private static FileIOPermission sfileIOPermission = new FileIOPermission(PermissionState.Unrestricted);
 #endif        
         private SerStack ValueFixupStack
@@ -1362,7 +1362,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
                 if (bSimpleAssembly)
                 {
                     try {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                           sfileIOPermission.Assert();
 #endif
                           try {
@@ -1373,7 +1373,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
 #endif // FEATURE_FUSION
                           }
                           finally {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                               CodeAccessPermission.RevertAssert();
 #endif
                           }
@@ -1390,14 +1390,14 @@ namespace System.Runtime.Serialization.Formatters.Binary {
                 else {
                     try
                     {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                           sfileIOPermission.Assert();
 #endif
                           try {
                               assm = Assembly.Load(assemblyName);
                           }
                           finally {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                               CodeAccessPermission.RevertAssert();
 #endif
                           }
@@ -1512,7 +1512,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
             if ( !FormatterServices.UnsafeTypeForwardersIsEnabled() && sourceAssembly != destAssembly )
             {
                 // we have a type forward to attribute !
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                 // we can try to see if the dest assembly has less permissionSet
                 if (!destAssembly.PermissionSet.IsSubsetOf(sourceAssembly.PermissionSet))
 #endif
@@ -1530,7 +1530,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
                             typeFowardedFromAssembly = Assembly.Load(typeInfo.AssemblyString);
                         }
                         catch { }
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                         if (typeFowardedFromAssembly != sourceAssembly)
                         {
                             // throw security exception
@@ -1540,7 +1540,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
                     }
                     else
                     {
-#if !DISABLE_CAS_USE
+#if FEATURE_MONO_CAS
                         // throw security exception
                         throw new SecurityException() { Demanded = sourceAssembly.PermissionSet };
 #endif