From b6932fd190e1c1159cee7fa6c48a1dded66e0fd7 Mon Sep 17 00:00:00 2001 From: Noah Falk Date: Fri, 15 Jul 2022 22:53:14 -0700 Subject: [PATCH] Remove Microsoft.Diagnostics.Tracing.EventSource.Redist (#71573) This package was used historically to distribute EventSource fixes out-of-band but is no longer needed. This change removed the project and the ES_BUILD_STANDALONE ifdef which was only defined when the project was building. Fixes #71231 --- .../Advapi32/Interop.EventWriteTransfer.cs | 4 - .../Net/Logging/NetEventSource.Common.cs | 18 - .../NetEventSource.Security.Windows.cs | 6 - .../src/System/Sha1ForNonSecretPurposes.cs | 8 - ...Diagnostics.Tracing.EventSource.Redist.sln | 58 ---- ...gnostics.Tracing.EventSource.Redist.csproj | 78 ----- .../Diagnostics/Tracing/StubEnvironment.cs | 74 ---- .../src/Resources/Strings.resx | 323 ------------------ ...cs.Tracing.EventSource.Redist.Tests.csproj | 41 --- .../DiagnosticSourceEventSource.cs | 18 - .../src/System/Net/Http/HttpTelemetry.cs | 6 - .../System/Net/Http/NetEventSource.Http.cs | 2 - .../NetEventSource.Security.Windows.cs | 4 - .../Net/Security/NetSecurityTelemetry.cs | 8 - .../System/Buffers/ArrayPoolEventSource.cs | 8 - .../Diagnostics/Tracing/ActivityTracker.cs | 50 +-- .../Diagnostics/Tracing/CounterGroup.cs | 68 +--- .../Diagnostics/Tracing/CounterPayload.cs | 8 - .../Diagnostics/Tracing/DiagnosticCounter.cs | 8 - .../Tracing/EventActivityOptions.cs | 7 - .../Diagnostics/Tracing/EventCounter.cs | 10 - .../Diagnostics/Tracing/EventDescriptor.cs | 7 - .../Diagnostics/Tracing/EventProvider.cs | 94 +---- .../System/Diagnostics/Tracing/EventSource.cs | 148 -------- .../Tracing/EventSourceException.cs | 4 - .../Tracing/FrameworkEventSource.cs | 6 - .../Diagnostics/Tracing/IEventProvider.cs | 8 - .../Tracing/IncrementingEventCounter.cs | 11 - .../Tracing/IncrementingPollingCounter.cs | 10 - .../Diagnostics/Tracing/PollingCounter.cs | 9 - .../Tracing/TraceLogging/ArrayTypeInfo.cs | 9 - .../Tracing/TraceLogging/ConcurrentSet.cs | 7 - .../Tracing/TraceLogging/ConcurrentSetItem.cs | 4 - .../Tracing/TraceLogging/DataCollector.cs | 4 - .../Tracing/TraceLogging/EmptyStruct.cs | 4 - .../Tracing/TraceLogging/EnumHelper.cs | 4 - .../TraceLogging/EnumerableTypeInfo.cs | 8 - .../TraceLogging/EventDataAttribute.cs | 8 - .../TraceLogging/EventFieldAttribute.cs | 8 - .../Tracing/TraceLogging/EventFieldFormat.cs | 4 - .../TraceLogging/EventIgnoreAttribute.cs | 8 - .../Tracing/TraceLogging/EventPayload.cs | 8 - .../TraceLogging/EventSourceOptions.cs | 8 - .../Tracing/TraceLogging/FieldMetadata.cs | 4 - .../Tracing/TraceLogging/InvokeTypeInfo.cs | 7 - .../Tracing/TraceLogging/NameInfo.cs | 7 - .../Tracing/TraceLogging/PropertyAnalysis.cs | 7 - .../Tracing/TraceLogging/PropertyValue.cs | 16 - .../Tracing/TraceLogging/SimpleEventTypes.cs | 12 - .../Tracing/TraceLogging/SimpleTypeInfos.cs | 17 - .../Tracing/TraceLogging/Statics.cs | 8 - .../TraceLogging/TraceLoggingDataCollector.cs | 7 - .../TraceLogging/TraceLoggingDataType.cs | 8 - .../TraceLogging/TraceLoggingEventSource.cs | 49 +-- .../TraceLogging/TraceLoggingEventTraits.cs | 8 - .../TraceLogging/TraceLoggingEventTypes.cs | 15 - .../TraceLoggingMetadataCollector.cs | 4 - .../TraceLogging/TraceLoggingTypeInfo.cs | 9 - .../Tracing/TraceLogging/TypeAnalysis.cs | 9 - .../src/System/Diagnostics/Tracing/Winmeta.cs | 9 - ...veRuntimeEventSource.PortableThreadPool.cs | 20 -- .../System/Threading/Tasks/TplEventSource.cs | 14 - .../src/Internal/DataflowEtwProvider.cs | 4 - .../Threading/Tasks/ParallelETWProvider.cs | 8 - .../System/Threading/CDSsyncETWBCLProvider.cs | 2 - .../Transactions/TransactionsEtwProvider.cs | 2 - 66 files changed, 24 insertions(+), 1410 deletions(-) delete mode 100644 src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/Microsoft.Diagnostics.Tracing.EventSource.Redist.sln delete mode 100644 src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Microsoft.Diagnostics.Tracing.EventSource.Redist.csproj delete mode 100644 src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Microsoft/Diagnostics/Tracing/StubEnvironment.cs delete mode 100644 src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Resources/Strings.resx delete mode 100644 src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/tests/Microsoft.Diagnostics.Tracing.EventSource.Redist.Tests.csproj diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteTransfer.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteTransfer.cs index 2c732dbeba32bb..d66fe12d87a9bd 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteTransfer.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteTransfer.cs @@ -3,11 +3,7 @@ using System; using System.Runtime.InteropServices; -#if ES_BUILD_STANDALONE -using Microsoft.Diagnostics.Tracing; -#else using System.Diagnostics.Tracing; -#endif internal static partial class Interop { diff --git a/src/libraries/Common/src/System/Net/Logging/NetEventSource.Common.cs b/src/libraries/Common/src/System/Net/Logging/NetEventSource.Common.cs index a292310ae7a796..b61309980ec36a 100644 --- a/src/libraries/Common/src/System/Net/Logging/NetEventSource.Common.cs +++ b/src/libraries/Common/src/System/Net/Logging/NetEventSource.Common.cs @@ -38,9 +38,7 @@ namespace System.Net /// Provides logging facilities for System.Net libraries. internal sealed partial class NetEventSource : EventSource { -#if !ES_BUILD_STANDALONE private const string EventSourceSuppressMessage = "Parameters to this method are primitive and are trimmer safe"; -#endif /// The single event source instance to use for all logging. public static readonly NetEventSource Log = new NetEventSource(); @@ -373,10 +371,8 @@ private static string Format(FormattableString s) #region Custom WriteEvent overloads -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, string? arg1, string? arg2, string? arg3, string? arg4) { @@ -421,10 +417,8 @@ private unsafe void WriteEvent(int eventId, string? arg1, string? arg2, string? } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, string? arg1, string? arg2, byte[]? arg3) { @@ -468,10 +462,8 @@ private unsafe void WriteEvent(int eventId, string? arg1, string? arg2, byte[]? } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, string? arg1, int arg2, int arg3, int arg4) { @@ -510,10 +502,8 @@ private unsafe void WriteEvent(int eventId, string? arg1, int arg2, int arg3, in } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, string? arg1, int arg2, string? arg3) { @@ -549,10 +539,8 @@ private unsafe void WriteEvent(int eventId, string? arg1, int arg2, string? arg3 } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, string? arg1, string? arg2, int arg3) { @@ -588,10 +576,8 @@ private unsafe void WriteEvent(int eventId, string? arg1, string? arg2, int arg3 } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, string? arg1, string? arg2, string? arg3, int arg4) { @@ -634,10 +620,8 @@ private unsafe void WriteEvent(int eventId, string? arg1, string? arg2, string? } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, string arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8) { @@ -696,10 +680,8 @@ private unsafe void WriteEvent(int eventId, string arg1, int arg2, int arg3, int } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, string arg1, string arg2, int arg3, int arg4, int arg5) { diff --git a/src/libraries/Common/src/System/Net/Security/NetEventSource.Security.Windows.cs b/src/libraries/Common/src/System/Net/Security/NetEventSource.Security.Windows.cs index eeb707b3496a10..77ef71b94d3592 100644 --- a/src/libraries/Common/src/System/Net/Security/NetEventSource.Security.Windows.cs +++ b/src/libraries/Common/src/System/Net/Security/NetEventSource.Security.Windows.cs @@ -9,10 +9,8 @@ namespace System.Net { internal sealed partial class NetEventSource { -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "parameter intent is an enum and is trimmer safe")] -#endif [Event(AcquireDefaultCredentialId, Keywords = Keywords.Default, Level = EventLevel.Informational)] public void AcquireDefaultCredential(string packageName, Interop.SspiCli.CredentialUse intent) { @@ -64,10 +62,8 @@ public void AcceptSecurityContext(SafeFreeCredentials? credential, SafeDeleteCon private void AcceptSecurityContext(string credential, string context, Interop.SspiCli.ContextFlags inFlags) => WriteEvent(AcceptSecuritContextId, credential, context, (int)inFlags); -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "parameter errorCode is an enum and is trimmer safe")] -#endif [Event(OperationReturnedSomethingId, Keywords = Keywords.Default, Level = EventLevel.Informational)] public void OperationReturnedSomething(string operation, Interop.SECURITY_STATUS errorCode) { @@ -77,10 +73,8 @@ public void OperationReturnedSomething(string operation, Interop.SECURITY_STATUS } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "parameter errorCode is an enum and is trimmer safe")] -#endif [Event(SecurityContextInputBufferId, Keywords = Keywords.Default, Level = EventLevel.Informational)] public void SecurityContextInputBuffer(string context, int inputBufferSize, int outputBufferSize, Interop.SECURITY_STATUS errorCode) { diff --git a/src/libraries/Common/src/System/Sha1ForNonSecretPurposes.cs b/src/libraries/Common/src/System/Sha1ForNonSecretPurposes.cs index bf87f32624be31..77da6517345136 100644 --- a/src/libraries/Common/src/System/Sha1ForNonSecretPurposes.cs +++ b/src/libraries/Common/src/System/Sha1ForNonSecretPurposes.cs @@ -53,11 +53,7 @@ public void Append(byte input) /// /// Data to include in the hash. Must not be null. /// -#if ES_BUILD_STANDALONE - public void Append(byte[] input) -#else public void Append(ReadOnlySpan input) -#endif { foreach (byte b in input) { @@ -79,11 +75,7 @@ public void Append(ReadOnlySpan input) /// bytes will be lost. If the buffer is larger than 20 bytes, the /// rest of the buffer is left unmodified. /// -#if ES_BUILD_STANDALONE - public void Finish(byte[] output) -#else public void Finish(Span output) -#endif { long l = _length + 8 * _pos; Append(0x80); diff --git a/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/Microsoft.Diagnostics.Tracing.EventSource.Redist.sln b/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/Microsoft.Diagnostics.Tracing.EventSource.Redist.sln deleted file mode 100644 index 1935344220be54..00000000000000 --- a/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/Microsoft.Diagnostics.Tracing.EventSource.Redist.sln +++ /dev/null @@ -1,58 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{D71CB9DA-6691-4A1A-80CA-45736E4B9272}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Tracing.EventSource.Redist", "src\Microsoft.Diagnostics.Tracing.EventSource.Redist.csproj", "{D7BDDDA5-180A-4CA8-864B-F9FC4E046D4F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Tracing.EventSource.Redist.Tests", "tests\Microsoft.Diagnostics.Tracing.EventSource.Redist.Tests.csproj", "{B25DF443-E116-4D44-B2AB-6D4333F59F32}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryImportGenerator", "..\System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj", "{3E38F409-6289-4822-A387-3264844AE68F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{1943D0D3-09C6-4B6A-AF96-CE50B5395631}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{DDF63C60-9514-44F6-BE59-551CCF38F5EB}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3974376A-2BB7-4695-B012-A0DB15EE777A}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{34CAB486-402D-43AE-BA78-6D58A9A337B4}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D71CB9DA-6691-4A1A-80CA-45736E4B9272}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D71CB9DA-6691-4A1A-80CA-45736E4B9272}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D71CB9DA-6691-4A1A-80CA-45736E4B9272}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D71CB9DA-6691-4A1A-80CA-45736E4B9272}.Release|Any CPU.Build.0 = Release|Any CPU - {D7BDDDA5-180A-4CA8-864B-F9FC4E046D4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D7BDDDA5-180A-4CA8-864B-F9FC4E046D4F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D7BDDDA5-180A-4CA8-864B-F9FC4E046D4F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D7BDDDA5-180A-4CA8-864B-F9FC4E046D4F}.Release|Any CPU.Build.0 = Release|Any CPU - {B25DF443-E116-4D44-B2AB-6D4333F59F32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B25DF443-E116-4D44-B2AB-6D4333F59F32}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B25DF443-E116-4D44-B2AB-6D4333F59F32}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B25DF443-E116-4D44-B2AB-6D4333F59F32}.Release|Any CPU.Build.0 = Release|Any CPU - {3E38F409-6289-4822-A387-3264844AE68F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3E38F409-6289-4822-A387-3264844AE68F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3E38F409-6289-4822-A387-3264844AE68F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3E38F409-6289-4822-A387-3264844AE68F}.Release|Any CPU.Build.0 = Release|Any CPU - {1943D0D3-09C6-4B6A-AF96-CE50B5395631}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1943D0D3-09C6-4B6A-AF96-CE50B5395631}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1943D0D3-09C6-4B6A-AF96-CE50B5395631}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1943D0D3-09C6-4B6A-AF96-CE50B5395631}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {D71CB9DA-6691-4A1A-80CA-45736E4B9272} = {DDF63C60-9514-44F6-BE59-551CCF38F5EB} - {B25DF443-E116-4D44-B2AB-6D4333F59F32} = {DDF63C60-9514-44F6-BE59-551CCF38F5EB} - {D7BDDDA5-180A-4CA8-864B-F9FC4E046D4F} = {3974376A-2BB7-4695-B012-A0DB15EE777A} - {3E38F409-6289-4822-A387-3264844AE68F} = {34CAB486-402D-43AE-BA78-6D58A9A337B4} - {1943D0D3-09C6-4B6A-AF96-CE50B5395631} = {34CAB486-402D-43AE-BA78-6D58A9A337B4} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {8CAF340C-E3EF-4DF0-998D-A17DE2C72207} - EndGlobalSection -EndGlobal diff --git a/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Microsoft.Diagnostics.Tracing.EventSource.Redist.csproj b/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Microsoft.Diagnostics.Tracing.EventSource.Redist.csproj deleted file mode 100644 index b6a616a2a204aa..00000000000000 --- a/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Microsoft.Diagnostics.Tracing.EventSource.Redist.csproj +++ /dev/null @@ -1,78 +0,0 @@ - - - This package includes the class Microsoft.Diagnostics.Tracing.EventSource which enables firing ETW events from managed code. This is the "runtime" or "redist" EventSource package and should be referenced directly only by other NuGet packages that need the EventSource functionality. Application developers that need this functionality should instead reference the Microsoft.Diagnostics.Tracing.EventSource NuGet package which provides an enhanced developer experience. -This package enables defining a strongly typed specification of an ETW provider that can be called by managed code. The EventSource class is also included in the .NET Framework, .NET Core, and netstandard2.0 in the System.Diagnostics.Tracing namespace. This package contains the latest version of EventSource and is meant to be used as a stop gap for .NET Framework developers until features and fixes are ported to System.Diagnostics.Tracing.EventSource in the .NET Framework. -For more details, have a look at http://msdn.microsoft.com/en-us/library/system.diagnostics.tracing.eventsource.aspx. - -Commonly Used Types: -Microsoft.Diagnostics.Tracing.EventSource - true - $(MSBuildProjectName) - Microsoft.Diagnostics.Tracing.EventSource - $(DefineConstants);NO_EVENTCOMMANDEXECUTED_SUPPORT;ES_BUILD_STANDALONE;FEATURE_MANAGED_ETW;TARGET_WINDOWS - false - $(NetFrameworkMinimum) - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Microsoft/Diagnostics/Tracing/StubEnvironment.cs b/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Microsoft/Diagnostics/Tracing/StubEnvironment.cs deleted file mode 100644 index 7e1a49cff5c084..00000000000000 --- a/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Microsoft/Diagnostics/Tracing/StubEnvironment.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.Permissions; - -namespace Microsoft.Diagnostics.Tracing -{ - internal static class Environment - { - public static readonly int ProcessId = GetCurrentProcessId(); - - private static int GetCurrentProcessId() - { - new SecurityPermission(PermissionState.Unrestricted).Assert(); - return (int)Interop.Kernel32.GetCurrentProcessId(); - } - } -} - -namespace System.Numerics -{ - internal static class BitOperations - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static uint RotateLeft(uint value, int offset) - => (value << offset) | (value >> (32 - offset)); - - public static int PopCount(uint value) - { - const uint c1 = 0x_55555555u; - const uint c2 = 0x_33333333u; - const uint c3 = 0x_0F0F0F0Fu; - const uint c4 = 0x_01010101u; - - value -= (value >> 1) & c1; - value = (value & c2) + ((value >> 2) & c2); - value = (((value + (value >> 4)) & c3) * c4) >> 24; - - return (int)value; - } - - public static int TrailingZeroCount(uint value) - { - if (value == 0) - return 32; - - int count = 0; - while ((value & 1) == 0) - { - value >>= 1; - count++; - } - return count; - } - } -} - -internal static partial class Interop -{ - [SuppressUnmanagedCodeSecurityAttribute] - internal static partial class Kernel32 - { - [LibraryImport(nameof(Kernel32))] - internal static partial int GetCurrentThreadId(); - - [LibraryImport(nameof(Kernel32))] - internal static partial uint GetCurrentProcessId(); - } -} diff --git a/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Resources/Strings.resx b/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Resources/Strings.resx deleted file mode 100644 index 0e3913b9ba776f..00000000000000 --- a/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/src/Resources/Strings.resx +++ /dev/null @@ -1,323 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - The given key '{0}' was not present in the dictionary. - - - The name of the type is invalid. - - - Non-negative number required. - - - The ID parameter must be in the range {0} through {1}. - - - Abstract event source must not declare event methods ({0} with ID {1}). - - - Abstract event source must not declare {0} nested type. - - - Getting out of bounds during scalar addition. - - - Bad Hexidecimal digit "{0}". - - - Channel {0} does not match event channel value {1}. - - - Data descriptors are out of range. - - - Multiple definitions for string "{0}". - - - The type of {0} is not expected in {1}. - - - Must have an even number of Hexidecimal digits. - - - Channel {0} has a value of {1} which is outside the legal range (16-254). - - - Event {0} has ID {1} which is already in use. - - - Event {0} (with ID {1}) has a non-default opcode but not a task. - - - Event method {0} (with ID {1}) is an explicit interface method implementation. Re-write method as implicit implementation. - - - Event {0} (with ID {1}) has a name that is not the concatenation of its task name and opcode. - - - Event name {0} used more than once. If you wish to overload a method, the overloaded method should have a NonEvent attribute. - - - Event {0} was called with {1} argument(s), but it is defined with {2} parameter(s). - - - An instance of EventSource with Guid {0} already exists. - - - The payload for a single event is too large. - - - Event {0} specifies an Admin channel {1}. It must specify a Message property. - - - Keyword {0} has a value of {1} which is outside the legal range (0-0x0000080000000000). - - - Opcode {0} has a value of {1} which is outside the legal range (11-238). - - - Task {0} has a value of {1} which is outside the legal range (1-65535). - - - Illegal value "{0}" (prefix strings with @ to indicate a literal string). - - - Incorrectly-authored TypeInfo - a type should be serialized as one field or as one group - - - Invalid command value. - - - Can't specify both etw event format flags. - - - Keywords {0} and {1} are defined with the same value ({2}). - - - Value {0} for keyword {1} needs to be a power of 2. - - - Creating an EventListener inside a EventListener callback. - - - Listener not found. - - - An error occurred when writing to a listener. - - - Attempt to define more than the maximum limit of 8 channels for a provider. - - - Event {0} was assigned event ID {1} but {2} was passed to WriteEvent. - - - The Guid of an EventSource must be non zero. - - - The name of an EventSource must not be null. - - - Event IDs must be positive integers. - - - No Free Buffers available from the operating system (e.g. event rate too fast). - - - The API supports only anonymous types or types decorated with the EventDataAttribute. Non-compliant type: {0} dataType. - - - EventSource expects the first parameter of the Event method to be of type Guid and to be named "relatedActivityId" when calling WriteEventWithRelatedActivityId. - - - Arrays of Binary are not supported. - - - Arrays of Nil are not supported. - - - Arrays of null-terminated string are not supported. - - - Enumerables of custom-serialized data are not supported - - - Nested arrays/enumerables are not supported. - - - Null passed as a event argument. - - - Opcodes {0} and {1} are defined with the same value ({2}). - - - Pins are out of range. - - - Recursive type definition is not supported. - - - An event with stop suffix must follow a corresponding event with a start suffix. - - - Tasks {0} and {1} are defined with the same value ({2}). - - - Event {0} (with ID {1}) has the same task/opcode pair as event {2} (with ID {3}). - - - Too many arguments. - - - Too many fields in structure. - - - EventSource({0}, {1}) - - - There must be an even number of trait strings (they are key-value pairs). - - - Event source types must be sealed or abstract. - - - Event source types must derive from EventSource. - - - Use of undefined channel value {0} for event {1}. - - - Use of undefined keyword value {0} for event {1}. - - - Use of undefined opcode value {0} for event {1}. - - - Unknown ETW trait "{0}". - - - Unsupported type {0} in event source. - - - Event {0} specifies an illegal or unsupported formatting message ("{1}"). - - - The parameters to the Event method do not match the parameters to the WriteEvent method. This may cause the event to be displayed incorrectly. - - diff --git a/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/tests/Microsoft.Diagnostics.Tracing.EventSource.Redist.Tests.csproj b/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/tests/Microsoft.Diagnostics.Tracing.EventSource.Redist.Tests.csproj deleted file mode 100644 index 7005c7fdbb8d0f..00000000000000 --- a/src/libraries/Microsoft.Diagnostics.Tracing.EventSource.Redist/tests/Microsoft.Diagnostics.Tracing.EventSource.Redist.Tests.csproj +++ /dev/null @@ -1,41 +0,0 @@ - - - $(DefineConstants);USE_MDT_EVENTSOURCE - true - $(NetFrameworkMinimum) - - - ..\..\System.Diagnostics.Tracing\tests - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs index 0b9102c4a35324..c79297bcf3fe52 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs @@ -233,10 +233,8 @@ public void Message(string? Message) /// /// Events from DiagnosticSource can be forwarded to EventSource using this event. /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Arguments parameter is trimmer safe")] -#endif [Event(2, Keywords = Keywords.Events)] private void Event(string SourceName, string EventName, IEnumerable>? Arguments) { @@ -256,10 +254,8 @@ private void EventJson(string SourceName, string EventName, string ArgmentsJson) /// /// Used to mark the beginning of an activity /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Arguments parameter is trimmer safe")] -#endif [Event(4, Keywords = Keywords.Events)] private void Activity1Start(string SourceName, string EventName, IEnumerable> Arguments) { @@ -269,10 +265,8 @@ private void Activity1Start(string SourceName, string EventName, IEnumerable /// Used to mark the end of an activity /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Arguments parameter is trimmer safe")] -#endif [Event(5, Keywords = Keywords.Events)] private void Activity1Stop(string SourceName, string EventName, IEnumerable> Arguments) { @@ -282,10 +276,8 @@ private void Activity1Stop(string SourceName, string EventName, IEnumerable /// Used to mark the beginning of an activity /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Arguments parameter is trimmer safe")] -#endif [Event(6, Keywords = Keywords.Events)] private void Activity2Start(string SourceName, string EventName, IEnumerable> Arguments) { @@ -295,10 +287,8 @@ private void Activity2Start(string SourceName, string EventName, IEnumerable /// Used to mark the end of an activity that can be recursive. /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Arguments parameter is trimmer safe")] -#endif [Event(7, Keywords = Keywords.Events)] private void Activity2Stop(string SourceName, string EventName, IEnumerable> Arguments) { @@ -308,10 +298,8 @@ private void Activity2Stop(string SourceName, string EventName, IEnumerable /// Used to mark the beginning of an activity /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Arguments parameter is trimmer safe")] -#endif [Event(8, Keywords = Keywords.Events, ActivityOptions = EventActivityOptions.Recursive)] private void RecursiveActivity1Start(string SourceName, string EventName, IEnumerable> Arguments) { @@ -321,10 +309,8 @@ private void RecursiveActivity1Start(string SourceName, string EventName, IEnume /// /// Used to mark the end of an activity that can be recursive. /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Arguments parameter is trimmer safe")] -#endif [Event(9, Keywords = Keywords.Events, ActivityOptions = EventActivityOptions.Recursive)] private void RecursiveActivity1Stop(string SourceName, string EventName, IEnumerable> Arguments) { @@ -347,10 +333,8 @@ private void NewDiagnosticListener(string SourceName) /// The ActivitySource name /// The Activity name /// Name and value pairs of the Activity properties -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Arguments parameter is trimmer safe")] -#endif [Event(11, Keywords = Keywords.Events, ActivityOptions = EventActivityOptions.Recursive)] private void ActivityStart(string SourceName, string ActivityName, IEnumerable> Arguments) => WriteEvent(11, SourceName, ActivityName, Arguments); @@ -361,10 +345,8 @@ private void ActivityStart(string SourceName, string ActivityName, IEnumerableThe ActivitySource name /// The Activity name /// Name and value pairs of the Activity properties -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Arguments parameter is trimmer safe")] -#endif [Event(12, Keywords = Keywords.Events, ActivityOptions = EventActivityOptions.Recursive)] private void ActivityStop(string SourceName, string ActivityName, IEnumerable> Arguments) => WriteEvent(12, SourceName, ActivityName, Arguments); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpTelemetry.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpTelemetry.cs index ce039003e95c15..059b876b4387ac 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpTelemetry.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpTelemetry.cs @@ -174,10 +174,8 @@ public void Http30ConnectionClosed() ConnectionClosed(versionMajor: 3, versionMinor: 0); } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Parameters to this method are primitive and are trimmer safe")] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, string? arg1, string? arg2, int arg3, string? arg4, byte arg5, byte arg6, HttpVersionPolicy arg7) { @@ -235,10 +233,8 @@ private unsafe void WriteEvent(int eventId, string? arg1, string? arg2, int arg3 } } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Parameters to this method are primitive and are trimmer safe")] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, double arg1, byte arg2, byte arg3) { @@ -267,10 +263,8 @@ private unsafe void WriteEvent(int eventId, double arg1, byte arg2, byte arg3) } } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Parameters to this method are primitive and are trimmer safe")] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, byte arg1, byte arg2) { diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/NetEventSource.Http.cs b/src/libraries/System.Net.Http/src/System/Net/Http/NetEventSource.Http.cs index 4cc256850e54c4..571ab0fc7bf2ea 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/NetEventSource.Http.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/NetEventSource.Http.cs @@ -74,10 +74,8 @@ public static void AuthenticationError(Uri? uri, string message) public void AuthenticationError(string? uri, string message) => WriteEvent(AuthenticationErrorId, uri, message); -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, int arg1, int arg2, int arg3, string? arg4, string? arg5) { diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/NetEventSource.Security.Windows.cs b/src/libraries/System.Net.Security/src/System/Net/Security/NetEventSource.Security.Windows.cs index 1d6b61bbf91913..12694700cf8a36 100644 --- a/src/libraries/System.Net.Security/src/System/Net/Security/NetEventSource.Security.Windows.cs +++ b/src/libraries/System.Net.Security/src/System/Net/Security/NetEventSource.Security.Windows.cs @@ -9,10 +9,8 @@ namespace System.Net { internal sealed partial class NetEventSource { -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "parameter intent is an enum and is trimmer safe")] -#endif [Event(AcquireDefaultCredentialId, Keywords = Keywords.Default, Level = EventLevel.Informational)] public void AcquireDefaultCredential(string packageName, Interop.SspiCli.CredentialUse intent) { @@ -64,10 +62,8 @@ public void AcceptSecurityContext(SafeFreeCredentials? credential, SafeDeleteCon private void AcceptSecurityContext(string credential, string context, Interop.SspiCli.ContextFlags inFlags) => WriteEvent(AcceptSecuritContextId, credential, context, (int)inFlags); -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "parameter errorCode is an enum and is trimmer safe")] -#endif [Event(OperationReturnedSomethingId, Keywords = Keywords.Default, Level = EventLevel.Informational)] public void OperationReturnedSomething(string operation, Interop.SECURITY_STATUS errorCode) { diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/NetSecurityTelemetry.cs b/src/libraries/System.Net.Security/src/System/Net/Security/NetSecurityTelemetry.cs index 4274367105a9ea..b177cd615432ee 100644 --- a/src/libraries/System.Net.Security/src/System/Net/Security/NetSecurityTelemetry.cs +++ b/src/libraries/System.Net.Security/src/System/Net/Security/NetSecurityTelemetry.cs @@ -12,9 +12,7 @@ namespace System.Net.Security [EventSource(Name = "System.Net.Security")] internal sealed class NetSecurityTelemetry : EventSource { -#if !ES_BUILD_STANDALONE private const string EventSourceSuppressMessage = "Parameters to this method are primitive and are trimmer safe"; -#endif public static readonly NetSecurityTelemetry Log = new NetSecurityTelemetry(); private IncrementingPollingCounter? _tlsHandshakeRateCounter; @@ -247,10 +245,8 @@ public void ConnectionClosed(SslProtocols protocol) } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, bool arg1, string? arg2) { @@ -279,10 +275,8 @@ private unsafe void WriteEvent(int eventId, bool arg1, string? arg2) } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, SslProtocols arg1) { @@ -298,10 +292,8 @@ private unsafe void WriteEvent(int eventId, SslProtocols arg1) } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, bool arg1, double arg2, string? arg3) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/ArrayPoolEventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/ArrayPoolEventSource.cs index 7fb9e54b6bb85e..fe52a9b5163475 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/ArrayPoolEventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/ArrayPoolEventSource.cs @@ -10,9 +10,7 @@ namespace System.Buffers [EventSourceAutoGenerate] internal sealed partial class ArrayPoolEventSource : EventSource { -#if !ES_BUILD_STANDALONE private const string EventSourceSuppressMessage = "Parameters to this method are primitive and are trimmer safe"; -#endif internal static readonly ArrayPoolEventSource Log = new ArrayPoolEventSource(); /// Bucket ID used when renting/returning an array that's too large for a pool. @@ -50,10 +48,8 @@ private ArrayPoolEventSource(int _) { } /// of BufferAllocated events being less than or equal to those numbers (ideally significantly /// less than). /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(1, Level = EventLevel.Verbose)] internal unsafe void BufferRented(int bufferId, int bufferSize, int poolId, int bucketId) { @@ -78,10 +74,8 @@ internal unsafe void BufferRented(int bufferId, int bufferSize, int poolId, int /// of BufferAllocated events is significantly smaller than the number of BufferRented and /// BufferReturned events. /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(2, Level = EventLevel.Informational)] internal unsafe void BufferAllocated(int bufferId, int bufferSize, int poolId, int bucketId, BufferAllocatedReason reason) { @@ -129,10 +123,8 @@ internal unsafe void BufferAllocated(int bufferId, int bufferSize, int poolId, i /// /// Event raised when a buffer returned to the pool is dropped. /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = EventSourceSuppressMessage)] -#endif [Event(6, Level = EventLevel.Informational)] internal unsafe void BufferDropped(int bufferId, int bufferSize, int poolId, int bucketId, BufferDroppedReason reason) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ActivityTracker.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ActivityTracker.cs index 026e93cbdfdc9d..9b79bea9d0d000 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ActivityTracker.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ActivityTracker.cs @@ -1,19 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -using System.Diagnostics; -#else using System.Threading.Tasks; -#endif using System.Threading; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// Tracks activities. This is meant to be a singleton (accessed by the ActivityTracer.Instance static property) @@ -265,19 +256,11 @@ private static string NormalizeActivityName(string providerName, string activity if (activityName.EndsWith(EventSource.s_ActivityStartSuffix, StringComparison.Ordinal)) { -#if ES_BUILD_STANDALONE - return string.Concat(providerName, activityName.Substring(0, activityName.Length - EventSource.s_ActivityStartSuffix.Length)); -#else return string.Concat(providerName, activityName.AsSpan(0, activityName.Length - EventSource.s_ActivityStartSuffix.Length)); -#endif } else if (activityName.EndsWith(EventSource.s_ActivityStopSuffix, StringComparison.Ordinal)) { -#if ES_BUILD_STANDALONE - return string.Concat(providerName, activityName.Substring(0, activityName.Length - EventSource.s_ActivityStopSuffix.Length)); -#else return string.Concat(providerName, activityName.AsSpan(0, activityName.Length - EventSource.s_ActivityStopSuffix.Length)); -#endif } else if (task != 0) { @@ -376,11 +359,7 @@ private unsafe void CreateActivityPathGuid(out Guid idRet, out int activityPathG } else { - // TODO FIXME - differentiate between AD inside PCL - int appDomainID = 0; -#if (!ES_BUILD_STANDALONE) - appDomainID = System.Threading.Thread.GetDomainID(); -#endif + int appDomainID = System.Threading.Thread.GetDomainID(); // We start with the appdomain number to make this unique among appdomains. activityPathGuidOffsetStart = AddIdToGuid(outPtr, activityPathGuidOffsetStart, (uint)appDomainID); } @@ -632,31 +611,4 @@ private void ActivityChanging(AsyncLocalValueChangedArgs args) #endregion } - -#if ES_BUILD_STANDALONE - /******************************** SUPPORT *****************************/ - /// - /// This is supplied by the framework. It is has the semantics that the value is copied to any new Tasks that is created - /// by the current task. Thus all causally related code gets this value. Note that reads and writes to this VARIABLE - /// (not what it points it) to this does not need to be protected by locks because it is inherently thread local (you always - /// only get your thread local copy which means that you never have races. - /// - /// - [EventSource(Name = "Microsoft.Tasks.Nuget")] - internal sealed class TplEventSource : EventSource - { - public static class Keywords - { - public const EventKeywords TasksFlowActivityIds = (EventKeywords)0x80; - public const EventKeywords Debug = (EventKeywords)0x20000; - } - - public static TplEventSource Log = new TplEventSource(); - public bool Debug { get { return IsEnabled(EventLevel.Verbose, Keywords.Debug); } } - - public void DebugFacilityMessage(string Facility, string Message) { WriteEvent(1, Facility, Message); } - public void DebugFacilityMessage1(string Facility, string Message, string Arg) { WriteEvent(2, Facility, Message, Arg); } - public void SetActivityId(Guid Id) { WriteEvent(3, Id); } - } -#endif } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs index 2bd67dc51c7194..f248899679a980 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs @@ -1,19 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -using System.Diagnostics; -#endif using System.Collections.Generic; using System.Runtime.Versioning; using System.Threading; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { internal sealed class CounterGroup { @@ -132,53 +124,29 @@ private void EnableTimer(float pollingIntervalInSeconds) ResetCounters(); // Reset statistics for counters before we start the thread. _timeStampSinceCollectionStarted = DateTime.UtcNow; -#if ES_BUILD_STANDALONE - // Don't capture the current ExecutionContext and its AsyncLocals onto the timer causing them to live forever - bool restoreFlow = false; - try - { - if (!ExecutionContext.IsFlowSuppressed()) - { - ExecutionContext.SuppressFlow(); - restoreFlow = true; - } -#endif - _nextPollingTimeStamp = DateTime.UtcNow + new TimeSpan(0, 0, (int)pollingIntervalInSeconds); - - // Create the polling thread and init all the shared state if needed - if (s_pollingThread == null) - { - s_pollingThreadSleepEvent = new AutoResetEvent(false); - s_counterGroupEnabledList = new List(); - s_pollingThread = new Thread(PollForValues) - { - IsBackground = true, - Name = ".NET Counter Poller" - }; -#if ES_BUILD_STANDALONE - s_pollingThread.Start(); -#else - s_pollingThread.InternalUnsafeStart(); -#endif - } + _nextPollingTimeStamp = DateTime.UtcNow + new TimeSpan(0, 0, (int)pollingIntervalInSeconds); - if (!s_counterGroupEnabledList!.Contains(this)) + // Create the polling thread and init all the shared state if needed + if (s_pollingThread == null) + { + s_pollingThreadSleepEvent = new AutoResetEvent(false); + s_counterGroupEnabledList = new List(); + s_pollingThread = new Thread(PollForValues) { - s_counterGroupEnabledList.Add(this); - } - - // notify the polling thread that the polling interval may have changed and the sleep should - // be recomputed - s_pollingThreadSleepEvent!.Set(); -#if ES_BUILD_STANDALONE + IsBackground = true, + Name = ".NET Counter Poller" + }; + s_pollingThread.InternalUnsafeStart(); } - finally + + if (!s_counterGroupEnabledList!.Contains(this)) { - // Restore the current ExecutionContext - if (restoreFlow) - ExecutionContext.RestoreFlow(); + s_counterGroupEnabledList.Add(this); } -#endif + + // notify the polling thread that the polling interval may have changed and the sleep should + // be recomputed + s_pollingThreadSleepEvent!.Set(); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterPayload.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterPayload.cs index 6c872159e65de1..01dac53d2583ab 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterPayload.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterPayload.cs @@ -1,18 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -using System.Diagnostics; -#endif using System.Collections; using System.Collections.Generic; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { [EventData] internal sealed class CounterPayload : IEnumerable> diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs index aae0333497c0f8..ee612167f8af6a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs @@ -1,20 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -using System.Diagnostics; -#endif using System.Collections.Generic; using System.Runtime.Versioning; using System.Text; using System.Threading; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// DiagnosticCounter is an abstract class that serves as the parent class for various Counter* classes, diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventActivityOptions.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventActivityOptions.cs index f4fb6927fe5af7..fa44ded6dc2547 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventActivityOptions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventActivityOptions.cs @@ -1,15 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// EventActivityOptions flags allow to specify different activity related characteristics. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs index 6fea134739756b..e21891c83e7d24 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs @@ -1,19 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -using System.Diagnostics; -#endif using System.Diagnostics.CodeAnalysis; using System.Runtime.Versioning; using System.Threading; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// Provides the ability to collect statistics through EventSource @@ -94,11 +86,9 @@ internal void OnMetricWritten(double value) _count++; } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The DynamicDependency will preserve the properties of CounterPayload")] [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties, typeof(CounterPayload))] -#endif internal override void WritePayload(float intervalSec, int pollingIntervalMillisec) { lock (this) diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventDescriptor.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventDescriptor.cs index b1aaccd7f7f7c6..1ab7aaff5d28b2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventDescriptor.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventDescriptor.cs @@ -5,16 +5,9 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { [StructLayout(LayoutKind.Explicit, Size = 16)] -#if ES_BUILD_STANDALONE - [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] -#endif internal readonly struct EventDescriptor : IEquatable { #region private diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs index c552a897eecd2e..5080f0ca1cafe5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs @@ -9,20 +9,11 @@ using System.Runtime.InteropServices; using System.Threading; -#if ES_BUILD_STANDALONE -using Microsoft.Win32; -using System.Security.Permissions; -#endif - -#if !ES_BUILD_STANDALONE && TARGET_WINDOWS +#if TARGET_WINDOWS using Internal.Win32; #endif -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { internal enum EventProviderType { @@ -45,9 +36,6 @@ internal enum ControllerCommand /// Only here because System.Diagnostics.EventProvider needs one more extensibility hook (when it gets a /// controller callback) /// -#if ES_BUILD_STANDALONE - [System.Security.Permissions.HostProtection(MayLeakOnAbort = true)] -#endif internal class EventProvider : IDisposable { // This is the windows EVENT_DATA_DESCRIPTOR structure. We expose it because this is what @@ -147,7 +135,7 @@ internal unsafe void Register(EventSource eventSource) status = EventRegister(eventSource, m_etwCallback); if (status != 0) { -#if TARGET_WINDOWS && !ES_BUILD_STANDALONE +#if TARGET_WINDOWS throw new ArgumentException(Interop.Kernel32.GetMessage(unchecked((int)status))); #else throw new ArgumentException(Convert.ToString(unchecked((int)status))); @@ -459,15 +447,7 @@ private static void GetSessionInfoCallback(int etwSessionId, long matchAllKeywor #endif unsafe void GetSessionInfo(SessionInfoCallback action, ref List? sessionList) { - // We wish the EventSource package to be legal for Windows Store applications. - // Currently EnumerateTraceGuidsEx is not an allowed API, so we avoid its use here - // and use the information in the registry instead. This means that ETW controllers - // that do not publish their intent to the registry (basically all controllers EXCEPT - // TraceEventSesion) will not work properly - - // However the framework version of EventSource DOES have ES_SESSION_INFO defined and thus - // does not have this issue. -#if (TARGET_WINDOWS && (ES_SESSION_INFO || !ES_BUILD_STANDALONE)) +#if TARGET_WINDOWS int buffSize = 256; // An initial guess that probably works most of the time. byte* stackSpace = stackalloc byte[buffSize]; byte* buffer = stackSpace; @@ -523,60 +503,7 @@ unsafe void GetSessionInfo(SessionInfoCallback action, ref List? se Marshal.FreeHGlobal((IntPtr)buffer); } } -#else -#if TARGET_WINDOWS - // This code is only used in the Nuget Package Version of EventSource. because - // the code above is using APIs baned from UWP apps. - // - // TODO: In addition to only working when TraceEventSession enables the provider, this code - // also has a problem because TraceEvent does not clean up if the registry is stale - // It is unclear if it is worth keeping, but for now we leave it as it does work - // at least some of the time. - - // Determine our session from what is in the registry. - string regKey = @"\Microsoft\Windows\CurrentVersion\Winevt\Publishers\{" + m_providerName + "}"; - if (IntPtr.Size == 8) - regKey = @"Software" + @"\Wow6432Node" + regKey; - else - regKey = @"Software" + regKey; - using (var key = Registry.LocalMachine.OpenSubKey(regKey)) - { - if (key != null) - { - foreach (string valueName in key.GetValueNames()) - { - if (valueName.StartsWith("ControllerData_Session_", StringComparison.Ordinal)) - { - string strId = valueName.Substring(23); // strip of the ControllerData_Session_ - 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) - { - var dataAsString = System.Text.Encoding.UTF8.GetString(data); - int keywordIdx = dataAsString.IndexOf("EtwSessionKeyword", StringComparison.Ordinal); - if (0 <= keywordIdx) - { - int startIdx = keywordIdx + 18; - int endIdx = dataAsString.IndexOf('\0', startIdx); - string keywordBitString = dataAsString.Substring(startIdx, endIdx - startIdx); - int keywordBit; - if (0 < endIdx && int.TryParse(keywordBitString, out keywordBit)) - action(etwSessionId, 1L << keywordBit, ref sessionList); - } - } - } - } - } - } - } -#endif #endif } @@ -626,9 +553,6 @@ unsafe bool GetDataFromController(int etwSessionId, string valueName = "ControllerData_Session_" + etwSessionId.ToString(CultureInfo.InvariantCulture); // we need to assert this permission for partial trust scenarios -#if ES_BUILD_STANDALONE - (new RegistryPermission(RegistryPermissionAccess.Read, regKey)).Assert(); -#endif using (RegistryKey? key = Registry.LocalMachine.OpenSubKey(regKey)) { data = key?.GetValue(valueName, null) as byte[]; @@ -998,15 +922,10 @@ internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, IntPtr even int index; int refObjIndex = 0; -#if ES_BUILD_STANDALONE - int[] refObjPosition = new int[EtwAPIMaxRefObjCount]; - object?[] dataRefObj = new object?[EtwAPIMaxRefObjCount]; -#else Debug.Assert(EtwAPIMaxRefObjCount == 8, $"{nameof(EtwAPIMaxRefObjCount)} must equal the number of fields in {nameof(EightObjects)}"); EightObjects eightObjectStack = default; Span refObjPosition = stackalloc int[EtwAPIMaxRefObjCount]; Span dataRefObj = new Span(ref eightObjectStack._arg0, EtwAPIMaxRefObjCount); -#endif EventData* userData = stackalloc EventData[2 * argCount]; for (int i = 0; i < 2 * argCount; i++) @@ -1045,10 +964,6 @@ internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, IntPtr even if (refObjIndex >= dataRefObj.Length) { -#if ES_BUILD_STANDALONE - Array.Resize(ref dataRefObj, dataRefObj.Length * 2); - Array.Resize(ref refObjPosition, refObjPosition.Length * 2); -#else Span newDataRefObj = new object?[dataRefObj.Length * 2]; dataRefObj.CopyTo(newDataRefObj); dataRefObj = newDataRefObj; @@ -1056,7 +971,6 @@ internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, IntPtr even Span newRefObjPosition = new int[refObjPosition.Length * 2]; refObjPosition.CopyTo(newRefObjPosition); refObjPosition = newRefObjPosition; -#endif } dataRefObj[refObjIndex] = supportedRefObj; @@ -1178,7 +1092,6 @@ internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, IntPtr even return true; } -#if !ES_BUILD_STANDALONE /// Workaround for inability to stackalloc object[EtwAPIMaxRefObjCount == 8]. private struct EightObjects { @@ -1193,7 +1106,6 @@ private struct EightObjects private object? _arg7; #pragma warning restore CA1823, CS0169, IDE0051 } -#endif /// /// WriteEvent, method to be used by generated code on a derived class diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs index 11b9b5fa38f341..bb879a64ce42ba 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs @@ -3,10 +3,6 @@ // This program uses code hyperlinks available as part of the HyperAddin Visual Studio plug-in. // It is available from http://www.codeplex.com/hyperAddin -#if ES_BUILD_STANDALONE -#define FEATURE_MANAGED_ETW_CHANNELS -// #define FEATURE_ADVANCED_MANAGED_ETW_CHANNELS -#endif /* DESIGN NOTES DESIGN NOTES DESIGN NOTES DESIGN NOTES */ // DESIGN NOTES @@ -177,14 +173,7 @@ using System.Threading; using System.Threading.Tasks; -#if ES_BUILD_STANDALONE -using System.Security.Permissions; -#endif -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -{ -#else namespace System.Diagnostics.Tracing { [Conditional("NEEDED_FOR_SOURCE_GENERATOR_ONLY")] @@ -193,7 +182,6 @@ internal sealed class EventSourceAutoGenerateAttribute : Attribute { } -#endif /// /// This class is meant to be inherited by a user-defined event source in order to define a managed /// ETW provider. Please See DESIGN NOTES above for the internal architecture. @@ -229,7 +217,6 @@ internal sealed class EventSourceAutoGenerateAttribute : Attribute /// } /// /// -#if !ES_BUILD_STANDALONE // The EnsureDescriptorsInitialized() method might need to access EventSource and its derived type // members and the trimmer ensures that these members are preserved. [DynamicallyAccessedMembers(ManifestMemberTypes)] @@ -243,7 +230,6 @@ internal sealed class EventSourceAutoGenerateAttribute : Attribute "because the nested type OverrideEventProvider's base type EventProvider defines a delegate. " + "This includes Delegate and MulticastDelegate methods which have dynamically accessed members requirements, but " + "EnsureDescriptorsInitialized does not access these members and is safe to call.")] -#endif public partial class EventSource : IDisposable { @@ -357,9 +343,7 @@ public static string GetName(Type eventSourceType) return GetName(eventSourceType, EventManifestOptions.None); } -#if !ES_BUILD_STANDALONE private const DynamicallyAccessedMemberTypes ManifestMemberTypes = DynamicallyAccessedMemberTypes.All; -#endif /// /// Returns a string of the XML manifest associated with the eventSourceType. The scheme for this XML is @@ -371,16 +355,12 @@ public static string GetName(Type eventSourceType) /// The manifest XML fragment contains the string name of the DLL name in /// which it is embedded. This parameter specifies what name will be used /// The XML data string -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2114:ReflectionToDynamicallyAccessedMembers", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "has dynamically accessed members requirements, but EnsureDescriptorsInitialized does not "+ "access this member and is safe to call.")] -#endif public static string? GenerateManifest( -#if !ES_BUILD_STANDALONE [DynamicallyAccessedMembers(ManifestMemberTypes)] -#endif Type eventSourceType, string? assemblyPathToIncludeInManifest) { @@ -398,16 +378,12 @@ public static string GetName(Type eventSourceType) /// The flags to customize manifest generation. If flags has bit OnlyIfNeededForRegistration specified /// this returns null when the eventSourceType does not require explicit registration /// The XML data string or null -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2114:ReflectionToDynamicallyAccessedMembers", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "has dynamically accessed members requirements, but EnsureDescriptorsInitialized does not "+ "access this member and is safe to call.")] -#endif public static string? GenerateManifest( -#if !ES_BUILD_STANDALONE [DynamicallyAccessedMembers(ManifestMemberTypes)] -#endif Type eventSourceType, string? assemblyPathToIncludeInManifest, EventManifestOptions flags) @@ -797,20 +773,16 @@ protected virtual void OnEventCommand(EventCommandEventArgs command) { } #pragma warning disable 1591 // optimized for common signatures (no args) -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId) { WriteEventCore(eventId, 0, null); } // optimized for common signatures (ints) -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, int arg1) { if (IsEnabled()) @@ -823,10 +795,8 @@ protected unsafe void WriteEvent(int eventId, int arg1) } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, int arg1, int arg2) { if (IsEnabled()) @@ -842,10 +812,8 @@ protected unsafe void WriteEvent(int eventId, int arg1, int arg2) } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, int arg1, int arg2, int arg3) { if (IsEnabled()) @@ -865,10 +833,8 @@ protected unsafe void WriteEvent(int eventId, int arg1, int arg2, int arg3) } // optimized for common signatures (longs) -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, long arg1) { if (IsEnabled()) @@ -881,10 +847,8 @@ protected unsafe void WriteEvent(int eventId, long arg1) } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, long arg1, long arg2) { if (IsEnabled()) @@ -900,10 +864,8 @@ protected unsafe void WriteEvent(int eventId, long arg1, long arg2) } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, long arg1, long arg2, long arg3) { if (IsEnabled()) @@ -923,10 +885,8 @@ protected unsafe void WriteEvent(int eventId, long arg1, long arg2, long arg3) } // optimized for common signatures (strings) -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, string? arg1) { if (IsEnabled()) @@ -943,10 +903,8 @@ protected unsafe void WriteEvent(int eventId, string? arg1) } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, string? arg1, string? arg2) { if (IsEnabled()) @@ -968,10 +926,8 @@ protected unsafe void WriteEvent(int eventId, string? arg1, string? arg2) } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, string? arg1, string? arg2, string? arg3) { if (IsEnabled()) @@ -999,10 +955,8 @@ protected unsafe void WriteEvent(int eventId, string? arg1, string? arg2, string } // optimized for common signatures (string and ints) -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, string? arg1, int arg2) { if (IsEnabled()) @@ -1022,10 +976,8 @@ protected unsafe void WriteEvent(int eventId, string? arg1, int arg2) } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, string? arg1, int arg2, int arg3) { if (IsEnabled()) @@ -1049,10 +1001,8 @@ protected unsafe void WriteEvent(int eventId, string? arg1, int arg2, int arg3) } // optimized for common signatures (string and longs) -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, string? arg1, long arg2) { if (IsEnabled()) @@ -1073,10 +1023,8 @@ protected unsafe void WriteEvent(int eventId, string? arg1, long arg2) } // optimized for common signatures (long and string) -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, long arg1, string? arg2) { if (IsEnabled()) @@ -1097,10 +1045,8 @@ protected unsafe void WriteEvent(int eventId, long arg1, string? arg2) } // optimized for common signatures (int and string) -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, int arg1, string? arg2) { if (IsEnabled()) @@ -1120,10 +1066,8 @@ protected unsafe void WriteEvent(int eventId, int arg1, string? arg2) } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, byte[]? arg1) { if (IsEnabled()) @@ -1157,10 +1101,8 @@ protected unsafe void WriteEvent(int eventId, byte[]? arg1) } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif protected unsafe void WriteEvent(int eventId, long arg1, byte[]? arg2) { if (IsEnabled()) @@ -1284,12 +1226,10 @@ internal unsafe void SetMetadata(byte* pointer, int size, int reserved) /// } /// /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "requires unreferenced code, but EnsureDescriptorsInitialized does not access this member and is safe to call.")] [RequiresUnreferencedCode(EventSourceRequiresUnreferenceMessage)] -#endif [CLSCompliant(false)] protected unsafe void WriteEventCore(int eventId, int eventDataCount, EventSource.EventData* data) { @@ -1321,12 +1261,10 @@ protected unsafe void WriteEventCore(int eventId, int eventDataCount, EventSourc /// } /// /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "requires unreferenced code, but EnsureDescriptorsInitialized does not access this member and is safe to call.")] [RequiresUnreferencedCode(EventSourceRequiresUnreferenceMessage)] -#endif [CLSCompliant(false)] protected unsafe void WriteEventWithRelatedActivityIdCore(int eventId, Guid* relatedActivityId, int eventDataCount, EventSource.EventData* data) { @@ -1419,12 +1357,10 @@ protected unsafe void WriteEventWithRelatedActivityIdCore(int eventId, Guid* rel /// method signature. Even if you use this for rare events, this call should be guarded by an /// check so that the varargs call is not made when the EventSource is not active. /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "requires unreferenced code, but EnsureDescriptorsInitialized does not access this member and is safe to call.")] [RequiresUnreferencedCode(EventSourceRequiresUnreferenceMessage)] -#endif protected unsafe void WriteEvent(int eventId, params object?[] args) { WriteEventVarargs(eventId, null, args); @@ -1438,12 +1374,10 @@ protected unsafe void WriteEvent(int eventId, params object?[] args) /// particular method signature. Even if you use this for rare events, this call should be guarded by an /// check so that the varargs call is not made when the EventSource is not active. /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "requires unreferenced code, but EnsureDescriptorsInitialized does not access this member and is safe to call.")] [RequiresUnreferencedCode(EventSourceRequiresUnreferenceMessage)] -#endif protected unsafe void WriteEventWithRelatedActivityId(int eventId, Guid relatedActivityId, params object?[] args) { WriteEventVarargs(eventId, &relatedActivityId, args); @@ -1642,11 +1576,9 @@ private unsafe void Initialize(Guid eventSourceGuid, string eventSourceName, str m_etwProvider = etwProvider; #if TARGET_WINDOWS -#if (!ES_BUILD_STANDALONE) // API available on OS >= Win 8 and patched Win 7. // Disable only for FrameworkEventSource to avoid recursion inside exception handling. if (this.Name != "System.Diagnostics.Eventing.FrameworkEventSource" || Environment.IsWindows8OrAbove) -#endif { var providerMetadata = ProviderMetadata; fixed (byte* pMetadata = providerMetadata) @@ -1703,18 +1635,11 @@ private static string GetName(Type eventSourceType, EventManifestOptions flags) private static Guid GenerateGuidFromName(string name) { -#if ES_BUILD_STANDALONE - namespaceBytes ??= new byte[] { - 0x48, 0x2C, 0x2D, 0xB2, 0xC3, 0x90, 0x47, 0xC8, - 0x87, 0xF8, 0x1A, 0x15, 0xBF, 0xC1, 0x30, 0xFB, - }; -#else ReadOnlySpan namespaceBytes = new byte[] // rely on C# compiler optimization to remove byte[] allocation { 0x48, 0x2C, 0x2D, 0xB2, 0xC3, 0x90, 0x47, 0xC8, 0x87, 0xF8, 0x1A, 0x15, 0xBF, 0xC1, 0x30, 0xFB, }; -#endif byte[] bytes = Encoding.BigEndianUnicode.GetBytes(name); Sha1ForNonSecretPurposes hash = default; @@ -1922,12 +1847,10 @@ private static unsafe void AssertValidString(EventData* data) return dispatcher; } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "requires unreferenced code, but EnsureDescriptorsInitialized does not access this member and is safe to call.")] [RequiresUnreferencedCode(EventSourceRequiresUnreferenceMessage)] -#endif private unsafe void WriteEventVarargs(int eventId, Guid* childActivityID, object?[] args) { if (IsEnabled()) @@ -2011,10 +1934,8 @@ private unsafe void WriteEventVarargs(int eventId, Guid* childActivityID, object #endif // FEATURE_MANAGED_ETW if (m_Dispatchers != null && metadata.EnabledForAnyListener) { -#if !ES_BUILD_STANDALONE // Maintain old behavior - object identity is preserved if (!LocalAppContextSwitches.PreserveEventListnerObjectIdentity) -#endif // !ES_BUILD_STANDALONE { args = SerializeEventArgs(eventId, args); } @@ -2037,12 +1958,10 @@ private unsafe void WriteEventVarargs(int eventId, Guid* childActivityID, object } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "requires unreferenced code, but EnsureDescriptorsInitialized does not access this member and is safe to call.")] [RequiresUnreferencedCode(EventSourceRequiresUnreferenceMessage)] -#endif private unsafe object?[] SerializeEventArgs(int eventId, object?[] args) { Debug.Assert(m_eventData != null); @@ -2198,13 +2117,11 @@ private unsafe void WriteEventString(string msgString) Level = level }; -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The call to TraceLoggingEventTypes with the below parameter values are trim safe")] [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2119", Justification = "DAM on EventSource references this compiler-generated local function which calls a " + "constructor that requires unreferenced code. EventSource will not access this local function.")] -#endif static TraceLoggingEventTypes GetTrimSafeTraceLoggingEventTypes() => new TraceLoggingEventTypes(EventName, EventTags.None, new Type[] { typeof(string) }); @@ -2499,12 +2416,10 @@ internal partial struct EventMetadata private TraceLoggingEventTypes _traceLoggingEventTypes; public TraceLoggingEventTypes TraceLoggingEventTypes { -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "requires unreferenced code, but EnsureDescriptorsInitialized does not access this member and is safe to call.")] [RequiresUnreferencedCode(EventSourceRequiresUnreferenceMessage)] -#endif get { if (_traceLoggingEventTypes is null) @@ -2850,9 +2765,7 @@ private bool AnyEventEnabled() private void EnsureDescriptorsInitialized() { -#if !ES_BUILD_STANDALONE Debug.Assert(Monitor.IsEntered(EventListener.EventListenersLock)); -#endif if (m_eventData == null) { // get the metadata via reflection. @@ -2993,17 +2906,13 @@ internal static bool IsCustomAttributeDefinedHelper( // Helper to deal with the fact that the type we are reflecting over might be loaded in the ReflectionOnly context. // When that is the case, we have the build the custom assemblies on a member by hand. -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2114:ReflectionToDynamicallyAccessedMembers", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "has dynamically accessed members requirements, but EnsureDescriptorsInitialized does not "+ "access this member and is safe to call.")] -#endif internal static Attribute? GetCustomAttributeHelper( MemberInfo member, -#if !ES_BUILD_STANDALONE [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties)] -#endif Type attributeType, EventManifestOptions flags = EventManifestOptions.None) { @@ -3120,16 +3029,12 @@ private static bool AttributeTypeNamesMatch(Type attributeType, Type reflectedAt // return the UTF8 bytes. It also sets up the code:EventData structures needed to dispatch events // at run time. 'source' is the event source to place the descriptors. If it is null, // then the descriptors are not created, and just the manifest is generated. -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2114:ReflectionToDynamicallyAccessedMembers", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "has dynamically accessed members requirements, but its use of this method satisfies " + "these requirements because it passes in the result of GetType with the same annotations.")] -#endif private static byte[]? CreateManifestAndDescriptors( -#if !ES_BUILD_STANDALONE [DynamicallyAccessedMembers(ManifestMemberTypes)] -#endif Type eventSourceType, string? eventSourceDllName, EventSource? source, @@ -3701,13 +3606,11 @@ private static void DebugCheckEvent(ref Dictionary? eventsByName /// /// The method to probe. /// The literal value or -1 if the value could not be determined. -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The method calls MethodBase.GetMethodBody. Trimming application can change IL of various methods" + "which can lead to change of behavior. This method only uses this to validate usage of event source APIs." + "In the worst case it will not be able to determine the value it's looking for and will not perform" + "any validation.")] -#endif private static int GetHelperCallFirstArg(MethodInfo method) { #if !NATIVEAOT @@ -3722,9 +3625,6 @@ private static int GetHelperCallFirstArg(MethodInfo method) // RET // // If we find this pattern we return the XXX. Otherwise we return -1. -#if ES_BUILD_STANDALONE - (new ReflectionPermission(ReflectionPermissionFlag.MemberAccess)).Assert(); -#endif byte[] instrs = method.GetMethodBody()!.GetILAsByteArray()!; int retVal = -1; for (int idx = 0; idx < instrs.Length;) @@ -3929,7 +3829,6 @@ private bool SelfDescribingEvents #if FEATURE_MANAGED_ETW_CHANNELS internal volatile ulong[]? m_channelData; #endif - // We use a single instance of ActivityTracker for all EventSources instances to allow correlation between multiple event providers. // We have m_activityTracker field simply because instance field is more efficient than static field fetch. private ActivityTracker m_activityTracker = null!; @@ -3951,13 +3850,6 @@ private bool SelfDescribingEvents internal const string DuplicateSourceNamesSwitch = "System.Diagnostics.Tracing.EventSource.AllowDuplicateSourceNames"; private static readonly bool AllowDuplicateSourceNames = AppContext.TryGetSwitch(DuplicateSourceNamesSwitch, out bool isEnabled) ? isEnabled : false; - // WARNING: Do not depend upon initialized statics during creation of EventSources, as it is possible for creation of an EventSource to trigger - // creation of yet another EventSource. When this happens, these statics may not yet be initialized. - // Rather than depending on initialized statics, use lazy initialization to ensure that the statics are initialized exactly when they are needed. -#if ES_BUILD_STANDALONE - // used for generating GUID from eventsource name - private static byte[]? namespaceBytes; -#endif #endregion } @@ -4261,16 +4153,6 @@ internal static void AddEventSource(EventSource newEventSource) { Debug.Assert(s_EventSources != null); -#if ES_BUILD_STANDALONE - // netcoreapp build calls DisposeOnShutdown directly from AppContext.OnProcessExit - if (!s_EventSourceShutdownRegistered) - { - s_EventSourceShutdownRegistered = true; - AppDomain.CurrentDomain.ProcessExit += DisposeOnShutdown; - AppDomain.CurrentDomain.DomainUnload += DisposeOnShutdown; - } -#endif - // Periodically search the list for existing entries to reuse, this avoids // unbounded memory use if we keep recycling eventSources (an unlikely thing). int newIndex = -1; @@ -4326,11 +4208,7 @@ internal static void AddEventSource(EventSource newEventSource) // such callbacks on process shutdown or appdomain so that unmanaged code will never // do this. This is what this callback is for. // See bug 724140 for more -#if ES_BUILD_STANDALONE - private static void DisposeOnShutdown(object? sender, EventArgs e) -#else internal static void DisposeOnShutdown() -#endif { Debug.Assert(EventSource.IsSupported); List sourcesToDispose = new List(); @@ -4363,9 +4241,7 @@ internal static void DisposeOnShutdown() /// private static void RemoveReferencesToListenerInEventSources(EventListener listenerToRemove) { -#if !ES_BUILD_STANDALONE Debug.Assert(Monitor.IsEntered(EventListener.EventListenersLock)); -#endif // Foreach existing EventSource in the appdomain Debug.Assert(s_EventSources != null); foreach (WeakReference eventSourceRef in s_EventSources) @@ -4589,12 +4465,6 @@ private void CallBackForExistingEventSources(bool addToListenersList, EventHandl private static bool s_ConnectingEventSourcesAndListener; #endif -#if ES_BUILD_STANDALONE - /// - /// Used to register AD/Process shutdown callbacks. - /// - private static bool s_EventSourceShutdownRegistered; -#endif #endregion } @@ -4823,11 +4693,7 @@ public long OSThreadId ref long? osThreadId = ref MoreInfo.OsThreadId; if (!osThreadId.HasValue) { -#if ES_BUILD_STANDALONE - osThreadId = (long)Interop.Kernel32.GetCurrentThreadId(); -#else osThreadId = (long)Thread.CurrentOSThreadId; -#endif } return osThreadId.Value; @@ -5395,9 +5261,7 @@ public void AddChannel(string? name, int value, EventChannelAttribute? channelAt private static EventChannelType EventChannelToChannelType(EventChannel channel) { -#if !ES_BUILD_STANDALONE Debug.Assert(channel >= EventChannel.Admin && channel <= EventChannel.Debug); -#endif return (EventChannelType)((int)channel - (int)EventChannel.Admin + (int)EventChannelType.Admin); } @@ -5610,9 +5474,7 @@ public void ManifestError(string msg, bool runtimeCritical = false) private string CreateManifestString() { -#if !ES_BUILD_STANDALONE Span ulongHexScratch = stackalloc char[16]; // long enough for ulong.MaxValue formatted as hex -#endif #if FEATURE_MANAGED_ETW_CHANNELS // Write out the channels @@ -5692,10 +5554,8 @@ private string CreateManifestString() // Write out the maps // Scoping the call to enum GetFields to a local function to limit the linker suppression -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern", Justification = "Trimmer does not trim enums")] -#endif static FieldInfo[] GetEnumFields(Type localEnumType) { Debug.Assert(localEnumType.IsEnum); @@ -5731,12 +5591,8 @@ static FieldInfo[] GetEnumFields(Type localEnumType) if (isbitmap && ((hexValue & (hexValue - 1)) != 0 || hexValue == 0)) continue; -#if ES_BUILD_STANDALONE - string hexValueFormatted = hexValue.ToString("x", CultureInfo.InvariantCulture); -#else hexValue.TryFormat(ulongHexScratch, out int charsWritten, "x"); Span hexValueFormatted = ulongHexScratch.Slice(0, charsWritten); -#endif sb.Append(" "); @@ -5779,12 +5635,8 @@ static FieldInfo[] GetEnumFields(Type localEnumType) { sb.Append(" keywordFormatted = ulongHexScratch.Slice(0, charsWritten); -#endif sb.Append(" mask=\"0x").Append(keywordFormatted).AppendLine("\"/>"); } sb.AppendLine(" "); diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSourceException.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSourceException.cs index 638bb05b9eb9b3..8127d1d7db183d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSourceException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSourceException.cs @@ -4,11 +4,7 @@ using System; using System.Runtime.Serialization; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// Exception that is thrown when an error occurs during EventSource operation. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/FrameworkEventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/FrameworkEventSource.cs index 49026d20327ad0..9e2766dc8c149a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/FrameworkEventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/FrameworkEventSource.cs @@ -10,9 +10,7 @@ namespace System.Diagnostics.Tracing [EventSourceAutoGenerate] internal sealed partial class FrameworkEventSource : EventSource { -#if !ES_BUILD_STANDALONE private const string EventSourceSuppressMessage = "Parameters to this method are primitive and are trimmer safe"; -#endif public static readonly FrameworkEventSource Log = new FrameworkEventSource(); // Keyword definitions. These represent logical groups of events that can be turned on and off independently @@ -37,10 +35,8 @@ public static class Keywords private FrameworkEventSource(int _) { } // optimized for common signatures (used by the ThreadTransferSend/Receive events) -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, long arg1, int arg2, string? arg3, bool arg4, int arg5, int arg6) { @@ -74,10 +70,8 @@ private unsafe void WriteEvent(int eventId, long arg1, int arg2, string? arg3, b } // optimized for common signatures (used by the ThreadTransferSend/Receive events) -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [NonEvent] private unsafe void WriteEvent(int eventId, long arg1, int arg2, string? arg3) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IEventProvider.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IEventProvider.cs index be1a0bca6945af..5cd30030f8f758 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IEventProvider.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IEventProvider.cs @@ -1,15 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif - -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { // Represents the interface between EventProvider and an external logging mechanism. internal interface IEventProvider diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs index 3d20263b80f4d2..426b7df495a7dd 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingEventCounter.cs @@ -1,19 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -using System.Diagnostics; -#endif - -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else using System.Diagnostics.CodeAnalysis; using System.Runtime.Versioning; namespace System.Diagnostics.Tracing -#endif { /// /// IncrementingEventCounter is a variant of EventCounter for variables that are ever-increasing. @@ -54,11 +45,9 @@ public void Increment(double increment = 1) public override string ToString() => $"IncrementingEventCounter '{Name}' Increment {_increment}"; -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The DynamicDependency will preserve the properties of IncrementingCounterPayload")] [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties, typeof(IncrementingCounterPayload))] -#endif internal override void WritePayload(float intervalSec, int pollingIntervalMillisec) { lock (this) // Lock the counter diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs index 4b209901093e21..78763d5dca64b4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/IncrementingPollingCounter.cs @@ -1,18 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif - -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else using System.Diagnostics.CodeAnalysis; using System.Runtime.Versioning; namespace System.Diagnostics.Tracing -#endif { /// /// IncrementingPollingCounter is a variant of EventCounter for variables that are ever-increasing. @@ -69,11 +61,9 @@ internal void UpdateMetric() } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The DynamicDependency will preserve the properties of IncrementingCounterPayload")] [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties, typeof(IncrementingCounterPayload))] -#endif internal override void WritePayload(float intervalSec, int pollingIntervalMillisec) { UpdateMetric(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs index e19f1f37fdb64f..0763f486cf3a1d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/PollingCounter.cs @@ -1,18 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else using System.Diagnostics.CodeAnalysis; using System.Runtime.Versioning; namespace System.Diagnostics.Tracing -#endif { /// /// PollingCounter is a variant of EventCounter - it collects and calculates similar statistics @@ -46,11 +39,9 @@ public PollingCounter(string name, EventSource eventSource, Func metricP private readonly Func _metricProvider; private double _lastVal; -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The DynamicDependency will preserve the properties of CounterPayload")] [DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties, typeof(CounterPayload))] -#endif internal override void WritePayload(float intervalSec, int pollingIntervalMillisec) { lock (this) diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ArrayTypeInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ArrayTypeInfo.cs index ed5308dbe196a1..658deeaf423222 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ArrayTypeInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ArrayTypeInfo.cs @@ -1,16 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -using System.Diagnostics; -#endif - -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { internal sealed class ArrayTypeInfo : TraceLoggingTypeInfo { diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ConcurrentSet.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ConcurrentSet.cs index a7fd4fabbd7852..f34961bab9ab25 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ConcurrentSet.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ConcurrentSet.cs @@ -1,16 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif using System.Threading; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: A very simple lock-free add-only dictionary. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ConcurrentSetItem.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ConcurrentSetItem.cs index f5ab1dd260335f..8d99539f43edda 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ConcurrentSetItem.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ConcurrentSetItem.cs @@ -1,11 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: Abstract base class that must be inherited by items in a diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/DataCollector.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/DataCollector.cs index 9c30fdd6a97886..ff07006940f4a3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/DataCollector.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/DataCollector.cs @@ -5,11 +5,7 @@ using System.Diagnostics; using System.Runtime.InteropServices; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: This is the implementation of the DataCollector diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EmptyStruct.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EmptyStruct.cs index 11b838aea89729..119ce48804107e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EmptyStruct.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EmptyStruct.cs @@ -1,11 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: Empty struct indicating no payload data. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EnumHelper.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EnumHelper.cs index b30b8cd0f30a17..cf647d3ca5f703 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EnumHelper.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EnumHelper.cs @@ -5,11 +5,7 @@ ?using System; using System.Reflection; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// Provides support for casting enums to their underlying type diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EnumerableTypeInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EnumerableTypeInfo.cs index a0e8a11058329d..95dfc59b142989 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EnumerableTypeInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EnumerableTypeInfo.cs @@ -1,18 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -using System.Diagnostics; -#endif using System.Collections; using System.Collections.Generic; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { internal sealed class EnumerableTypeInfo : TraceLoggingTypeInfo { diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventDataAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventDataAttribute.cs index 615fdef28362dc..2cf50b2b265fed 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventDataAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventDataAttribute.cs @@ -1,15 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif - -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// Used when authoring types that will be passed to EventSource.Write. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventFieldAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventFieldAttribute.cs index 64217954baf334..5987cff4ab3bf8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventFieldAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventFieldAttribute.cs @@ -1,15 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif - -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// Tags are flags that are not interpreted by EventSource but are passed along diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventFieldFormat.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventFieldFormat.cs index aaa67e96ad7e6c..4c55b58a3c10a0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventFieldFormat.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventFieldFormat.cs @@ -1,11 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// Provides a hint that may be used by an event listener when formatting diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventIgnoreAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventIgnoreAttribute.cs index 8b94a0ad79d232..74c9b6f8a81b62 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventIgnoreAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventIgnoreAttribute.cs @@ -1,15 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif - -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// Used when authoring types that will be passed to EventSource.Write. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs index 7ad51bb0caf708..552f56284864a6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs @@ -1,19 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -using System.Diagnostics; -#endif using System.Collections; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// EventPayload class holds the list of parameters and their corresponding values for user defined types passed to diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventSourceOptions.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventSourceOptions.cs index 1d0dcf4cc0348b..ec1fe8d186a5ed 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventSourceOptions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventSourceOptions.cs @@ -1,15 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif - -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// Used when calling EventSource.Write. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/FieldMetadata.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/FieldMetadata.cs index 776dc1ca652ac6..eae652c0cdd4cd 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/FieldMetadata.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/FieldMetadata.cs @@ -5,11 +5,7 @@ using System.Diagnostics; using System.Text; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: Contains the information needed to generate tracelogging diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/InvokeTypeInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/InvokeTypeInfo.cs index 1fc44ac48917c2..49f12489d1e6dc 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/InvokeTypeInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/InvokeTypeInfo.cs @@ -1,16 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif using System.Collections.Generic; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: An implementation of TraceLoggingTypeInfo that works diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/NameInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/NameInfo.cs index 201e878f68b0be..8b61c04cb9ee5f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/NameInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/NameInfo.cs @@ -1,17 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif using System.Collections.Generic; using System.Threading; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: Stores the metadata and event identifier corresponding diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/PropertyAnalysis.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/PropertyAnalysis.cs index 55554d113be051..e1faecf1e798a8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/PropertyAnalysis.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/PropertyAnalysis.cs @@ -1,16 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif using System.Reflection; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: stores the per-property information obtained by diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs index d621a371279492..5b5f9c77b1ff53 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs @@ -1,19 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -using System.Diagnostics; -#endif using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.InteropServices; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// Holds property values of any type. For common value types, we have inline storage so that we don't need @@ -202,10 +194,8 @@ private static Func GetBoxedValueTypePropertyGette /// /// /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("AotAnalysis", "IL3050:AotUnfriendlyApi", Justification = "Instantiation over a reference type. See comments above.")] -#endif private static Func GetReferenceTypePropertyGetter(PropertyInfo property) { var helper = (TypeHelper)Activator.CreateInstance(typeof(ReferenceTypeHelper<>).MakeGenericType(property.DeclaringType!))!; @@ -221,10 +211,8 @@ abstract class TypeHelper { public abstract Func GetPropertyGetter(PropertyInfo property); -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("AotAnalysis", "IL3050:AotUnfriendlyApi", Justification = "Instantiation over a reference type. See comments above.")] -#endif protected static Delegate GetGetMethod(PropertyInfo property, Type propertyType) { return property.GetMethod!.CreateDelegate(typeof(Func<,>).MakeGenericType(property.DeclaringType!, propertyType)); @@ -239,11 +227,7 @@ protected static Delegate GetGetMethod(PropertyInfo property, Type propertyType) sealed class ReferenceTypeHelper : TypeHelper where TContainer : class { private static Func GetGetMethod(PropertyInfo property) where TProperty : struct => -#if ES_BUILD_STANDALONE - (Func)property.GetMethod!.CreateDelegate(typeof(Func)); -#else property.GetMethod!.CreateDelegate>(); -#endif public override Func GetPropertyGetter(PropertyInfo property) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/SimpleEventTypes.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/SimpleEventTypes.cs index 4a90f83287d750..f6db3a6f4619eb 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/SimpleEventTypes.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/SimpleEventTypes.cs @@ -1,17 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -using System.Diagnostics; -#endif using System.Threading; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: Contains the metadata needed to emit an event, optimized @@ -27,15 +19,11 @@ internal static class SimpleEventTypes public static TraceLoggingEventTypes Instance { -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EventSource WriteEvent will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. This can be suppressed if the object is a primitive type")] -#endif get { return instance ??= InitInstance(); } } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EventSource WriteEvent will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. This can be suppressed if the object is a primitive type")] -#endif private static TraceLoggingEventTypes InitInstance() { var info = TraceLoggingTypeInfo.GetInstance(typeof(T), null); diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs index 0396063927dab7..5e2482a2357edb 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs @@ -1,21 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -using System.Diagnostics; -using System.Runtime.Serialization; -#endif using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Runtime.CompilerServices; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: Type handler for empty or unsupported types. @@ -320,9 +311,7 @@ internal sealed class NullableTypeInfo : TraceLoggingTypeInfo { private readonly TraceLoggingTypeInfo valueInfo; -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EventSource WriteEvent will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. This can be suppressed if the object is a primitive type")] -#endif public NullableTypeInfo(Type type, List recursionCheck) : base(type) { @@ -341,10 +330,8 @@ public override void WriteMetadata( this.valueInfo.WriteMetadata(group, "Value", format); } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2072:UnrecognizedReflectionPattern", Justification = "The underlying type of Nullable must be defaultable")] -#endif public override void WriteData(PropertyValue value) { object? refVal = value.ReferenceValue; @@ -352,11 +339,7 @@ public override void WriteData(PropertyValue value) TraceLoggingDataCollector.AddScalar(hasValue); PropertyValue val = valueInfo.PropertyValueFactory(hasValue ? refVal -#if ES_BUILD_STANDALONE - : FormatterServices.GetUninitializedObject(valueInfo.DataType)); - #else : RuntimeHelpers.GetUninitializedObject(valueInfo.DataType)); - #endif this.valueInfo.WriteData(val); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/Statics.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/Statics.cs index 68b350ce5b415e..e1780509851900 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/Statics.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/Statics.cs @@ -7,11 +7,7 @@ using System.Runtime.CompilerServices; using System.Text; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: Constants and utility functions. @@ -359,9 +355,7 @@ public static bool HasCustomAttribute( } public static Type? FindEnumerableElementType( -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.Interfaces)] -#endif Type type) { Type? elementType = null; @@ -395,9 +389,7 @@ public static bool IsGenericMatch(Type type, object? openType) return type.IsGenericType && type.GetGenericTypeDefinition() == (Type?)openType; } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EventSource WriteEvent will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. This can be suppressed if the object is a primitive type")] -#endif public static TraceLoggingTypeInfo CreateDefaultTypeInfo( Type dataType, List recursionCheck) diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingDataCollector.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingDataCollector.cs index 27428ce9bd69c4..6aa6dc6a689d7b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingDataCollector.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingDataCollector.cs @@ -1,15 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: Used when implementing a custom TraceLoggingTypeInfo. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingDataType.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingDataType.cs index afbb674acfe06b..1bc35cc6d12329 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingDataType.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingDataType.cs @@ -1,15 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif - -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: Used when implementing a custom TraceLoggingTypeInfo. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs index 633cde3195b77e..7058b0a25b4d5f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs @@ -8,11 +8,6 @@ #define FEATURE_MANAGED_ETW #endif // TARGET_WINDOWS -#if ES_BUILD_STANDALONE -#define FEATURE_MANAGED_ETW_CHANNELS -// #define FEATURE_ADVANCED_MANAGED_ETW_CHANNELS -#endif - using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -21,26 +16,17 @@ using System.Runtime.InteropServices; using System.Text; -#if ES_BUILD_STANDALONE -using System.Runtime.CompilerServices; -namespace Microsoft.Diagnostics.Tracing -#else using System.Runtime.CompilerServices; namespace System.Diagnostics.Tracing -#endif { public partial class EventSource { #if FEATURE_MANAGED_ETW private byte[]? m_providerMetadata; -#if ES_BUILD_STANDALONE - private byte[] ProviderMetadata => m_providerMetadata ?? Array.Empty(); -#else private protected virtual ReadOnlySpan ProviderMetadata => m_providerMetadata; private const string EventSourceRequiresUnreferenceMessage = "EventSource will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. This can be suppressed if the object is a primitive type"; private const string EventSourceSuppressMessage = "Parameters to this method are primitive and are trimmer safe"; #endif -#endif #if FEATURE_PERFTRACING private readonly TraceLoggingEventHandleTable m_eventHandleTable = null!; @@ -101,10 +87,8 @@ public EventSource( /// (Native API: EventWriteTransfer) /// /// The name of the event. -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif public unsafe void Write(string? eventName) { if (!this.IsEnabled()) @@ -125,10 +109,8 @@ public unsafe void Write(string? eventName) /// Options for the event, such as the level, keywords, and opcode. Unset /// options will be set to default values. /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif public unsafe void Write(string? eventName, EventSourceOptions options) { if (!this.IsEnabled()) @@ -158,15 +140,11 @@ public unsafe void Write(string? eventName, EventSourceOptions options) /// public instance properties of data will be written recursively to /// create the fields of the event. /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "requires unreferenced code, but EnsureDescriptorsInitialized does not access this member and is safe to call.")] [RequiresUnreferencedCode(EventSourceRequiresUnreferenceMessage)] public unsafe void Write<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>( -#else - public unsafe void Write( -#endif string? eventName, T data) { @@ -202,15 +180,11 @@ public unsafe void Write( /// public instance properties of data will be written recursively to /// create the fields of the event. /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "requires unreferenced code, but EnsureDescriptorsInitialized does not access this member and is safe to call.")] [RequiresUnreferencedCode(EventSourceRequiresUnreferenceMessage)] public unsafe void Write<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>( -#else - public unsafe void Write( -#endif string? eventName, EventSourceOptions options, T data) @@ -248,15 +222,11 @@ public unsafe void Write( /// public instance properties of data will be written recursively to /// create the fields of the event. /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "requires unreferenced code, but EnsureDescriptorsInitialized does not access this member and is safe to call.")] [RequiresUnreferencedCode(EventSourceRequiresUnreferenceMessage)] public unsafe void Write<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>( -#else - public unsafe void Write( -#endif string? eventName, ref EventSourceOptions options, ref T data) @@ -301,15 +271,11 @@ public unsafe void Write( /// public instance properties of data will be written recursively to /// create the fields of the event. /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2112:ReflectionToRequiresUnreferencedCode", Justification = "EnsureDescriptorsInitialized's use of GetType preserves this method which " + "requires unreferenced code, but EnsureDescriptorsInitialized does not access this member and is safe to call.")] [RequiresUnreferencedCode(EventSourceRequiresUnreferenceMessage)] public unsafe void Write<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>( -#else - public unsafe void Write( -#endif string? eventName, ref EventSourceOptions options, ref Guid activityId, @@ -483,9 +449,6 @@ private unsafe void WriteMultiMergeInner( descriptors[1].SetMetadata(pMetadata1, nameInfo.nameMetadata.Length, 1); descriptors[2].SetMetadata(pMetadata2, eventTypes.typeMetadata.Length, 1); -#if ES_BUILD_STANDALONE - System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions(); -#endif try { DataCollector.ThreadInstance.Enable( @@ -669,9 +632,6 @@ private unsafe void WriteImpl( descriptors[2].SetMetadata(pMetadata2, eventTypes.typeMetadata.Length, 1); #endif // FEATURE_MANAGED_ETW -#if ES_BUILD_STANDALONE - System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions(); -#endif EventOpcode opcode = (EventOpcode)descriptor.Opcode; Guid activityId = Guid.Empty; @@ -772,11 +732,6 @@ private unsafe void WriteToAllListeners(string? eventName, ref EventDescriptor e DispatchToAllListeners(eventCallbackArgs); } -#if ES_BUILD_STANDALONE - [System.Runtime.ConstrainedExecution.ReliabilityContract( - System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, - System.Runtime.ConstrainedExecution.Cer.Success)] -#endif [NonEvent] private static unsafe void WriteCleanup(GCHandle* pPins, int cPins) { @@ -795,7 +750,7 @@ private void InitializeProviderMetadata() { #if FEATURE_MANAGED_ETW bool hasProviderMetadata = ProviderMetadata.Length > 0; -#if !DEBUG && !ES_BUILD_STANDALONE +#if !DEBUG if (hasProviderMetadata) { // Already set @@ -845,7 +800,7 @@ private void InitializeProviderMetadata() m_providerMetadata = Statics.MetadataForString(this.Name, 0, 0, 0); } -#if DEBUG && !ES_BUILD_STANDALONE +#if DEBUG if (hasProviderMetadata) { // Validate the provided ProviderMetadata still matches in debug diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTraits.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTraits.cs index c7d8a89e1cad1f..584665c0ed4e13 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTraits.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTraits.cs @@ -1,15 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif - -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// Tags are flags that are not interpreted by EventSource but are passed along diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTypes.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTypes.cs index 61a819a0c9bc86..9c1857fdef9266 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTypes.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTypes.cs @@ -1,16 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif using System.Collections.Generic; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: Used when calling EventSource.WriteMultiMerge. @@ -48,9 +41,7 @@ public class TraceLoggingEventTypes /// /// The types of the fields in the event. This value must not be null. /// -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EventSource WriteEvent will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. This can be suppressed if the object is a primitive type")] -#endif internal TraceLoggingEventTypes( string name, EventTags tags, @@ -85,9 +76,7 @@ internal TraceLoggingEventTypes( { } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EventSource WriteEvent will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. This can be suppressed if the object is a primitive type")] -#endif internal TraceLoggingEventTypes( string name, EventTags tags, @@ -186,9 +175,7 @@ internal NameInfo GetNameInfo(string name, EventTags tags) => this.nameInfos.TryGet(new KeyValuePair(name, tags)) ?? this.nameInfos.GetOrAdd(new NameInfo(name, tags, this.typeMetadata.Length)); -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EventSource WriteEvent will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. This can be suppressed if the object is a primitive type")] -#endif private static TraceLoggingTypeInfo[] MakeArray(System.Reflection.ParameterInfo[] paramInfos) { if (paramInfos is null) @@ -206,9 +193,7 @@ private static TraceLoggingTypeInfo[] MakeArray(System.Reflection.ParameterInfo[ return result; } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EventSource WriteEvent will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. This can be suppressed if the object is a primitive type")] -#endif private static TraceLoggingTypeInfo[] MakeArray(Type[] types) { if (types is null) diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingMetadataCollector.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingMetadataCollector.cs index 5f78812a53453a..7ff2a1793c8fd1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingMetadataCollector.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingMetadataCollector.cs @@ -4,11 +4,7 @@ using System; using System.Collections.Generic; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: used when implementing a custom TraceLoggingTypeInfo. diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingTypeInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingTypeInfo.cs index 7dc243a62e2d51..505f694845469f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingTypeInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingTypeInfo.cs @@ -1,16 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif using System.Collections.Generic; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: used when implementing a custom TraceLoggingTypeInfo. @@ -152,9 +145,7 @@ public abstract void WriteMetadata( [ThreadStatic] // per-thread cache to avoid synchronization private static Dictionary? threadCache; -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EventSource WriteEvent will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. This can be suppressed if the object is a primitive type")] -#endif public static TraceLoggingTypeInfo GetInstance(Type type, List? recursionCheck) { Dictionary cache = threadCache ??= new Dictionary(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TypeAnalysis.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TypeAnalysis.cs index 051eef8ac07d72..31c2a53aff12ee 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TypeAnalysis.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TypeAnalysis.cs @@ -1,18 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if ES_BUILD_STANDALONE -using System; -#endif using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Reflection; -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// TraceLogging: stores the per-type information obtained by reflecting over a type. @@ -26,9 +19,7 @@ internal sealed class TypeAnalysis internal readonly EventOpcode opcode = (EventOpcode)(-1); internal readonly EventTags tags; -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EventSource WriteEvent will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. This can be suppressed if the object is a primitive type")] -#endif public TypeAnalysis( Type dataType, EventDataAttribute? eventAttrib, diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/Winmeta.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/Winmeta.cs index 23e644f15543ca..52e3e3af4b3708 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/Winmeta.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/Winmeta.cs @@ -10,16 +10,7 @@ ** ============================================================*/ -#if ES_BUILD_STANDALONE -#define FEATURE_MANAGED_ETW_CHANNELS -using System; -#endif - -#if ES_BUILD_STANDALONE -namespace Microsoft.Diagnostics.Tracing -#else namespace System.Diagnostics.Tracing -#endif { /// /// WindowsEventLevel. Custom values must be in the range from 16 through 255 diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs index 0031309ec3521a..9b26335ddabca8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/NativeRuntimeEventSource.PortableThreadPool.cs @@ -18,9 +18,7 @@ public static class Keywords public const EventKeywords ThreadTransferKeyword = (EventKeywords)0x80000000; } -#if !ES_BUILD_STANDALONE private const string EventSourceSuppressMessage = "Parameters to this method are primitive and are trimmer safe"; -#endif // This value does not seem to be used, leaving it as zero for now. It may be useful for a scenario that may involve // multiple instances of the runtime within the same process, but then it seems unlikely that both instances' thread // pools would be in moderate use. @@ -72,10 +70,8 @@ public enum ThreadAdjustmentReasonMap : uint CooperativeBlocking, } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [NonEvent] private unsafe void WriteThreadEvent(int eventId, uint numExistingThreads) { @@ -132,10 +128,8 @@ public void ThreadPoolWorkerThreadWait( } } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(54, Level = EventLevel.Informational, Message = Messages.WorkerThreadAdjustmentSample, Task = Tasks.ThreadPoolWorkerThreadAdjustment, Opcode = Opcodes.Sample, Version = 0, Keywords = Keywords.ThreadingKeyword)] public unsafe void ThreadPoolWorkerThreadAdjustmentSample( double Throughput, @@ -155,10 +149,8 @@ public unsafe void ThreadPoolWorkerThreadAdjustmentSample( WriteEventCore(54, 2, data); } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(55, Level = EventLevel.Informational, Message = Messages.WorkerThreadAdjustmentAdjustment, Task = Tasks.ThreadPoolWorkerThreadAdjustment, Opcode = Opcodes.Adjustment, Version = 0, Keywords = Keywords.ThreadingKeyword)] public unsafe void ThreadPoolWorkerThreadAdjustmentAdjustment( double AverageThroughput, @@ -186,10 +178,8 @@ public unsafe void ThreadPoolWorkerThreadAdjustmentAdjustment( WriteEventCore(55, 4, data); } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(56, Level = EventLevel.Verbose, Message = Messages.WorkerThreadAdjustmentStats, Task = Tasks.ThreadPoolWorkerThreadAdjustment, Opcode = Opcodes.Stats, Version = 0, Keywords = Keywords.ThreadingKeyword)] public unsafe void ThreadPoolWorkerThreadAdjustmentStats( double Duration, @@ -245,10 +235,8 @@ public unsafe void ThreadPoolWorkerThreadAdjustmentStats( WriteEventCore(56, 11, data); } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(63, Level = EventLevel.Verbose, Message = Messages.IOEnqueue, Task = Tasks.ThreadPool, Opcode = Opcodes.IOEnqueue, Version = 0, Keywords = Keywords.ThreadingKeyword | Keywords.ThreadTransferKeyword)] private unsafe void ThreadPoolIOEnqueue( IntPtr NativeOverlapped, @@ -298,10 +286,8 @@ public void ThreadPoolIOEnqueue(RegisteredWaitHandle registeredWaitHandle) } } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(64, Level = EventLevel.Verbose, Message = Messages.IO, Task = Tasks.ThreadPool, Opcode = Opcodes.IODequeue, Version = 0, Keywords = Keywords.ThreadingKeyword | Keywords.ThreadTransferKeyword)] private unsafe void ThreadPoolIODequeue( IntPtr NativeOverlapped, @@ -345,10 +331,8 @@ public void ThreadPoolIODequeue(RegisteredWaitHandle registeredWaitHandle) } } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(60, Level = EventLevel.Verbose, Message = Messages.WorkingThreadCount, Task = Tasks.ThreadPoolWorkingThreadCount, Opcode = EventOpcode.Start, Version = 0, Keywords = Keywords.ThreadingKeyword)] public unsafe void ThreadPoolWorkingThreadCount(uint Count, ushort ClrInstanceID = DefaultClrInstanceId) { @@ -378,10 +362,8 @@ public unsafe void ThreadPoolIOPack(NativeOverlapped* nativeOverlapped) } } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(65, Level = EventLevel.Verbose, Message = Messages.IO, Task = Tasks.ThreadPool, Opcode = Opcodes.IOPack, Version = 0, Keywords = Keywords.ThreadingKeyword)] private unsafe void ThreadPoolIOPack( IntPtr NativeOverlapped, @@ -402,10 +384,8 @@ private unsafe void ThreadPoolIOPack( } -#if !ES_BUILD_STANDALONE [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(59, Level = EventLevel.Informational, Message = Messages.MinMaxThreads, Task = Tasks.ThreadPoolMinMaxThreads, Opcode = EventOpcode.Info, Version = 0, Keywords = Keywords.ThreadingKeyword)] public unsafe void ThreadPoolMinMaxThreads( ushort MinWorkerThreads, diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TplEventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TplEventSource.cs index d6242062b8d5e2..0a7b09eae131cf 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TplEventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TplEventSource.cs @@ -21,9 +21,7 @@ namespace System.Threading.Tasks [EventSourceAutoGenerate] internal sealed partial class TplEventSource : EventSource { -#if !ES_BUILD_STANDALONE private const string EventSourceSuppressMessage = "Parameters to this method are primitive and are trimmer safe"; -#endif /// Used to determine if tasks should generate Activity IDs for themselves internal bool TasksSetActivityIds; // This keyword is set internal bool Debug; @@ -192,10 +190,8 @@ public enum TaskWaitBehavior : int /// The task ID /// The options used to create the task. /// The ID for the current AppDomain. -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(TASKSCHEDULED_ID, Task = Tasks.TaskScheduled, Version = 1, Opcode = EventOpcode.Send, Level = EventLevel.Informational, Keywords = Keywords.TaskTransfer | Keywords.Tasks)] public void TaskScheduled( @@ -264,10 +260,8 @@ public void TaskStarted( /// The task ID. /// The task ID. /// Whether the task completed due to an error. -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(TASKCOMPLETED_ID, Version = 1, Level = EventLevel.Informational, Keywords = Keywords.TaskStops)] public void TaskCompleted( @@ -310,10 +304,8 @@ public void TaskCompleted( /// If known, if 'TaskID' has a 'continueWith' task, mention give its ID here. /// 0 means unknown. This allows better visualization of the common sequential chaining case. /// -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(TASKWAITBEGIN_ID, Version = 3, Task = TplEventSource.Tasks.TaskWait, Opcode = EventOpcode.Send, Level = EventLevel.Informational, Keywords = Keywords.TaskTransfer | Keywords.Tasks)] public void TaskWaitBegin( @@ -403,10 +395,8 @@ public void TaskWaitContinuationStarted(int TaskID) /// The scheduler ID. /// The task ID. /// The ID of the continuation object. -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(AWAITTASKCONTINUATIONSCHEDULED_ID, Task = Tasks.AwaitTaskContinuationScheduled, Opcode = EventOpcode.Send, Level = EventLevel.Informational, Keywords = Keywords.TaskTransfer | Keywords.Tasks)] public void AwaitTaskContinuationScheduled( @@ -438,10 +428,8 @@ public void AwaitTaskContinuationScheduled( } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(TRACEOPERATIONSTART_ID, Version = 1, Level = EventLevel.Informational, Keywords = Keywords.AsyncCausalityOperation)] public void TraceOperationBegin(int TaskID, string OperationName, long RelatedContext) @@ -494,10 +482,8 @@ public void TraceSynchronousWorkBegin(int TaskID, CausalitySynchronousWork Work) WriteEvent(TRACESYNCHRONOUSWORKSTART_ID, TaskID, (int)Work); // optimized overload for this exists } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(TRACESYNCHRONOUSWORKSTOP_ID, Version = 1, Level = EventLevel.Informational, Keywords = Keywords.AsyncCausalitySynchronousWork)] public void TraceSynchronousWorkEnd(CausalitySynchronousWork Work) diff --git a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/DataflowEtwProvider.cs b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/DataflowEtwProvider.cs index 895aa05c20712d..f36786a7d5d606 100644 --- a/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/DataflowEtwProvider.cs +++ b/src/libraries/System.Threading.Tasks.Dataflow/src/Internal/DataflowEtwProvider.cs @@ -102,10 +102,8 @@ internal void TaskLaunchedForMessageHandling( } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "WriteEvent Parameters are trimmer safe")] -#endif [Event(TASKLAUNCHED_EVENTID, Level = EventLevel.Informational)] private void TaskLaunchedForMessageHandling(int blockId, TaskLaunchedReason reason, int availableMessages, int taskId) { @@ -161,10 +159,8 @@ internal enum BlockCompletionReason Canceled = (int)TaskStatus.Canceled } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "WriteEvent Parameters are trimmer safe")] -#endif [Event(BLOCKCOMPLETED_EVENTID, Level = EventLevel.Informational)] private void DataflowBlockCompleted(int blockId, BlockCompletionReason reason, string exceptionData) { diff --git a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/ParallelETWProvider.cs b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/ParallelETWProvider.cs index fd27aa9a7c6195..a4c62f7a972eaa 100644 --- a/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/ParallelETWProvider.cs +++ b/src/libraries/System.Threading.Tasks.Parallel/src/System/Threading/Tasks/ParallelETWProvider.cs @@ -20,9 +20,7 @@ namespace System.Threading.Tasks [EventSource(Name = "System.Threading.Tasks.Parallel.EventSource")] internal sealed class ParallelEtwProvider : EventSource { -#if !ES_BUILD_STANDALONE private const string EventSourceSuppressMessage = "Parameters to this method are primitive and are trimmer safe"; -#endif /// /// Defines the singleton instance for the Task.Parallel ETW provider. /// @@ -101,10 +99,8 @@ public static class Tasks /// The kind of fork/join operation. /// The lower bound of the loop. /// The upper bound of the loop. -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(PARALLELLOOPBEGIN_ID, Level = EventLevel.Informational, Task = ParallelEtwProvider.Tasks.Loop, Opcode = EventOpcode.Start)] public void ParallelLoopBegin(int OriginatingTaskSchedulerID, int OriginatingTaskID, // PFX_COMMON_EVENT_HEADER int ForkJoinContextID, ForkJoinOperationType OperationType, // PFX_FORKJOIN_COMMON_EVENT_HEADER @@ -165,10 +161,8 @@ public void ParallelLoopBegin(int OriginatingTaskSchedulerID, int OriginatingTas /// The task ID. /// The loop ID. /// the total number of iterations processed. -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(PARALLELLOOPEND_ID, Level = EventLevel.Informational, Task = ParallelEtwProvider.Tasks.Loop, Opcode = EventOpcode.Stop)] public void ParallelLoopEnd(int OriginatingTaskSchedulerID, int OriginatingTaskID, // PFX_COMMON_EVENT_HEADER int ForkJoinContextID, long TotalIterations) @@ -216,10 +210,8 @@ public void ParallelLoopEnd(int OriginatingTaskSchedulerID, int OriginatingTaskI /// The invoke ID. /// The kind of fork/join operation. /// The number of actions being invoked. -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = EventSourceSuppressMessage)] -#endif [Event(PARALLELINVOKEBEGIN_ID, Level = EventLevel.Informational, Task = ParallelEtwProvider.Tasks.Invoke, Opcode = EventOpcode.Start)] public void ParallelInvokeBegin(int OriginatingTaskSchedulerID, int OriginatingTaskID, // PFX_COMMON_EVENT_HEADER int ForkJoinContextID, ForkJoinOperationType OperationType, // PFX_FORKJOIN_COMMON_EVENT_HEADER diff --git a/src/libraries/System.Threading/src/System/Threading/CDSsyncETWBCLProvider.cs b/src/libraries/System.Threading/src/System/Threading/CDSsyncETWBCLProvider.cs index 149839f8a50388..92e1cbd0969a2b 100644 --- a/src/libraries/System.Threading/src/System/Threading/CDSsyncETWBCLProvider.cs +++ b/src/libraries/System.Threading/src/System/Threading/CDSsyncETWBCLProvider.cs @@ -57,10 +57,8 @@ private CdsSyncEtwBCLProvider() { } // Barrier Events // -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")] -#endif [Event(BARRIER_PHASEFINISHED_ID, Level = EventLevel.Verbose, Version = 1)] public void Barrier_PhaseFinished(bool currentSense, long phaseNum) { diff --git a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionsEtwProvider.cs b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionsEtwProvider.cs index 1aa565fbb2a78c..f6fd5f6b87e2d7 100644 --- a/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionsEtwProvider.cs +++ b/src/libraries/System.Transactions.Local/src/System/Transactions/TransactionsEtwProvider.cs @@ -839,10 +839,8 @@ internal void TransactionScopeCreated(TransactionTraceIdentifier transactionID, } } -#if !ES_BUILD_STANDALONE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "TransactionScopeResult parameter is an enum and is trimmer safe")] -#endif [Event(TRANSACTIONSCOPE_CREATED_EVENTID, Keywords = Keywords.TraceBase, Level = EventLevel.Informational, Task = Tasks.TransactionScope, Opcode = Opcodes.Created, Message = "Transactionscope was created: Transaction ID is {0}, TransactionScope Result is {1}")] private void TransactionScopeCreated(string transactionID, TransactionScopeResult transactionScopeResult) {