Skip to content

Commit 2c68de7

Browse files
Make lambdas static
Make a number of lambda methods explicitly static.
1 parent 79bfb2d commit 2c68de7

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/Logging.XUnit/XUnitLogger.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private XUnitLogger(string name, XUnitLoggerOptions? options)
5050
{
5151
Name = name ?? throw new ArgumentNullException(nameof(name));
5252

53-
_filter = options?.Filter ?? ((_, _) => true);
53+
_filter = options?.Filter ?? (static (_, _) => true);
5454
_messageSinkMessageFactory = options?.MessageSinkMessageFactory ?? (message => new DiagnosticMessage(message));
5555
IncludeScopes = options?.IncludeScopes ?? false;
5656
}
@@ -80,7 +80,7 @@ private XUnitLogger(string name, XUnitLoggerOptions? options)
8080
/// <summary>
8181
/// Gets or sets a delegate representing the system clock.
8282
/// </summary>
83-
internal Func<DateTimeOffset> Clock { get; set; } = () => DateTimeOffset.Now;
83+
internal Func<DateTimeOffset> Clock { get; set; } = static () => DateTimeOffset.Now;
8484

8585
/// <inheritdoc />
8686
public IDisposable BeginScope<TState>(TState state)

src/Logging.XUnit/XUnitLoggerExtensions.IMessageSink.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static ILoggingBuilder AddXUnit(this ILoggingBuilder builder, IMessageSin
3636
throw new ArgumentNullException(nameof(accessor));
3737
}
3838

39-
return builder.AddXUnit(accessor, (_) => { });
39+
return builder.AddXUnit(accessor, static (_) => { });
4040
}
4141

4242
/// <summary>
@@ -104,7 +104,7 @@ public static ILoggingBuilder AddXUnit(this ILoggingBuilder builder, IMessageSin
104104
throw new ArgumentNullException(nameof(messageSink));
105105
}
106106

107-
return builder.AddXUnit(messageSink, (_) => { });
107+
return builder.AddXUnit(messageSink, static (_) => { });
108108
}
109109

110110
/// <summary>
@@ -227,7 +227,7 @@ public static ILoggerFactory AddXUnit(this ILoggerFactory factory, IMessageSink
227227
throw new ArgumentNullException(nameof(messageSink));
228228
}
229229

230-
return factory.AddXUnit(messageSink, (_) => { });
230+
return factory.AddXUnit(messageSink, static (_) => { });
231231
}
232232

233233
/// <summary>

src/Logging.XUnit/XUnitLoggerExtensions.ITestOutputHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static ILoggingBuilder AddXUnit(this ILoggingBuilder builder)
3131
throw new ArgumentNullException(nameof(builder));
3232
}
3333

34-
return builder.AddXUnit(new AmbientTestOutputHelperAccessor(), (_) => { });
34+
return builder.AddXUnit(new AmbientTestOutputHelperAccessor(), static (_) => { });
3535
}
3636

3737
/// <summary>
@@ -57,7 +57,7 @@ public static ILoggingBuilder AddXUnit(this ILoggingBuilder builder, ITestOutput
5757
throw new ArgumentNullException(nameof(accessor));
5858
}
5959

60-
return builder.AddXUnit(accessor, (_) => { });
60+
return builder.AddXUnit(accessor, static (_) => { });
6161
}
6262

6363
/// <summary>
@@ -125,7 +125,7 @@ public static ILoggingBuilder AddXUnit(this ILoggingBuilder builder, ITestOutput
125125
throw new ArgumentNullException(nameof(outputHelper));
126126
}
127127

128-
return builder.AddXUnit(outputHelper, (_) => { });
128+
return builder.AddXUnit(outputHelper, static (_) => { });
129129
}
130130

131131
/// <summary>
@@ -248,7 +248,7 @@ public static ILoggerFactory AddXUnit(this ILoggerFactory factory, ITestOutputHe
248248
throw new ArgumentNullException(nameof(outputHelper));
249249
}
250250

251-
return factory.AddXUnit(outputHelper, (_) => { });
251+
return factory.AddXUnit(outputHelper, static (_) => { });
252252
}
253253

254254
/// <summary>

src/Logging.XUnit/XUnitLoggerOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ public XUnitLoggerOptions()
2222
/// <summary>
2323
/// Gets or sets the category filter to apply to logs.
2424
/// </summary>
25-
public Func<string?, LogLevel, bool> Filter { get; set; } = (c, l) => true; // By default log everything
25+
public Func<string?, LogLevel, bool> Filter { get; set; } = static (c, l) => true; // By default log everything
2626

2727
/// <summary>
2828
/// Gets or sets the message sink message factory to use when writing to a <see cref="IMessageSink"/>.
2929
/// </summary>
30-
public Func<string, IMessageSinkMessage> MessageSinkMessageFactory { get; set; } = m => new DiagnosticMessage(m);
30+
public Func<string, IMessageSinkMessage> MessageSinkMessageFactory { get; set; } = static (m) => new DiagnosticMessage(m);
3131

3232
/// <summary>
3333
/// Gets or sets a value indicating whether to include scopes.

0 commit comments

Comments
 (0)