Skip to content

Commit cc37cdd

Browse files
authored
Seal NullLogger (#117342)
Sealing it makes type checks against it cheaper. Some libraries special-case ILogger instances that are NullLogger in order to avoid some logging-related overheads. While normally sealing a previously shipped public type would be a breaking change, NullLogger's only constructor is private, so types can't currently derive from it.
1 parent 9e5e6aa commit cc37cdd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/libraries/Microsoft.Extensions.Logging.Abstractions/ref/Microsoft.Extensions.Logging.Abstractions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public readonly partial struct LogEntry<TState>
177177
public Microsoft.Extensions.Logging.LogLevel LogLevel { get { throw null; } }
178178
public TState State { get { throw null; } }
179179
}
180-
public partial class NullLogger : Microsoft.Extensions.Logging.ILogger
180+
public sealed partial class NullLogger : Microsoft.Extensions.Logging.ILogger
181181
{
182182
internal NullLogger() { }
183183
public static Microsoft.Extensions.Logging.Abstractions.NullLogger Instance { get { throw null; } }

src/libraries/Microsoft.Extensions.Logging.Abstractions/src/NullLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Microsoft.Extensions.Logging.Abstractions
88
/// <summary>
99
/// Minimalistic logger that does nothing.
1010
/// </summary>
11-
public class NullLogger : ILogger
11+
public sealed class NullLogger : ILogger
1212
{
1313
/// <summary>
1414
/// Returns the shared instance of <see cref="NullLogger"/>.

0 commit comments

Comments
 (0)