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

Fix RC2 analyzer warnings #576

Merged
merged 1 commit into from
Oct 12, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public partial class TestableAuditContext : TestableBehaviorContext, IAuditConte
/// <summary>
/// The message to be audited.
/// </summary>
public OutgoingMessage Message { get; set; } = new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), new byte[0]);
public OutgoingMessage Message { get; set; } = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty<byte>());

/// <summary>
/// Metadata of the audited message.
/// </summary>
public Dictionary<string, string> AuditMetadata { get; set; } = new Dictionary<string, string>();
public Dictionary<string, string> AuditMetadata { get; set; } = [];

/// <summary>
/// This method is being removed from IAuditContext, so this stub method remains until the removal is done in v10.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public TestableIncomingLogicalMessageContext(IMessageCreator messageCreator = nu
/// <summary>
/// Headers for the incoming message.
/// </summary>
public Dictionary<string, string> Headers { get; set; } = new Dictionary<string, string>();
public Dictionary<string, string> Headers { get; set; } = [];

/// <summary>
/// Tells if the message has been handled.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace NServiceBus.Testing
{
using System;
using System.Collections.Generic;
using Pipeline;
using Transport;

Expand All @@ -15,7 +14,7 @@ public partial class TestableIncomingPhysicalMessageContext : TestableIncomingCo
/// </summary>
public TestableIncomingPhysicalMessageContext()
{
Message = new IncomingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), new byte[] { });
Message = new IncomingMessage(Guid.NewGuid().ToString(), [], Array.Empty<byte>());
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void DoNotContinueDispatchingCurrentMessageToHandlers()
/// <summary>
/// Message headers.
/// </summary>
public Dictionary<string, string> Headers { get; set; } = new Dictionary<string, string>();
public Dictionary<string, string> Headers { get; set; } = [];

/// <summary>
/// The message instance being handled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public partial class TestableOutgoingContext : TestablePipelineContext, IOutgoin
/// <summary>
/// The headers of the outgoing message.
/// </summary>
public Dictionary<string, string> Headers { get; set; } = new Dictionary<string, string>();
public Dictionary<string, string> Headers { get; set; } = [];

/// <summary>
/// Selects the builder returned by <see cref="IBehaviorContext.Builder" />. Override this method to provide your custom <see cref="IServiceProvider" /> implementation.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace NServiceBus.Testing
{
using System;
using System.Collections.Generic;
using Pipeline;
using Routing;
Expand All @@ -25,6 +26,6 @@ public virtual void UpdateMessage(object newInstance)
/// <summary>
/// The routing strategies for this message.
/// </summary>
public IReadOnlyCollection<RoutingStrategy> RoutingStrategies { get; set; } = new RoutingStrategy[0];
public IReadOnlyCollection<RoutingStrategy> RoutingStrategies { get; set; } = Array.Empty<RoutingStrategy>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public virtual void UpdateMessage(ReadOnlyMemory<byte> body)
/// <summary>
/// A <see cref="T:System.Byte" /> array containing the serialized contents of the outgoing message.
/// </summary>
public ReadOnlyMemory<byte> Body { get; set; } = new byte[0];
public ReadOnlyMemory<byte> Body { get; set; } = Array.Empty<byte>();

/// <summary>
/// The routing strategies for this message.
/// </summary>
public IReadOnlyCollection<RoutingStrategy> RoutingStrategies { get; set; } = new RoutingStrategy[0];
public IReadOnlyCollection<RoutingStrategy> RoutingStrategies { get; set; } = Array.Empty<RoutingStrategy>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class TestableRecoverabilityContext : TestableBehaviorContext, IR
/// <summary>
/// The message that failed processing.
/// </summary>
public IncomingMessage FailedMessage { get; set; } = new IncomingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), ReadOnlyMemory<byte>.Empty);
public IncomingMessage FailedMessage { get; set; } = new IncomingMessage(Guid.NewGuid().ToString(), [], ReadOnlyMemory<byte>.Empty);

/// <summary>
/// The exception that caused processing to fail.
Expand Down Expand Up @@ -46,7 +46,7 @@ public partial class TestableRecoverabilityContext : TestableBehaviorContext, IR
public RecoverabilityConfig RecoverabilityConfiguration { get; set; } = new RecoverabilityConfig(
new ImmediateConfig(0),
new DelayedConfig(0, TimeSpan.Zero),
new FailedConfig("error", new HashSet<Type>()));
new FailedConfig("error", []));

/// <summary>
/// The recoverability action to take for this message.
Expand All @@ -56,7 +56,7 @@ public partial class TestableRecoverabilityContext : TestableBehaviorContext, IR
/// <summary>
/// Metadata for this message.
/// </summary>
public Dictionary<string, string> Metadata { get; set; } = new Dictionary<string, string>();
public Dictionary<string, string> Metadata { get; set; } = [];

/// <summary>
/// Locks the recoverability action for further changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public partial class TestableRoutingContext : TestableBehaviorContext, IRoutingC
/// <summary>
/// The message to dispatch the the transport.
/// </summary>
public OutgoingMessage Message { get; set; } = new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), new byte[0]);
public OutgoingMessage Message { get; set; } = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty<byte>());

/// <summary>
/// The routing strategies for the operation to be dispatched.
/// </summary>
public IReadOnlyCollection<RoutingStrategy> RoutingStrategies { get; set; } = new RoutingStrategy[0];
public IReadOnlyCollection<RoutingStrategy> RoutingStrategies { get; set; } = Array.Empty<RoutingStrategy>();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace NServiceBus.Testing
{
using System;
using System.Collections.Generic;
using Pipeline;
using Transport;

Expand All @@ -26,6 +25,6 @@ public virtual void AbortReceiveOperation()
/// <summary>
/// The physical message being processed.
/// </summary>
public IncomingMessage Message { get; set; } = new IncomingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), new byte[0]);
public IncomingMessage Message { get; set; } = new IncomingMessage(Guid.NewGuid().ToString(), [], Array.Empty<byte>());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public void Rollback()
actions.Clear();
}

List<Action> actions = new List<Action>();
List<Action> actions = [];
}
}
2 changes: 1 addition & 1 deletion src/NServiceBus.Testing/Sagas/QueuedSagaMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal QueuedSagaMessage(Type type, object message, IReadOnlyDictionary<string

if (autoCorrelatedSagaId.HasValue)
{
var editable = headers as Dictionary<string, string> ?? headers?.ToDictionary(kvp => kvp.Key, kvp => kvp.Value) ?? new Dictionary<string, string>();
var editable = headers as Dictionary<string, string> ?? headers?.ToDictionary(kvp => kvp.Key, kvp => kvp.Value) ?? [];
editable[NServiceBus.Headers.SagaId] = autoCorrelatedSagaId.Value.ToString();
Headers = editable;
}
Expand Down
2 changes: 1 addition & 1 deletion src/NServiceBus.Testing/Sagas/SagaMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public Task InvokeHandlerMethod<TSaga>(TSaga saga, string methodName, QueuedSaga

class MappingReader : IConfigureHowToFindSagaWithMessage, IConfigureHowToFindSagaWithMessageHeaders
{
readonly Dictionary<Type, Func<QueuedSagaMessage, object>> mappings = new Dictionary<Type, Func<QueuedSagaMessage, object>>();
readonly Dictionary<Type, Func<QueuedSagaMessage, object>> mappings = [];

void IConfigureHowToFindSagaWithMessage.ConfigureMapping<TSagaEntity, TMessage>(Expression<Func<TSagaEntity, object>> sagaEntityProperty, Expression<Func<TMessage, object>> messageProperty)
{
Expand Down