Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove ! operator from nulls in conditions #1719

Merged
merged 1 commit into from Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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