Skip to content

Commit b43d280

Browse files
alinasmirnovaAndreyAkinshin
authored andcommittedOct 3, 2023
Fixed warnings in EngineEventLogParser
1 parent 9d7350c commit b43d280

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed
 

‎src/BenchmarkDotNet.Diagnostics.Windows/Tracing/EngineEventLogParser.cs

+20-20
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace BenchmarkDotNet.Diagnostics.Windows.Tracing
88
{
99
public sealed class EngineEventLogParser : TraceEventParser
1010
{
11-
private static volatile TraceEvent[] templates;
11+
private static volatile TraceEvent[]? templates;
1212

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

@@ -114,69 +114,69 @@ public event Action<IterationEvent> WorkloadActualStop
114114

115115
protected override string GetProviderName() { return ProviderName; }
116116

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

179-
protected override void EnumerateTemplates(Func<string, string, EventFilterResponse> eventsToObserve, Action<TraceEvent> callback)
179+
protected override void EnumerateTemplates(Func<string, string, EventFilterResponse>? eventsToObserve, Action<TraceEvent> callback)
180180
{
181181
if (templates == null)
182182
{

‎src/BenchmarkDotNet.Diagnostics.Windows/Tracing/IterationEvent.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ public sealed class IterationEvent : TraceEvent
99
{
1010
public long TotalOperations => GetInt64At(0);
1111

12-
private event Action<IterationEvent> target;
12+
private event Action<IterationEvent>? target;
1313

14-
internal IterationEvent(Action<IterationEvent> target, int eventID, int task, string taskName, Guid taskGuid, int opcode, string opcodeName, Guid providerGuid, string providerName)
15-
: base(eventID, task, taskName, taskGuid, opcode, opcodeName, providerGuid, providerName)
14+
internal IterationEvent(Action<IterationEvent>? target, int eventId, int task, string taskName, Guid taskGuid, int opcode, string opcodeName, Guid providerGuid, string providerName)
15+
: base(eventId, task, taskName, taskGuid, opcode, opcodeName, providerGuid, providerName)
1616
{
1717
this.target = target;
1818
}
1919

20-
protected override Delegate Target
20+
protected override Delegate? Target
2121
{
2222
get => target;
2323
set => target = (Action<IterationEvent>)value;
@@ -34,7 +34,7 @@ public override StringBuilder ToXml(StringBuilder sb)
3434
return sb;
3535
}
3636

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.