Skip to content

[API Proposal]: Settings property in EventSourceAttribute #121205

@EgorBo

Description

@EgorBo

Background and motivation

This is the last missing piece to implement an EventSource Source Generator, more context: #121180 (comment)

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 #121180

API Proposal

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

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

Alternative Designs

Risks

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Diagnostics.TracinguntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions