From a977aedcc906a4d8622da25ce6df1a017c0aeb78 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Sun, 5 Oct 2025 14:33:54 +0200 Subject: [PATCH 1/9] Avoid custom attribute routine in NetEventSource --- .../src/System/Net/Http/NetEventSource.WinHttpHandler.cs | 9 +++++++-- .../src/System/Net/Http/NetEventSource.Http.cs | 6 +++++- .../src/System/Net/NetEventSource.HttpListener.cs | 9 +++++++-- .../src/System/Net/Mail/NetEventSource.Mail.cs | 9 +++++++-- .../src/System/Net/NetEventSource.NameResolution.cs | 9 +++++++-- .../NetEventSource.NetworkInformation.cs | 6 +++++- .../src/System/Net/NetEventSource.Primitives.cs | 9 +++++++-- .../src/System/Net/Quic/NetEventSource.Quic.cs | 6 +++++- .../src/System/Net/NetEventSource.Requests.cs | 9 +++++++-- .../src/System/Net/Security/NetEventSource.Security.cs | 6 +++++- .../src/System/Net/Sockets/NetEventSource.Sockets.cs | 6 +++++- .../System/Net/WebSockets/NetEventSource.WebSockets.cs | 6 +++++- 12 files changed, 72 insertions(+), 18 deletions(-) diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs index 6095be9edfc587..3ebd0a7422ebf1 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs @@ -5,6 +5,11 @@ namespace System.Net { - [EventSource(Name = "Private.InternalDiagnostics.System.Net.Http.WinHttpHandler")] - internal sealed partial class NetEventSource { } + [EventSource(Name = NetEventSourceName)] + internal sealed partial class NetEventSource + { + private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Http.WinHttpHandler"; + + public NetEventSource() : base(NetEventSourceName) { } + } } 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 95c5af48e6c12a..f1eb16fe020594 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 @@ -7,9 +7,13 @@ namespace System.Net { - [EventSource(Name = "Private.InternalDiagnostics.System.Net.Http")] + [EventSource(Name = NetEventSourceName)] internal sealed partial class NetEventSource { + private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Http"; + + public NetEventSource() : base(NetEventSourceName) { } + private const int UriBaseAddressId = NextAvailableEventId; private const int ContentNullId = UriBaseAddressId + 1; private const int HeadersInvalidValueId = ContentNullId + 1; diff --git a/src/libraries/System.Net.HttpListener/src/System/Net/NetEventSource.HttpListener.cs b/src/libraries/System.Net.HttpListener/src/System/Net/NetEventSource.HttpListener.cs index 386023a036a930..a40d46946c9c7c 100644 --- a/src/libraries/System.Net.HttpListener/src/System/Net/NetEventSource.HttpListener.cs +++ b/src/libraries/System.Net.HttpListener/src/System/Net/NetEventSource.HttpListener.cs @@ -5,6 +5,11 @@ namespace System.Net { - [EventSource(Name = "Private.InternalDiagnostics.System.Net.HttpListener")] - internal sealed partial class NetEventSource { } + [EventSource(Name = NetEventSourceName)] + internal sealed partial class NetEventSource + { + private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.HttpListener"; + + public NetEventSource() : base(NetEventSourceName) { } + } } diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/NetEventSource.Mail.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/NetEventSource.Mail.cs index 6f0b111c9a13bc..e8993fd50c57a2 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/NetEventSource.Mail.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/NetEventSource.Mail.cs @@ -7,6 +7,11 @@ namespace System.Net { - [EventSource(Name = "Private.InternalDiagnostics.System.Net.Mail")] - internal sealed partial class NetEventSource { } + [EventSource(Name = NetEventSourceName)] + internal sealed partial class NetEventSource + { + private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Mail"; + + public NetEventSource() : base(NetEventSourceName) { } + } } diff --git a/src/libraries/System.Net.NameResolution/src/System/Net/NetEventSource.NameResolution.cs b/src/libraries/System.Net.NameResolution/src/System/Net/NetEventSource.NameResolution.cs index f8a323e4ad8a32..3792aff4a9bec6 100644 --- a/src/libraries/System.Net.NameResolution/src/System/Net/NetEventSource.NameResolution.cs +++ b/src/libraries/System.Net.NameResolution/src/System/Net/NetEventSource.NameResolution.cs @@ -5,6 +5,11 @@ namespace System.Net { - [EventSource(Name = "Private.InternalDiagnostics.System.Net.NameResolution")] - internal sealed partial class NetEventSource { } + [EventSource(Name = NetEventSourceName)] + internal sealed partial class NetEventSource + { + private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.NameResolution"; + + public NetEventSource() : base(NetEventSourceName) { } + } } diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetEventSource.NetworkInformation.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetEventSource.NetworkInformation.cs index 87a07eb1cdd2a0..7c1fc78c3e16bb 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetEventSource.NetworkInformation.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetEventSource.NetworkInformation.cs @@ -7,9 +7,13 @@ namespace System.Net { - [EventSource(Name = "Private.InternalDiagnostics.System.Net.NetworkInformation")] + [EventSource(Name = NetEventSourceName)] internal sealed class NetEventSource : EventSource { + private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.NetworkInformation"; + + public NetEventSource() : base(NetEventSourceName) { } + public static readonly NetEventSource Log = new NetEventSource(); private const int ErrorEventId = 2; diff --git a/src/libraries/System.Net.Primitives/src/System/Net/NetEventSource.Primitives.cs b/src/libraries/System.Net.Primitives/src/System/Net/NetEventSource.Primitives.cs index 1d79653d1daaf6..c946f540c6a747 100644 --- a/src/libraries/System.Net.Primitives/src/System/Net/NetEventSource.Primitives.cs +++ b/src/libraries/System.Net.Primitives/src/System/Net/NetEventSource.Primitives.cs @@ -5,6 +5,11 @@ namespace System.Net { - [EventSource(Name = "Private.InternalDiagnostics.System.Net.Primitives")] - internal sealed partial class NetEventSource { } + [EventSource(Name = NetEventSourceName)] + internal sealed partial class NetEventSource + { + private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Primitives"; + + public NetEventSource() : base(NetEventSourceName) { } + } } diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/NetEventSource.Quic.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/NetEventSource.Quic.cs index 37dbeab080837c..d7f9fadbc9d0d6 100644 --- a/src/libraries/System.Net.Quic/src/System/Net/Quic/NetEventSource.Quic.cs +++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/NetEventSource.Quic.cs @@ -6,9 +6,13 @@ namespace System.Net { - [EventSource(Name = "Private.InternalDiagnostics.System.Net.Quic")] + [EventSource(Name = NetEventSourceName)] internal sealed partial class NetEventSource { + private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Quic"; + + public NetEventSource() : base(NetEventSourceName) { } + static partial void AdditionalCustomizedToString(object value, ref string? result) { if (value is MsQuicSafeHandle safeHandle) diff --git a/src/libraries/System.Net.Requests/src/System/Net/NetEventSource.Requests.cs b/src/libraries/System.Net.Requests/src/System/Net/NetEventSource.Requests.cs index 5bfc9d8c456ca9..231e330b74a4cc 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/NetEventSource.Requests.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/NetEventSource.Requests.cs @@ -5,6 +5,11 @@ namespace System.Net { - [EventSource(Name = "Private.InternalDiagnostics.System.Net.Requests")] - internal sealed partial class NetEventSource { } + [EventSource(Name = NetEventSourceName)] + internal sealed partial class NetEventSource + { + private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Requests"; + + public NetEventSource() : base(NetEventSourceName) { } + } } diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/NetEventSource.Security.cs b/src/libraries/System.Net.Security/src/System/Net/Security/NetEventSource.Security.cs index 5ca0be27a35723..6310ec6c51d95d 100644 --- a/src/libraries/System.Net.Security/src/System/Net/Security/NetEventSource.Security.cs +++ b/src/libraries/System.Net.Security/src/System/Net/Security/NetEventSource.Security.cs @@ -11,9 +11,13 @@ namespace System.Net { - [EventSource(Name = "Private.InternalDiagnostics.System.Net.Security")] + [EventSource(Name = NetEventSourceName)] internal sealed partial class NetEventSource { + private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Security"; + + public NetEventSource() : base(NetEventSourceName) { } + #if WINDOWS // More events are defined in NetEventSource.Security.Windows.cs private const int LocatingPrivateKeyId = OperationReturnedSomethingId + 1; diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetEventSource.Sockets.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetEventSource.Sockets.cs index ed5460ffcb7c94..fc8644f4097194 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetEventSource.Sockets.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetEventSource.Sockets.cs @@ -7,9 +7,13 @@ namespace System.Net { - [EventSource(Name = "Private.InternalDiagnostics.System.Net.Sockets")] + [EventSource(Name = NetEventSourceName)] internal sealed partial class NetEventSource { + private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Sockets"; + + public NetEventSource() : base(NetEventSourceName) { } + private const int AcceptedId = NextAvailableEventId; private const int ConnectedId = AcceptedId + 1; private const int ConnectedAsyncDnsId = ConnectedId + 1; diff --git a/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/NetEventSource.WebSockets.cs b/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/NetEventSource.WebSockets.cs index fceeadd862d3c6..80d5267e9cb533 100644 --- a/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/NetEventSource.WebSockets.cs +++ b/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/NetEventSource.WebSockets.cs @@ -8,9 +8,13 @@ namespace System.Net { - [EventSource(Name = "Private.InternalDiagnostics.System.Net.WebSockets")] + [EventSource(Name = NetEventSourceName)] internal sealed partial class NetEventSource { + private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.WebSockets"; + + public NetEventSource() : base(NetEventSourceName) { } + // NOTE // - The 'Start' and 'Stop' suffixes on the following event names have special meaning in EventSource. They // enable creating 'activities'. From c79a9a572ee648a32a2d1153f801c2bd36448248 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Sun, 5 Oct 2025 15:02:10 +0200 Subject: [PATCH 2/9] add EventSourceSettings.EtwManifestEventFormat --- .../src/System/Net/Http/NetEventSource.WinHttpHandler.cs | 2 +- .../System.Net.Http/src/System/Net/Http/NetEventSource.Http.cs | 2 +- .../src/System/Net/NetEventSource.HttpListener.cs | 2 +- .../System.Net.Mail/src/System/Net/Mail/NetEventSource.Mail.cs | 2 +- .../src/System/Net/NetEventSource.NameResolution.cs | 2 +- .../Net/NetworkInformation/NetEventSource.NetworkInformation.cs | 2 +- .../src/System/Net/NetEventSource.Primitives.cs | 2 +- .../System.Net.Quic/src/System/Net/Quic/NetEventSource.Quic.cs | 2 +- .../src/System/Net/NetEventSource.Requests.cs | 2 +- .../src/System/Net/Security/NetEventSource.Security.cs | 2 +- .../src/System/Net/Sockets/NetEventSource.Sockets.cs | 2 +- .../src/System/Net/WebSockets/NetEventSource.WebSockets.cs | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs index 3ebd0a7422ebf1..c3fc2335d362e4 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs @@ -10,6 +10,6 @@ internal sealed partial class NetEventSource { private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Http.WinHttpHandler"; - public NetEventSource() : base(NetEventSourceName) { } + public NetEventSource() : base(NetEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } } } 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 f1eb16fe020594..d3ba13ff485e2a 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 @@ -12,7 +12,7 @@ internal sealed partial class NetEventSource { private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Http"; - public NetEventSource() : base(NetEventSourceName) { } + public NetEventSource() : base(NetEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } private const int UriBaseAddressId = NextAvailableEventId; private const int ContentNullId = UriBaseAddressId + 1; diff --git a/src/libraries/System.Net.HttpListener/src/System/Net/NetEventSource.HttpListener.cs b/src/libraries/System.Net.HttpListener/src/System/Net/NetEventSource.HttpListener.cs index a40d46946c9c7c..a7b68f1952b748 100644 --- a/src/libraries/System.Net.HttpListener/src/System/Net/NetEventSource.HttpListener.cs +++ b/src/libraries/System.Net.HttpListener/src/System/Net/NetEventSource.HttpListener.cs @@ -10,6 +10,6 @@ internal sealed partial class NetEventSource { private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.HttpListener"; - public NetEventSource() : base(NetEventSourceName) { } + public NetEventSource() : base(NetEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } } } diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/NetEventSource.Mail.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/NetEventSource.Mail.cs index e8993fd50c57a2..fabf71247ec6c5 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/NetEventSource.Mail.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/NetEventSource.Mail.cs @@ -12,6 +12,6 @@ internal sealed partial class NetEventSource { private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Mail"; - public NetEventSource() : base(NetEventSourceName) { } + public NetEventSource() : base(NetEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } } } diff --git a/src/libraries/System.Net.NameResolution/src/System/Net/NetEventSource.NameResolution.cs b/src/libraries/System.Net.NameResolution/src/System/Net/NetEventSource.NameResolution.cs index 3792aff4a9bec6..e4ef4f752ab1c6 100644 --- a/src/libraries/System.Net.NameResolution/src/System/Net/NetEventSource.NameResolution.cs +++ b/src/libraries/System.Net.NameResolution/src/System/Net/NetEventSource.NameResolution.cs @@ -10,6 +10,6 @@ internal sealed partial class NetEventSource { private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.NameResolution"; - public NetEventSource() : base(NetEventSourceName) { } + public NetEventSource() : base(NetEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } } } diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetEventSource.NetworkInformation.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetEventSource.NetworkInformation.cs index 7c1fc78c3e16bb..74c8ec1e8228bd 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetEventSource.NetworkInformation.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetEventSource.NetworkInformation.cs @@ -12,7 +12,7 @@ internal sealed class NetEventSource : EventSource { private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.NetworkInformation"; - public NetEventSource() : base(NetEventSourceName) { } + public NetEventSource() : base(NetEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } public static readonly NetEventSource Log = new NetEventSource(); diff --git a/src/libraries/System.Net.Primitives/src/System/Net/NetEventSource.Primitives.cs b/src/libraries/System.Net.Primitives/src/System/Net/NetEventSource.Primitives.cs index c946f540c6a747..58c50d26c6ef16 100644 --- a/src/libraries/System.Net.Primitives/src/System/Net/NetEventSource.Primitives.cs +++ b/src/libraries/System.Net.Primitives/src/System/Net/NetEventSource.Primitives.cs @@ -10,6 +10,6 @@ internal sealed partial class NetEventSource { private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Primitives"; - public NetEventSource() : base(NetEventSourceName) { } + public NetEventSource() : base(NetEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } } } diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/NetEventSource.Quic.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/NetEventSource.Quic.cs index d7f9fadbc9d0d6..7e1ea926160686 100644 --- a/src/libraries/System.Net.Quic/src/System/Net/Quic/NetEventSource.Quic.cs +++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/NetEventSource.Quic.cs @@ -11,7 +11,7 @@ internal sealed partial class NetEventSource { private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Quic"; - public NetEventSource() : base(NetEventSourceName) { } + public NetEventSource() : base(NetEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } static partial void AdditionalCustomizedToString(object value, ref string? result) { diff --git a/src/libraries/System.Net.Requests/src/System/Net/NetEventSource.Requests.cs b/src/libraries/System.Net.Requests/src/System/Net/NetEventSource.Requests.cs index 231e330b74a4cc..070684e7b45b61 100644 --- a/src/libraries/System.Net.Requests/src/System/Net/NetEventSource.Requests.cs +++ b/src/libraries/System.Net.Requests/src/System/Net/NetEventSource.Requests.cs @@ -10,6 +10,6 @@ internal sealed partial class NetEventSource { private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Requests"; - public NetEventSource() : base(NetEventSourceName) { } + public NetEventSource() : base(NetEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } } } diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/NetEventSource.Security.cs b/src/libraries/System.Net.Security/src/System/Net/Security/NetEventSource.Security.cs index 6310ec6c51d95d..5835dec28d18c7 100644 --- a/src/libraries/System.Net.Security/src/System/Net/Security/NetEventSource.Security.cs +++ b/src/libraries/System.Net.Security/src/System/Net/Security/NetEventSource.Security.cs @@ -16,7 +16,7 @@ internal sealed partial class NetEventSource { private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Security"; - public NetEventSource() : base(NetEventSourceName) { } + public NetEventSource() : base(NetEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } #if WINDOWS // More events are defined in NetEventSource.Security.Windows.cs diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetEventSource.Sockets.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetEventSource.Sockets.cs index fc8644f4097194..99669d885af960 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetEventSource.Sockets.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetEventSource.Sockets.cs @@ -12,7 +12,7 @@ internal sealed partial class NetEventSource { private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Sockets"; - public NetEventSource() : base(NetEventSourceName) { } + public NetEventSource() : base(NetEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } private const int AcceptedId = NextAvailableEventId; private const int ConnectedId = AcceptedId + 1; diff --git a/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/NetEventSource.WebSockets.cs b/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/NetEventSource.WebSockets.cs index 80d5267e9cb533..4f8ae05d2fbe20 100644 --- a/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/NetEventSource.WebSockets.cs +++ b/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/NetEventSource.WebSockets.cs @@ -13,7 +13,7 @@ internal sealed partial class NetEventSource { private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.WebSockets"; - public NetEventSource() : base(NetEventSourceName) { } + public NetEventSource() : base(NetEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } // NOTE // - The 'Start' and 'Stop' suffixes on the following event names have special meaning in EventSource. They From d30d7d6d1499344c7f2f86fc60673c6674676845 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Sun, 5 Oct 2025 15:15:30 +0200 Subject: [PATCH 3/9] Apply Miha's FB --- .../System/Net/Http/NetEventSource.WinHttpHandler.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs index c3fc2335d362e4..b23deec571752d 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.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. -using System.Diagnostics.Tracing; - namespace System.Net { - [EventSource(Name = NetEventSourceName)] - internal sealed partial class NetEventSource - { - private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Http.WinHttpHandler"; - - public NetEventSource() : base(NetEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } - } + internal sealed partial class NetEventSource { } } From fd94022a319adb0e88c027a9f927e5d92080c577 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Sun, 5 Oct 2025 17:08:08 +0200 Subject: [PATCH 4/9] revert --- .../System/Net/Http/NetEventSource.WinHttpHandler.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs index b23deec571752d..c3fc2335d362e4 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/NetEventSource.WinHttpHandler.cs @@ -1,7 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Diagnostics.Tracing; + namespace System.Net { - internal sealed partial class NetEventSource { } + [EventSource(Name = NetEventSourceName)] + internal sealed partial class NetEventSource + { + private const string NetEventSourceName = "Private.InternalDiagnostics.System.Net.Http.WinHttpHandler"; + + public NetEventSource() : base(NetEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } + } } From 68435e1579d14cf1491aa59dc9495392d933a894 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 6 Oct 2025 05:37:15 +0200 Subject: [PATCH 5/9] More event sources --- .../System/Diagnostics/DiagnosticSourceEventSource.cs | 6 ++++-- .../System/Diagnostics/Metrics/MetricsEventSource.cs | 9 +++++++-- .../src/System/Net/Http/HttpTelemetry.cs | 9 ++++++++- .../src/System/Net/NameResolutionTelemetry.cs | 9 ++++++++- .../src/System/Net/Security/NetSecurityTelemetry.cs | 9 ++++++++- .../src/System/Net/Sockets/SocketsTelemetry.cs | 9 ++++++++- .../Xml/Serialization/XmlSerializationEventSource.cs | 10 ++++++++-- .../X509Certificates/OpenSslX509ChainEventSource.cs | 9 ++++++++- 8 files changed, 59 insertions(+), 11 deletions(-) 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 673671b3ad52cc..431fc96b534e6a 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs @@ -159,9 +159,11 @@ namespace System.Diagnostics /// /// See the DiagnosticSourceEventSourceBridgeTest.cs for more explicit examples of using this bridge. /// - [EventSource(Name = "Microsoft-Diagnostics-DiagnosticSource")] + [EventSource(Name = DiagnosticSourceEventSourceName)] internal sealed class DiagnosticSourceEventSource : EventSource { + private const string DiagnosticSourceEventSourceName = "Microsoft-Diagnostics-DiagnosticSource"; + public static readonly DiagnosticSourceEventSource Log = new DiagnosticSourceEventSource(); public static class Keywords @@ -405,7 +407,7 @@ protected override void OnEventCommand(EventCommandEventArgs command) private DiagnosticSourceEventSource() // This constructor uses EventSourceSettings which is only available on V4.6 and above // Use the EventSourceSettings to turn on support for complex types, if available (v4.6 and above). - : base(EventSourceSettings.EtwSelfDescribingEventFormat) + : base(DiagnosticSourceEventSourceName, EventSourceSettings.EtwSelfDescribingEventFormat) { } diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs index a2d3e7abdf6a31..e1550b18bece59 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs @@ -48,9 +48,11 @@ namespace System.Diagnostics.Metrics /// not counting the special zero bucket. The default value is 160. /// o reportDeltas - If true, the histogram will report deltas instead of whole accumulated values. The default value is false. /// - [EventSource(Name = "System.Diagnostics.Metrics")] + [EventSource(Name = MetricsEventSourceName)] internal sealed class MetricsEventSource : EventSource { + private const string MetricsEventSourceName = "System.Diagnostics.Metrics"; + public static readonly MetricsEventSource Log = new(); // Although this API isn't public, it is invoked via reflection from System.Private.CoreLib and needs the same back-compat @@ -96,7 +98,10 @@ private CommandHandler Handler } } - private MetricsEventSource() { } + private MetricsEventSource() + : base(MetricsEventSourceName, EventSourceSettings.EtwSelfDescribingEventFormat) + { + } /// /// Used to send ad-hoc diagnostics to humans. 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 f06fb5c0314379..5089d727c25678 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 @@ -9,9 +9,16 @@ namespace System.Net.Http { - [EventSource(Name = "System.Net.Http")] + [EventSource(Name = HttpTelemetryName)] internal sealed partial class HttpTelemetry : EventSource { + private const string HttpTelemetryName = "System.Net.Http"; + + public HttpTelemetry() + : base(HttpTelemetryName, EventSourceSettings.EtwSelfDescribingEventFormat) + { + } + public static readonly HttpTelemetry Log = new HttpTelemetry(); public static class Keywords diff --git a/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionTelemetry.cs b/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionTelemetry.cs index defa4da90564b2..527a4c0554f155 100644 --- a/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionTelemetry.cs +++ b/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionTelemetry.cs @@ -9,9 +9,16 @@ namespace System.Net { - [EventSource(Name = "System.Net.NameResolution")] + [EventSource(Name = NameResolutionTelemetryName)] internal sealed class NameResolutionTelemetry : EventSource { + private const string NameResolutionTelemetryName = "System.Net.NameResolution"; + + public NameResolutionTelemetry() + : base(NameResolutionTelemetryName, EventSourceSettings.EtwSelfDescribingEventFormat) + { + } + public static readonly NameResolutionTelemetry Log = new NameResolutionTelemetry(); private const int ResolutionStartEventId = 1; 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 6b425c28919358..89dc9078caa07b 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 @@ -9,9 +9,16 @@ namespace System.Net.Security { - [EventSource(Name = "System.Net.Security")] + [EventSource(Name = NetSecurityTelemetryName)] internal sealed class NetSecurityTelemetry : EventSource { + private const string NetSecurityTelemetryName = "System.Net.Security"; + + public NetSecurityTelemetry() + : base(NetSecurityTelemetryName, EventSourceSettings.EtwSelfDescribingEventFormat) + { + } + private const string ActivitySourceName = "Experimental.System.Net.Security"; private const string ActivityName = ActivitySourceName + ".TlsHandshake"; diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketsTelemetry.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketsTelemetry.cs index 2a7abb81f60b87..a207cc64f11696 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketsTelemetry.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketsTelemetry.cs @@ -7,9 +7,16 @@ namespace System.Net.Sockets { - [EventSource(Name = "System.Net.Sockets")] + [EventSource(Name = SocketsTelemetryName)] internal sealed class SocketsTelemetry : EventSource { + private const string SocketsTelemetryName = "System.Net.Sockets"; + + public SocketsTelemetry() + : base(SocketsTelemetryName, EventSourceSettings.EtwSelfDescribingEventFormat) + { + } + private const string ActivitySourceName = "Experimental.System.Net.Sockets"; private const string ConnectActivityName = ActivitySourceName + ".Connect"; private static readonly ActivitySource s_connectActivitySource = new ActivitySource(ActivitySourceName); diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationEventSource.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationEventSource.cs index 7b6846b1d5d1c9..f6dc2cd0b37a67 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationEventSource.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationEventSource.cs @@ -5,10 +5,16 @@ namespace System.Xml.Serialization { - [EventSource( - Name = "System.Xml.Serialzation.XmlSerialization")] + [EventSource(Name = XmlSerializationEventSourceName)] internal sealed class XmlSerializationEventSource : EventSource { + private const string XmlSerializationEventSourceName = "System.Xml.Serialzation.XmlSerialization"; + + public XmlSerializationEventSource() + : base(XmlSerializationEventSourceName, EventSourceSettings.EtwSelfDescribingEventFormat) + { + } + internal static readonly XmlSerializationEventSource Log = new XmlSerializationEventSource(); [Event(EventIds.XmlSerializerExpired, Level = EventLevel.Informational)] diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainEventSource.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainEventSource.cs index 0e1cdc25efb832..712815c0e913b4 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainEventSource.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainEventSource.cs @@ -7,9 +7,16 @@ namespace System.Security.Cryptography.X509Certificates { - [EventSource(Name = "System.Security.Cryptography.X509Certificates.X509Chain.OpenSsl")] + [EventSource(Name = OpenSslX509ChainEventSourceName)] internal sealed class OpenSslX509ChainEventSource : EventSource { + private const string OpenSslX509ChainEventSourceName = "System.Security.Cryptography.X509Certificates.X509Chain.OpenSsl"; + + public OpenSslX509ChainEventSource() + : base(OpenSslX509ChainEventSourceName, EventSourceSettings.EtwSelfDescribingEventFormat) + { + } + internal static readonly OpenSslX509ChainEventSource Log = new OpenSslX509ChainEventSource(); private const int EventId_ChainStart = 1; From 8627d2c4e00d19e821e9b41741dcd111cd961b08 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 6 Oct 2025 06:16:11 +0200 Subject: [PATCH 6/9] fix whitespace --- .../src/System/Diagnostics/Metrics/MetricsEventSource.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs index e1550b18bece59..90f393ae8868bf 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs @@ -98,7 +98,7 @@ private CommandHandler Handler } } - private MetricsEventSource() + private MetricsEventSource() : base(MetricsEventSourceName, EventSourceSettings.EtwSelfDescribingEventFormat) { } From 3716cabbd710ec032d70babd5a6b6b5e90140356 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 6 Oct 2025 06:19:04 +0200 Subject: [PATCH 7/9] use EtwManifestEventFormat --- .../src/System/Diagnostics/DiagnosticSourceEventSource.cs | 2 +- .../src/System/Diagnostics/Metrics/MetricsEventSource.cs | 2 +- .../System.Net.Http/src/System/Net/Http/HttpTelemetry.cs | 2 +- .../src/System/Net/NameResolutionTelemetry.cs | 2 +- .../src/System/Net/Security/NetSecurityTelemetry.cs | 2 +- .../src/System/Net/Sockets/SocketsTelemetry.cs | 2 +- .../src/System/Xml/Serialization/XmlSerializationEventSource.cs | 2 +- .../X509Certificates/OpenSslX509ChainEventSource.cs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) 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 431fc96b534e6a..2b58cb75711f1c 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs @@ -407,7 +407,7 @@ protected override void OnEventCommand(EventCommandEventArgs command) private DiagnosticSourceEventSource() // This constructor uses EventSourceSettings which is only available on V4.6 and above // Use the EventSourceSettings to turn on support for complex types, if available (v4.6 and above). - : base(DiagnosticSourceEventSourceName, EventSourceSettings.EtwSelfDescribingEventFormat) + : base(DiagnosticSourceEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs index 90f393ae8868bf..9656e8303c186b 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs @@ -99,7 +99,7 @@ private CommandHandler Handler } private MetricsEventSource() - : base(MetricsEventSourceName, EventSourceSettings.EtwSelfDescribingEventFormat) + : base(MetricsEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } 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 5089d727c25678..1c7a6ce5f36b86 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 @@ -15,7 +15,7 @@ internal sealed partial class HttpTelemetry : EventSource private const string HttpTelemetryName = "System.Net.Http"; public HttpTelemetry() - : base(HttpTelemetryName, EventSourceSettings.EtwSelfDescribingEventFormat) + : base(HttpTelemetryName, EventSourceSettings.EtwManifestEventFormat) { } diff --git a/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionTelemetry.cs b/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionTelemetry.cs index 527a4c0554f155..e7b4266701ad8a 100644 --- a/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionTelemetry.cs +++ b/src/libraries/System.Net.NameResolution/src/System/Net/NameResolutionTelemetry.cs @@ -15,7 +15,7 @@ internal sealed class NameResolutionTelemetry : EventSource private const string NameResolutionTelemetryName = "System.Net.NameResolution"; public NameResolutionTelemetry() - : base(NameResolutionTelemetryName, EventSourceSettings.EtwSelfDescribingEventFormat) + : base(NameResolutionTelemetryName, EventSourceSettings.EtwManifestEventFormat) { } 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 89dc9078caa07b..2be354f4a71ce1 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 @@ -15,7 +15,7 @@ internal sealed class NetSecurityTelemetry : EventSource private const string NetSecurityTelemetryName = "System.Net.Security"; public NetSecurityTelemetry() - : base(NetSecurityTelemetryName, EventSourceSettings.EtwSelfDescribingEventFormat) + : base(NetSecurityTelemetryName, EventSourceSettings.EtwManifestEventFormat) { } diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketsTelemetry.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketsTelemetry.cs index a207cc64f11696..3507638bc2ca20 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketsTelemetry.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketsTelemetry.cs @@ -13,7 +13,7 @@ internal sealed class SocketsTelemetry : EventSource private const string SocketsTelemetryName = "System.Net.Sockets"; public SocketsTelemetry() - : base(SocketsTelemetryName, EventSourceSettings.EtwSelfDescribingEventFormat) + : base(SocketsTelemetryName, EventSourceSettings.EtwManifestEventFormat) { } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationEventSource.cs b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationEventSource.cs index f6dc2cd0b37a67..ca093164ff6094 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationEventSource.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationEventSource.cs @@ -11,7 +11,7 @@ internal sealed class XmlSerializationEventSource : EventSource private const string XmlSerializationEventSourceName = "System.Xml.Serialzation.XmlSerialization"; public XmlSerializationEventSource() - : base(XmlSerializationEventSourceName, EventSourceSettings.EtwSelfDescribingEventFormat) + : base(XmlSerializationEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } diff --git a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainEventSource.cs b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainEventSource.cs index 712815c0e913b4..726b3486d939bf 100644 --- a/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainEventSource.cs +++ b/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainEventSource.cs @@ -13,7 +13,7 @@ internal sealed class OpenSslX509ChainEventSource : EventSource private const string OpenSslX509ChainEventSourceName = "System.Security.Cryptography.X509Certificates.X509Chain.OpenSsl"; public OpenSslX509ChainEventSource() - : base(OpenSslX509ChainEventSourceName, EventSourceSettings.EtwSelfDescribingEventFormat) + : base(OpenSslX509ChainEventSourceName, EventSourceSettings.EtwManifestEventFormat) { } From 3e3f2accfbfb4ef5e34c94a3e822af27ee49c18a Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 6 Oct 2025 06:20:27 +0200 Subject: [PATCH 8/9] DiagnosticSourceEvent uses self-describing one --- .../src/System/Diagnostics/DiagnosticSourceEventSource.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2b58cb75711f1c..431fc96b534e6a 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs @@ -407,7 +407,7 @@ protected override void OnEventCommand(EventCommandEventArgs command) private DiagnosticSourceEventSource() // This constructor uses EventSourceSettings which is only available on V4.6 and above // Use the EventSourceSettings to turn on support for complex types, if available (v4.6 and above). - : base(DiagnosticSourceEventSourceName, EventSourceSettings.EtwManifestEventFormat) + : base(DiagnosticSourceEventSourceName, EventSourceSettings.EtwSelfDescribingEventFormat) { } From 83acb965d9c64c64a11ece0492337307f5f1a623 Mon Sep 17 00:00:00 2001 From: Juan Sebastian Hoyos Ayala Date: Tue, 14 Oct 2025 19:59:33 -0700 Subject: [PATCH 9/9] Move System.Threading.SynchronizationEventSource and System.Collections.Concurrent.ConcurrentCollectionsEventSource to use string based constructors --- .../Concurrent/CDSCollectionETWBCLProvider.cs | 23 ++++++++++++++---- .../System/Threading/CDSsyncETWBCLProvider.cs | 24 +++++++++++++++---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/CDSCollectionETWBCLProvider.cs b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/CDSCollectionETWBCLProvider.cs index 2165c3344f5eee..c3df95d6d9f24f 100644 --- a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/CDSCollectionETWBCLProvider.cs +++ b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/CDSCollectionETWBCLProvider.cs @@ -14,23 +14,38 @@ // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Diagnostics.Tracing; +using System.Runtime.CompilerServices; namespace System.Collections.Concurrent { /// Provides an event source for tracing CDS collection information. [EventSource( - Name = "System.Collections.Concurrent.ConcurrentCollectionsEventSource", + Name = EventSourceName, Guid = "35167F8E-49B2-4b96-AB86-435B59336B5E" )] internal sealed class CDSCollectionETWBCLProvider : EventSource { + private const string EventSourceName = "System.Collections.Concurrent.ConcurrentCollectionsEventSource"; /// /// Defines the singleton instance for the collection ETW provider. /// The collection provider GUID is {35167F8E-49B2-4b96-AB86-435B59336B5E}. /// - public static readonly CDSCollectionETWBCLProvider Log = new CDSCollectionETWBCLProvider(); - /// Prevent external instantiation. All logging should go through the Log instance. - private CDSCollectionETWBCLProvider() { } + public static readonly CDSCollectionETWBCLProvider Log = CreateInstance(); + + private static CDSCollectionETWBCLProvider CreateInstance() + { + [UnsafeAccessor(UnsafeAccessorKind.Method, Name = ".ctor")] + static extern void BaseConstructor(EventSource eventSource, Guid eventSourceGuid, string eventSourceName, EventSourceSettings settings, string[]? traits = null); + + var instance = (CDSCollectionETWBCLProvider)RuntimeHelpers.GetUninitializedObject(typeof(CDSCollectionETWBCLProvider)); + + BaseConstructor(instance, + new Guid(0x35167F8E, 0x49B2, 0x4b96, 0xAB, 0x86, 0x43, 0x5B, 0x59, 0x33, 0x6B, 0x5E), + EventSourceName, + EventSourceSettings.EtwManifestEventFormat); + + return instance; + } /// Enabled for all keywords. private const EventKeywords ALL_KEYWORDS = (EventKeywords)(-1); diff --git a/src/libraries/System.Threading/src/System/Threading/CDSsyncETWBCLProvider.cs b/src/libraries/System.Threading/src/System/Threading/CDSsyncETWBCLProvider.cs index 64f46a74635bc4..97e193dac22d18 100644 --- a/src/libraries/System.Threading/src/System/Threading/CDSsyncETWBCLProvider.cs +++ b/src/libraries/System.Threading/src/System/Threading/CDSsyncETWBCLProvider.cs @@ -13,6 +13,7 @@ using System; using System.Collections.Generic; +using System.Runtime.CompilerServices; using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Tracing; using System.Security; @@ -22,18 +23,33 @@ namespace System.Threading { /// Provides an event source for tracing CDS synchronization information. [EventSource( - Name = "System.Threading.SynchronizationEventSource", + Name = EventSourceName, Guid = "EC631D38-466B-4290-9306-834971BA0217" )] internal sealed class CdsSyncEtwBCLProvider : EventSource { + private const string EventSourceName = "System.Threading.SynchronizationEventSource"; + /// /// Defines the singleton instance for the CDS Sync ETW provider. /// The CDS Sync Event provider GUID is {EC631D38-466B-4290-9306-834971BA0217}. /// - public static readonly CdsSyncEtwBCLProvider Log = new CdsSyncEtwBCLProvider(); - /// Prevent external instantiation. All logging should go through the Log instance. - private CdsSyncEtwBCLProvider() { } + public static readonly CdsSyncEtwBCLProvider Log = new CreateInstance(); + + private static CdsSyncEtwBCLProvider CreateInstance() + { + [UnsafeAccessor(UnsafeAccessorKind.Method, Name = ".ctor")] + static extern void BaseConstructor(EventSource eventSource, Guid eventSourceGuid, string eventSourceName, EventSourceSettings settings, string[]? traits = null); + + var instance = (CdsSyncEtwBCLProvider)RuntimeHelpers.GetUninitializedObject(typeof(CdsSyncEtwBCLProvider)); + + BaseConstructor(instance, + new Guid(0xEC631D38, 0x466B, 0x4290, 0x93, 0x06, 0x83, 0x49, 0x71, 0xBA, 0x02, 0x17), + EventSourceName, + EventSourceSettings.EtwManifestEventFormat); + + return instance; + } /// Enabled for all keywords. private const EventKeywords ALL_KEYWORDS = (EventKeywords)(-1);