Skip to content

Commit 21f579b

Browse files
committed
1) Remove [EventSourceAutoGenerate], we rely on just [EventSource] + no explicit ctors
2) Introduce a new global SourceGenerators - EventSourceGenerator (and move the existing impl from SPC.Generators to this new project) 3) Update slnx files (via the UpdateSolutionFiles task) 4) Migrate all classes with [EventSource] to use the SG. Except for the ones with EtwSelfDescribingEventFormat
1 parent 25800e6 commit 21f579b

File tree

45 files changed

+102
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+102
-191
lines changed

eng/generators.targets

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
'$(DisableImplicitFrameworkReferences)' == 'true' and
4141
'@(ProjectReference->AnyHaveMetadataValue('Filename', 'System.Runtime.InteropServices'))' == 'true'
4242
)" />
43+
44+
<EnabledGenerators Include="EventSourceGenerator"
45+
Condition="'$(IsSourceProject)' == 'true' and
46+
'$(MSBuildProjectExtension)' == '.csproj' and
47+
(
48+
'$(DisableImplicitFrameworkReferences)' == 'true'
49+
)" />
4350
</ItemGroup>
4451

4552
<ItemGroup Condition="'@(EnabledGenerators)' != '' and
@@ -70,6 +77,11 @@
7077
OutputItemType="Analyzer"
7178
SetConfiguration="Configuration=$(LibrariesConfiguration)"
7279
Condition="@(EnabledGenerators->AnyHaveMetadataValue('Identity', 'ComInterfaceGenerator'))" />
80+
<ProjectReference Include="$(LibrariesProjectRoot)System.Private.CoreLib\gen\EventSourceGenerator.csproj"
81+
ReferenceOutputAssembly="false"
82+
OutputItemType="Analyzer"
83+
SetConfiguration="Configuration=$(LibrariesConfiguration)"
84+
Condition="@(EnabledGenerators->AnyHaveMetadataValue('Identity', 'EventSourceGenerator'))" />
7385
</ItemGroup>
7486

7587
<Target Name="ConfigureGenerators"

src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/PerfEventSource.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
namespace ILCompiler.DependencyAnalysisFramework
1111
{
1212
[EventSource(Name = "Microsoft-ILCompiler-Graph-Perf")]
13-
public class PerfEventSource : EventSource
13+
public partial class PerfEventSource : EventSource
1414
{
15-
private PerfEventSource() { }
16-
1715
public static PerfEventSource Log = new PerfEventSource();
1816

1917
public struct StartStopEvents : IDisposable

src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/PerfEventSource.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
namespace ILCompiler
1111
{
1212
[EventSource(Name = "Microsoft-ILCompiler-Perf")]
13-
public class PerfEventSource : EventSource
13+
public partial class PerfEventSource : EventSource
1414
{
15-
private PerfEventSource() { }
16-
1715
public static PerfEventSource Log = new PerfEventSource();
1816

1917
public struct StartStopEvents : IDisposable

src/libraries/NetCoreAppLibrary.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@
181181
<!-- List .NETCoreApp shared framework generator project names below. -->
182182
<NetCoreAppLibraryGenerator>
183183
ComInterfaceGenerator;
184+
EventSourceGenerator;
184185
LibraryImportGenerator;
185186
JSImportGenerator;
186187
Microsoft.Interop.SourceGeneration;

src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/CDSCollectionETWBCLProvider.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ namespace System.Collections.Concurrent
1919
Name = "System.Collections.Concurrent.ConcurrentCollectionsEventSource",
2020
Guid = "35167F8E-49B2-4b96-AB86-435B59336B5E"
2121
)]
22-
internal sealed class CDSCollectionETWBCLProvider : EventSource
22+
internal sealed partial class CDSCollectionETWBCLProvider : EventSource
2323
{
2424
/// <summary>
2525
/// Defines the singleton instance for the collection ETW provider.
2626
/// The collection provider GUID is {35167F8E-49B2-4b96-AB86-435B59336B5E}.
2727
/// </summary>
2828
public static readonly CDSCollectionETWBCLProvider Log = new CDSCollectionETWBCLProvider();
29-
/// <summary>Prevent external instantiation. All logging should go through the Log instance.</summary>
30-
private CDSCollectionETWBCLProvider() { }
3129

3230
/// <summary>Enabled for all keywords.</summary>
3331
private const EventKeywords ALL_KEYWORDS = (EventKeywords)(-1);

src/libraries/System.Data.Common/src/System/Data/Common/DataCommonEventSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace System.Data
88
{
99
[EventSource(Name = "System.Data.DataCommonEventSource")]
10-
internal sealed class DataCommonEventSource : EventSource
10+
internal sealed partial class DataCommonEventSource : EventSource
1111
{
1212
internal static readonly DataCommonEventSource Log = new DataCommonEventSource();
1313
private static long s_nextScopeId;

src/libraries/System.Data.OleDb/src/System/Data/Common/DataCommonEventSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace System.Data
88
{
99
[EventSource(Name = "System.Data.DataCommonEventSource")]
10-
internal sealed class DataCommonEventSource : EventSource
10+
internal sealed partial class DataCommonEventSource : EventSource
1111
{
1212
internal static readonly DataCommonEventSource Log = new DataCommonEventSource();
1313
private const int TraceEventId = 1;

src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MetricsEventSource.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ namespace System.Diagnostics.Metrics
4848
/// not counting the special zero bucket. The default value is 160.
4949
/// o reportDeltas - If true, the histogram will report deltas instead of whole accumulated values. The default value is false.
5050
/// </summary>
51-
[EventSource(Name = MetricsEventSourceName)]
52-
internal sealed class MetricsEventSource : EventSource
51+
[EventSource(Name = "System.Diagnostics.Metrics")]
52+
internal sealed partial class MetricsEventSource : EventSource
5353
{
54-
private const string MetricsEventSourceName = "System.Diagnostics.Metrics";
55-
5654
public static readonly MetricsEventSource Log = new();
5755

5856
// Although this API isn't public, it is invoked via reflection from System.Private.CoreLib and needs the same back-compat
@@ -98,11 +96,6 @@ private CommandHandler Handler
9896
}
9997
}
10098

101-
private MetricsEventSource()
102-
: base(MetricsEventSourceName, EventSourceSettings.EtwManifestEventFormat)
103-
{
104-
}
105-
10699
/// <summary>
107100
/// Used to send ad-hoc diagnostics to humans.
108101
/// </summary>

src/libraries/System.Diagnostics.Tracing/ref/System.Diagnostics.Tracing.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ protected EventSource(System.Diagnostics.Tracing.EventSourceSettings settings, p
155155
public EventSource(string eventSourceName) { }
156156
public EventSource(string eventSourceName, System.Diagnostics.Tracing.EventSourceSettings config) { }
157157
public EventSource(string eventSourceName, System.Diagnostics.Tracing.EventSourceSettings config, params string[]? traits) { }
158+
public EventSource(string eventSourceName, Guid eventSourceGuid) { }
159+
public EventSource(string eventSourceName, Guid eventSourceGuid, System.Diagnostics.Tracing.EventSourceSettings settings, params string[]? traits) { }
160+
158161
public System.Exception? ConstructionException { get { throw null; } }
159162
public static System.Guid CurrentThreadActivityId { get { throw null; } }
160163
public System.Guid Guid { get { throw null; } }

src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Utils/PLINQETWProvider.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@ namespace System.Linq.Parallel
2222
[EventSource(
2323
Name = "System.Linq.Parallel.PlinqEventSource",
2424
Guid = "159eeeec-4a14-4418-a8fe-faabcd987887")]
25-
internal sealed class PlinqEtwProvider : EventSource
25+
internal sealed partial class PlinqEtwProvider : EventSource
2626
{
2727
/// <summary>
2828
/// Defines the singleton instance for the PLINQ ETW provider.
2929
/// The PLINQ Event provider GUID is {159eeeec-4a14-4418-a8fe-faabcd987887}.
3030
/// </summary>
3131
internal static readonly PlinqEtwProvider Log = new PlinqEtwProvider();
32-
/// <summary>Prevent external instantiation. All logging should go through the Log instance.</summary>
33-
private PlinqEtwProvider() { }
3432

3533
/// <summary>Cached id for the default scheduler.</summary>
3634
/// <remarks>If PLINQ ever supports other schedulers, that information will need to be passed into the query events.</remarks>

0 commit comments

Comments
 (0)