Skip to content

Commit

Permalink
style: replace null checks with pattern match
Browse files Browse the repository at this point in the history
  • Loading branch information
skwasjer committed Nov 25, 2023
1 parent 65a87ac commit 29b2d79
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/Rebus.Correlate/CorrelateConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public static class CorrelateConfigurationExtensions
/// <returns>The <see cref="OptionsConfigurer" /> instance.</returns>
public static OptionsConfigurer EnableCorrelate(this OptionsConfigurer configurer, ILoggerFactory loggerFactory)
{
if (configurer == null)
if (configurer is null)
{
throw new ArgumentNullException(nameof(configurer));
}

if (loggerFactory == null)
if (loggerFactory is null)
{
throw new ArgumentNullException(nameof(loggerFactory));
}
Expand Down Expand Up @@ -67,7 +67,7 @@ public static OptionsConfigurer EnableCorrelate(this OptionsConfigurer configure
/// <returns>The <see cref="OptionsConfigurer" /> instance.</returns>
public static OptionsConfigurer EnableCorrelate(this OptionsConfigurer configurer, IServiceProvider serviceProvider)
{
if (serviceProvider == null)
if (serviceProvider is null)
{
throw new ArgumentNullException(nameof(serviceProvider));
}
Expand All @@ -83,12 +83,12 @@ public static OptionsConfigurer EnableCorrelate(this OptionsConfigurer configure
/// <returns>The <see cref="OptionsConfigurer" /> instance.</returns>
public static OptionsConfigurer EnableCorrelate(this OptionsConfigurer configurer, DependencyResolverAdapter dependencyResolverAdapter)
{
if (configurer == null)
if (configurer is null)
{
throw new ArgumentNullException(nameof(configurer));
}

if (dependencyResolverAdapter == null)
if (dependencyResolverAdapter is null)
{
throw new ArgumentNullException(nameof(dependencyResolverAdapter));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Rebus.Correlate/DependencyResolverAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public DependencyResolverAdapter(Func<Type, object?> optionalResolve)
public TService Get<TService>()
{
TService service = GetOrNull<TService>();
if (service == null)
if (service is null)
{
throw new InvalidOperationException($"Correlate can not be enabled, the service '{typeof(TService).FullName}' can not be resolved.");
}
Expand Down
2 changes: 1 addition & 1 deletion src/Rebus.Correlate/Steps/CorrelateIncomingMessageStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Task Process(IncomingStepContext context, Func<Task> next)
{
Message message = context.Load<Message>();
message.Headers.TryGetValue(Headers.CorrelationId, out string? correlationId);
if (correlationId != null)
if (correlationId is not null)
{
_logger.Debug("Correlation ID: {CorrelationId}", correlationId);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Rebus.Correlate/Steps/CorrelateOutgoingMessageStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Task Process(OutgoingStepContext context, Func<Task> next)
int correlationSequence = 0;
ITransactionContext transactionContext = context.Load<ITransactionContext>();
IncomingStepContext incomingStepContext = transactionContext.GetOrNull<IncomingStepContext>(StepContext.StepContextKey);
if (incomingStepContext != null)
if (incomingStepContext is not null)
{
correlationSequence = GetCorrelationSequence(incomingStepContext) + 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static BuiltinHandlerActivator Handle<TMessage>(this BuiltinHandlerActiva
{
await handlerFunction(message);
}
catch (Exception ex) when (onError != null)
catch (Exception ex) when (onError is not null)
{
onError(ex);
}
Expand Down
2 changes: 1 addition & 1 deletion test/Rebus.Correlate.Tests/Fixtures/RebusFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public IBus Start()

protected void Configure(Action<RebusConfigurer> configureRebus)
{
if (configureRebus == null)
if (configureRebus is null)
{
throw new ArgumentNullException(nameof(configureRebus));
}
Expand Down

0 comments on commit 29b2d79

Please sign in to comment.