Skip to content

Commit

Permalink
Fixed warnings in EngineEventLogParser
Browse files Browse the repository at this point in the history
  • Loading branch information
alinasmirnova authored and AndreyAkinshin committed Oct 3, 2023
1 parent 9d7350c commit b43d280
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace BenchmarkDotNet.Diagnostics.Windows.Tracing
{
public sealed class EngineEventLogParser : TraceEventParser
{
private static volatile TraceEvent[] templates;
private static volatile TraceEvent[]? templates;

public EngineEventLogParser(TraceEventSource source, bool dontRegister = false) : base(source, dontRegister) { }

Expand Down Expand Up @@ -114,69 +114,69 @@ public event Action<IterationEvent> WorkloadActualStop

protected override string GetProviderName() { return ProviderName; }

private static IterationEvent BenchmarkStartTemplate(Action<IterationEvent> action)
private static IterationEvent BenchmarkStartTemplate(Action<IterationEvent>? action)
{ // action, eventid, taskid, taskName, taskGuid, opcode, opcodeName, providerGuid, providerName
return new IterationEvent(action, EngineEventSource.BenchmarkStartEventId, (int)EngineEventSource.Tasks.Benchmark, nameof(EngineEventSource.Tasks.Benchmark), Guid.Empty, (int)EventOpcode.Start, nameof(EventOpcode.Start), ProviderGuid, ProviderName);
}

private static IterationEvent BenchmarkStopTemplate(Action<IterationEvent> action)
private static IterationEvent BenchmarkStopTemplate(Action<IterationEvent>? action)
{ // action, eventid, taskid, taskName, taskGuid, opcode, opcodeName, providerGuid, providerName
return new IterationEvent(action, EngineEventSource.BenchmarkStopEventId, (int)EngineEventSource.Tasks.Benchmark, nameof(EngineEventSource.Tasks.Benchmark), Guid.Empty, (int)EventOpcode.Stop, nameof(EventOpcode.Stop), ProviderGuid, ProviderName);
}

private static IterationEvent OverheadJittingStartTemplate(Action<IterationEvent> action)
private static IterationEvent OverheadJittingStartTemplate(Action<IterationEvent>? action)
=> CreateIterationStartTemplate(action, EngineEventSource.OverheadJittingStartEventId, EngineEventSource.Tasks.OverheadJitting);

private static IterationEvent OverheadJittingStopTemplate(Action<IterationEvent> action)
private static IterationEvent OverheadJittingStopTemplate(Action<IterationEvent>? action)
=> CreateIterationStopTemplate(action, EngineEventSource.OverheadJittingStopEventId, EngineEventSource.Tasks.OverheadJitting);

private static IterationEvent WorkloadJittingStartTemplate(Action<IterationEvent> action)
private static IterationEvent WorkloadJittingStartTemplate(Action<IterationEvent>? action)
=> CreateIterationStartTemplate(action, EngineEventSource.WorkloadJittingStartEventId, EngineEventSource.Tasks.WorkloadJitting);

private static IterationEvent WorkloadJittingStopTemplate(Action<IterationEvent> action)
private static IterationEvent WorkloadJittingStopTemplate(Action<IterationEvent>? action)
=> CreateIterationStopTemplate(action, EngineEventSource.WorkloadJittingStopEventId, EngineEventSource.Tasks.WorkloadJitting);

private static IterationEvent WorkloadPilotStartTemplate(Action<IterationEvent> action)
private static IterationEvent WorkloadPilotStartTemplate(Action<IterationEvent>? action)
=> CreateIterationStartTemplate(action, EngineEventSource.WorkloadPilotStartEventId, EngineEventSource.Tasks.WorkloadPilot);

private static IterationEvent WorkloadPilotStopTemplate(Action<IterationEvent> action)
private static IterationEvent WorkloadPilotStopTemplate(Action<IterationEvent>? action)
=> CreateIterationStopTemplate(action, EngineEventSource.WorkloadPilotStopEventId, EngineEventSource.Tasks.WorkloadPilot);

private static IterationEvent OverheadWarmupStartTemplate(Action<IterationEvent> action)
private static IterationEvent OverheadWarmupStartTemplate(Action<IterationEvent>? action)
=> CreateIterationStartTemplate(action, EngineEventSource.OverheadWarmupStartEventId, EngineEventSource.Tasks.OverheadWarmup);

private static IterationEvent OverheadWarmupStopTemplate(Action<IterationEvent> action)
private static IterationEvent OverheadWarmupStopTemplate(Action<IterationEvent>? action)
=> CreateIterationStopTemplate(action, EngineEventSource.OverheadWarmupStopEventId, EngineEventSource.Tasks.OverheadWarmup);

private static IterationEvent WorkloadWarmupStartTemplate(Action<IterationEvent> action)
private static IterationEvent WorkloadWarmupStartTemplate(Action<IterationEvent>? action)
=> CreateIterationStartTemplate(action, EngineEventSource.WorkloadWarmupStartEventId, EngineEventSource.Tasks.WorkloadWarmup);

private static IterationEvent WorkloadWarmupStopTemplate(Action<IterationEvent> action)
private static IterationEvent WorkloadWarmupStopTemplate(Action<IterationEvent>? action)
=> CreateIterationStopTemplate(action, EngineEventSource.WorkloadWarmupStopEventId, EngineEventSource.Tasks.WorkloadWarmup);

private static IterationEvent OverheadActualStartTemplate(Action<IterationEvent> action)
private static IterationEvent OverheadActualStartTemplate(Action<IterationEvent>? action)
=> CreateIterationStartTemplate(action, EngineEventSource.OverheadActualStartEventId, EngineEventSource.Tasks.OverheadActual);

private static IterationEvent OverheadActualStopTemplate(Action<IterationEvent> action)
private static IterationEvent OverheadActualStopTemplate(Action<IterationEvent>? action)
=> CreateIterationStopTemplate(action, EngineEventSource.OverheadActualStopEventId, EngineEventSource.Tasks.OverheadActual);

private static IterationEvent WorkloadActualStartTemplate(Action<IterationEvent> action)
private static IterationEvent WorkloadActualStartTemplate(Action<IterationEvent>? action)
=> CreateIterationStartTemplate(action, EngineEventSource.WorkloadActualStartEventId, EngineEventSource.Tasks.WorkloadActual);

private static IterationEvent WorkloadActualStopTemplate(Action<IterationEvent> action)
private static IterationEvent WorkloadActualStopTemplate(Action<IterationEvent>? action)
=> CreateIterationStopTemplate(action, EngineEventSource.WorkloadActualStopEventId, EngineEventSource.Tasks.WorkloadActual);

private static IterationEvent CreateIterationStartTemplate(Action<IterationEvent> action, int eventId, EventTask eventTask)
private static IterationEvent CreateIterationStartTemplate(Action<IterationEvent>? action, int eventId, EventTask eventTask)
{ // action, eventid, taskid, taskName, taskGuid, opcode, opcodeName, providerGuid, providerName
return new IterationEvent(action, eventId, (int)eventTask, eventTask.ToString(), Guid.Empty, (int)EventOpcode.Start, nameof(EventOpcode.Start), ProviderGuid, ProviderName);
}

private static IterationEvent CreateIterationStopTemplate(Action<IterationEvent> action, int eventId, EventTask eventTask)
private static IterationEvent CreateIterationStopTemplate(Action<IterationEvent>? action, int eventId, EventTask eventTask)
{ // action, eventid, taskid, taskName, taskGuid, opcode, opcodeName, providerGuid, providerName
return new IterationEvent(action, eventId, (int)eventTask, eventTask.ToString(), Guid.Empty, (int)EventOpcode.Stop, nameof(EventOpcode.Stop), ProviderGuid, ProviderName);
}

protected override void EnumerateTemplates(Func<string, string, EventFilterResponse> eventsToObserve, Action<TraceEvent> callback)
protected override void EnumerateTemplates(Func<string, string, EventFilterResponse>? eventsToObserve, Action<TraceEvent> callback)
{
if (templates == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ public sealed class IterationEvent : TraceEvent
{
public long TotalOperations => GetInt64At(0);

private event Action<IterationEvent> target;
private event Action<IterationEvent>? target;

internal IterationEvent(Action<IterationEvent> target, int eventID, int task, string taskName, Guid taskGuid, int opcode, string opcodeName, Guid providerGuid, string providerName)
: base(eventID, task, taskName, taskGuid, opcode, opcodeName, providerGuid, providerName)
internal IterationEvent(Action<IterationEvent>? target, int eventId, int task, string taskName, Guid taskGuid, int opcode, string opcodeName, Guid providerGuid, string providerName)
: base(eventId, task, taskName, taskGuid, opcode, opcodeName, providerGuid, providerName)
{
this.target = target;
}

protected override Delegate Target
protected override Delegate? Target
{
get => target;
set => target = (Action<IterationEvent>)value;
Expand All @@ -34,7 +34,7 @@ public override StringBuilder ToXml(StringBuilder sb)
return sb;
}

public override object PayloadValue(int index) => index == 0 ? (object)TotalOperations : null;
public override object? PayloadValue(int index) => index == 0 ? TotalOperations : null;

protected override void Dispatch() => target?.Invoke(this);

Expand Down

0 comments on commit b43d280

Please sign in to comment.