Tweaks permissions ifdefs in System.Diagnostics.Tracing (#21733)
authorMarek Safar <marek.safar@gmail.com>
Tue, 1 Jan 2019 22:15:36 +0000 (23:15 +0100)
committerJan Kotas <jkotas@microsoft.com>
Tue, 1 Jan 2019 22:15:36 +0000 (12:15 -1000)
src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventDescriptor.cs
src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs
src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs
src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/StubEnvironment.cs

index 0fed7b5..53017b7 100644 (file)
@@ -22,9 +22,9 @@ namespace System.Diagnostics.Tracing
 #endif
 {
     [StructLayout(LayoutKind.Explicit, Size = 16)]
-#if !CORECLR && !ES_BUILD_PN    
+#if ES_BUILD_STANDALONE
     [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
-#endif // !CORECLR && !ES_BUILD_PN
+#endif
 
     /*
      EventDescriptor was public in the separate System.Diagnostics.Tracing assembly(pre NS2.0), 
index 0624a17..d6e581e 100644 (file)
@@ -55,9 +55,9 @@ namespace System.Diagnostics.Tracing
     /// Only here because System.Diagnostics.EventProvider needs one more extensibility hook (when it gets a 
     /// controller callback)
     /// </summary>
-#if !CORECLR && !ES_BUILD_PN
+#if ES_BUILD_STANDALONE
     [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)]
-#endif // !CORECLR && !ES_BUILD_PN
+#endif
     internal partial class EventProvider : IDisposable
     {
         // This is the windows EVENT_DATA_DESCRIPTOR structure.  We expose it because this is what
@@ -540,8 +540,10 @@ namespace System.Diagnostics.Tracing
                             int etwSessionId;
                             if (int.TryParse(strId, out etwSessionId))
                             {
+#if ES_BUILD_STANDALONE
                                 // we need to assert this permission for partial trust scenarios
                                 (new RegistryPermission(RegistryPermissionAccess.Read, regKey)).Assert();
+#endif
                                 var data = key.GetValue(valueName) as byte[];
                                 if (data != null)
                                 {
@@ -608,7 +610,7 @@ namespace System.Diagnostics.Tracing
                 string valueName = "ControllerData_Session_" + etwSessionId.ToString(CultureInfo.InvariantCulture);
 
                 // we need to assert this permission for partial trust scenarios
-#if !CORECLR
+#if ES_BUILD_STANDALONE
                 (new RegistryPermission(RegistryPermissionAccess.Read, regKey)).Assert();
 #endif
                 using (var key = Registry.LocalMachine.OpenSubKey(regKey))
index e149a08..38f25cf 100644 (file)
@@ -174,9 +174,9 @@ using System.Globalization;
 using System.Reflection;
 using System.Resources;
 using System.Security;
-#if !CORECLR && !ES_BUILD_PN
+#if ES_BUILD_STANDALONE
 using System.Security.Permissions;
-#endif // !CORECLR && !ES_BUILD_PN
+#endif
 
 using System.Text;
 using System.Threading;
@@ -2740,7 +2740,7 @@ namespace System.Diagnostics.Tracing
             }
             if (s_currentPid == 0)
             {
-#if ES_BUILD_STANDALONE && !ES_BUILD_PCL && !CORECLR
+#if ES_BUILD_STANDALONE
                 // for non-BCL EventSource we must assert SecurityPermission
                 new SecurityPermission(PermissionState.Unrestricted).Assert();
 #endif
@@ -3508,7 +3508,7 @@ namespace System.Diagnostics.Tracing
             // RET
             // 
             // If we find this pattern we return the XXX.  Otherwise we return -1.  
-#if !CORECLR
+#if ES_BUILD_STANDALONE
             (new ReflectionPermission(ReflectionPermissionFlag.MemberAccess)).Assert();
 #endif
             byte[] instrs = method.GetMethodBody().GetILAsByteArray();
index bd89f32..9773491 100644 (file)
@@ -324,26 +324,6 @@ namespace Microsoft.Reflection
     }
 }
 
-// Defining some no-ops in PCL builds
-#if ES_BUILD_PCL
-namespace System.Security
-{
-    class SuppressUnmanagedCodeSecurityAttribute : Attribute { }
-
-    enum SecurityAction { Demand }
-}
-
-namespace System.Security.Permissions
-{
-    class HostProtectionAttribute : Attribute { public bool MayLeakOnAbort { get; set; } }
-    class PermissionSetAttribute : Attribute
-    { 
-        public PermissionSetAttribute(System.Security.SecurityAction action) { }
-        public bool Unrestricted { get; set; }
-    }
-}
-#endif
-
 #if ES_BUILD_STANDALONE
 namespace Microsoft.Win32
 {