Exclude security code from the mobile targets.
authorMarek Habersack <grendel@twistedcode.net>
Wed, 10 Dec 2014 10:16:13 +0000 (11:16 +0100)
committerMarek Safar <marek.safar@gmail.com>
Mon, 2 May 2016 22:07:40 +0000 (00:07 +0200)
Mobile doesn't support any of the security features of .NET, no point in
running the code and/or defining fake types.

mcs/class/referencesource/System/compmod/system/componentmodel/TypeDescriptor.cs
mcs/class/referencesource/System/misc/SecurityUtils.cs

index d847c6e62e80e939d2e607c2327f933aed2af98f..22f7cdc5dec5a5dc5e5d9b78847c97d4f49fd2ee 100644 (file)
@@ -365,7 +365,7 @@ namespace System.ComponentModel
             {
                 throw new ArgumentNullException("type");
             }
-
+#if !MOBILE
             PermissionSet typeDescriptorPermission = new PermissionSet(PermissionState.None);
             typeDescriptorPermission.AddPermission(new TypeDescriptorPermission(TypeDescriptorPermissionFlags.RestrictedRegistrationAccess));
 
@@ -373,7 +373,7 @@ namespace System.ComponentModel
             targetPermissions = targetPermissions.Union(typeDescriptorPermission);
 
             targetPermissions.Demand();
-
+#endif
             AddProvider(provider, type);
         }
 
@@ -401,7 +401,7 @@ namespace System.ComponentModel
             {
                 throw new ArgumentNullException("instance");
             }
-
+#if !MOBILE
             Type type = instance.GetType();
 
             PermissionSet typeDescriptorPermission = new PermissionSet(PermissionState.None);
@@ -411,7 +411,7 @@ namespace System.ComponentModel
             targetPermissions = targetPermissions.Union(typeDescriptorPermission);
 
             targetPermissions.Demand();
-
+#endif
             AddProvider(provider, instance);
         }
 
@@ -3240,7 +3240,7 @@ namespace System.ComponentModel
             {
                 throw new ArgumentNullException("type");
             }
-
+#if !MOBILE
             PermissionSet typeDescriptorPermission = new PermissionSet(PermissionState.None);
             typeDescriptorPermission.AddPermission(new TypeDescriptorPermission(TypeDescriptorPermissionFlags.RestrictedRegistrationAccess));
 
@@ -3248,7 +3248,7 @@ namespace System.ComponentModel
             targetPermissions = targetPermissions.Union(typeDescriptorPermission);
 
             targetPermissions.Demand();
-
+#endif
             RemoveProvider(provider, type);
         }
 
@@ -3275,7 +3275,7 @@ namespace System.ComponentModel
             {
                 throw new ArgumentNullException("instance");
             }
-
+#if !MOBILE
             Type type = instance.GetType();
 
             PermissionSet typeDescriptorPermission = new PermissionSet(PermissionState.None);
@@ -3285,7 +3285,7 @@ namespace System.ComponentModel
             targetPermissions = targetPermissions.Union(typeDescriptorPermission);
 
             targetPermissions.Demand();
-
+#endif
             RemoveProvider(provider, instance);
         }
 
index 76e02fafbaf129d1df896e79c433af109780ea35..5bf155fd382b7a33483d0c9b7d61e3c5ebb56da9 100644 (file)
@@ -70,9 +70,11 @@ namespace System.Windows.Forms
 
         [SecuritySafeCritical]
         private static void DemandGrantSet(Assembly assembly) {
+#if !MOBILE
             PermissionSet targetGrantSet = assembly.PermissionSet;
             targetGrantSet.AddPermission(RestrictedMemberAccessPermission);
             targetGrantSet.Demand();
+#endif
         }
 
         private static bool HasReflectionPermission(Type type) {