Skip to content

Commit

Permalink
remove ! operator from nulls in conditions (#1719)
Browse files Browse the repository at this point in the history
  • Loading branch information
sungam3r committed Aug 1, 2022
1 parent 1c926f0 commit f447af3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/Serilog/Core/Logger.cs
Expand Up @@ -102,7 +102,7 @@ public sealed class Logger : ILogger, ILogEventSink, IDisposable
/// <returns>A logger that will enrich log events as specified.</returns>
public ILogger ForContext(ILogEventEnricher enricher)
{
if (enricher == null!)
if (enricher == null)
return this; // No context here, so little point writing to SelfLog.

return new Logger(
Expand All @@ -122,7 +122,7 @@ public ILogger ForContext(ILogEventEnricher enricher)
/// <returns>A logger that will enrich log events as specified.</returns>
public ILogger ForContext(IEnumerable<ILogEventEnricher> enrichers)
{
if (enrichers == null!)
if (enrichers == null)
return this; // No context here, so little point writing to SelfLog.

return ForContext(new SafeAggregateEnricher(enrichers));
Expand Down Expand Up @@ -175,7 +175,7 @@ public ILogger ForContext(string propertyName, object? value, bool destructureOb
/// <returns>A logger that will enrich log events as specified.</returns>
public ILogger ForContext(Type source)
{
if (source == null!)
if (source == null)
return this; // Little point in writing to SelfLog here because we don't have any contextual information

return ForContext(Constants.SourceContextPropertyName, source.FullName);
Expand Down Expand Up @@ -363,7 +363,7 @@ public void Write<T>(LogEventLevel level, Exception? exception, string messageTe
public void Write(LogEventLevel level, Exception? exception, string messageTemplate, params object?[]? propertyValues)
{
if (!IsEnabled(level)) return;
if (messageTemplate == null!) return;
if (messageTemplate == null) return;

// Catch a common pitfall when a single non-object array is cast to object[]
if (propertyValues != null &&
Expand All @@ -383,7 +383,7 @@ public void Write(LogEventLevel level, Exception? exception, string messageTempl
/// <param name="logEvent">The event to write.</param>
public void Write(LogEvent logEvent)
{
if (logEvent == null!) return;
if (logEvent == null) return;
if (!IsEnabled(logEvent.Level)) return;
Dispatch(logEvent);
}
Expand Down Expand Up @@ -1332,7 +1332,7 @@ public void Fatal(Exception? exception, string messageTemplate, params object?[]
[NotNullWhen(true)] out MessageTemplate? parsedTemplate,
[NotNullWhen(true)] out IEnumerable<LogEventProperty>? boundProperties)
{
if (messageTemplate == null!)
if (messageTemplate == null)
{
parsedTemplate = null;
boundProperties = null;
Expand Down
6 changes: 3 additions & 3 deletions src/Serilog/ILogger.cs
Expand Up @@ -69,7 +69,7 @@ ILogger ForContext(ILogEventEnricher enricher)
ILogger ForContext(IEnumerable<ILogEventEnricher> enrichers)
#if FEATURE_DEFAULT_INTERFACE
{
if (enrichers == null!)
if (enrichers == null)
return this; // No context here, so little point writing to SelfLog.

return ForContext(new Core.Enrichers.SafeAggregateEnricher(enrichers));
Expand Down Expand Up @@ -120,7 +120,7 @@ ILogger ForContext<TSource>()
ILogger ForContext(Type source)
#if FEATURE_DEFAULT_INTERFACE
{
if (source == null!)
if (source == null)
return this; // Little point in writing to SelfLog here because we don't have any contextual information

return ForContext(Constants.SourceContextPropertyName, source.FullName);
Expand Down Expand Up @@ -331,7 +331,7 @@ void Write(LogEventLevel level, Exception? exception, string messageTemplate, pa
#if FEATURE_DEFAULT_INTERFACE
{
if (!IsEnabled(level)) return;
if (messageTemplate == null!) return;
if (messageTemplate == null) return;

// Catch a common pitfall when a single non-object array is cast to object[]
if (propertyValues != null &&
Expand Down

0 comments on commit f447af3

Please sign in to comment.