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.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..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
@@ -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.EtwManifestEventFormat)
+ {
+ }
///
/// Used to send ad-hoc diagnostics to humans.
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..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
@@ -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, 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 f06fb5c0314379..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
@@ -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.EtwManifestEventFormat)
+ {
+ }
+
public static readonly HttpTelemetry Log = new HttpTelemetry();
public static class Keywords
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..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
@@ -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, EventSourceSettings.EtwManifestEventFormat) { }
+
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..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
@@ -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, 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 6f0b111c9a13bc..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
@@ -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, 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 defa4da90564b2..e7b4266701ad8a 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.EtwManifestEventFormat)
+ {
+ }
+
public static readonly NameResolutionTelemetry Log = new NameResolutionTelemetry();
private const int ResolutionStartEventId = 1;
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..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
@@ -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, 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 87a07eb1cdd2a0..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
@@ -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, EventSourceSettings.EtwManifestEventFormat) { }
+
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..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
@@ -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, 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 37dbeab080837c..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
@@ -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, EventSourceSettings.EtwManifestEventFormat) { }
+
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..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
@@ -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, 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 5ca0be27a35723..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
@@ -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, EventSourceSettings.EtwManifestEventFormat) { }
+
#if WINDOWS
// More events are defined in NetEventSource.Security.Windows.cs
private const int LocatingPrivateKeyId = OperationReturnedSomethingId + 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..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
@@ -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.EtwManifestEventFormat)
+ {
+ }
+
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/NetEventSource.Sockets.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetEventSource.Sockets.cs
index ed5460ffcb7c94..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
@@ -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, EventSourceSettings.EtwManifestEventFormat) { }
+
private const int AcceptedId = NextAvailableEventId;
private const int ConnectedId = AcceptedId + 1;
private const int ConnectedAsyncDnsId = ConnectedId + 1;
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..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
@@ -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.EtwManifestEventFormat)
+ {
+ }
+
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.Net.WebSockets/src/System/Net/WebSockets/NetEventSource.WebSockets.cs b/src/libraries/System.Net.WebSockets/src/System/Net/WebSockets/NetEventSource.WebSockets.cs
index fceeadd862d3c6..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
@@ -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, EventSourceSettings.EtwManifestEventFormat) { }
+
// NOTE
// - The 'Start' and 'Stop' suffixes on the following event names have special meaning in EventSource. They
// enable creating 'activities'.
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..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
@@ -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.EtwManifestEventFormat)
+ {
+ }
+
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..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
@@ -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.EtwManifestEventFormat)
+ {
+ }
+
internal static readonly OpenSslX509ChainEventSource Log = new OpenSslX509ChainEventSource();
private const int EventId_ChainStart = 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);