dotnet / dotnet/runtime

[API Proposal]: Settings property in EventSourceAttribute

Open
#121,205 8 comments 0 reactions 0 assignees View on GitHub
api-suggestion area-System.Diagnostics.Tracing
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Background and motivation

This is the last missing piece to implement an EventSource Source Generator, more context: https://github.com/dotnet/runtime/pull/121180#discussion_r2475570848

tl;dr:
Today, when developers need to set `EtwSelfDescribingEventFormat` mode (we have 3 EventSource implementations doing so) they cannot declare it in the [EventSource] attribute and have to do that via the base EventSource constructor.

Unblocks https://github.com/dotnet/runtime/pull/121180

### API Proposal

```diff
namespace System.Diagnostics.Tracing;

[System.AttributeUsageAttribute(System.AttributeTargets.Class)]
public sealed partial class EventSourceAttribute : System.Attribute
{
public EventSourceAttribute() { }
public string? Guid { get; set; }
public string? LocalizationResources { get; set; }
public string? Name { get; set; }
+ public EventSourceSettings? Settings { get; set; }
}
```

### API Usage

```csharp
[EventSource(
Name = DiagnosticSourceEventSourceName,
Settings = EventSourceSettings.EtwSelfDescribingEventFormat)]
internal sealed class DiagnosticSourceEventSource : EventSource
```

### Alternative Designs

-

### Risks

-

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.