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 #1313

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 @@ -74,6 +74,6 @@ public override async Task<TransportInfrastructure> Initialize(HostSettings host
return infrastructure;
}

public List<string> QueuesToCleanup { get; } = new List<string>();
public List<string> QueuesToCleanup { get; } = [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async Task BreakConnectionBySendingInvalidMessage(CancellationToken cancellation
{
try
{
var outgoingMessage = new OutgoingMessage("Foo", new Dictionary<string, string>(), new byte[0]);
var outgoingMessage = new OutgoingMessage("Foo", [], new byte[0]);
var props = new DispatchProperties
{
DiscardIfNotReceivedBefore =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public OutgoingMessageBuilder WithIntent(MessageIntent intent)
Type eventType;
string messageId = Guid.NewGuid().ToString();
byte[] body;
Dictionary<string, string> headers = new Dictionary<string, string>();
DispatchProperties constraints = new DispatchProperties();
Dictionary<string, string> headers = [];
DispatchProperties constraints = [];
DispatchConsistency dispatchConsistency = DispatchConsistency.Default;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public override Task SetUp()
[Test]
public async Task Header_collection_is_null_after_redelivery_for_headerless_messages()
{
var message = new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), Array.Empty<byte>());
var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty<byte>());
var headerCollectionWasNullOnFirstDelivery = false;
var headerCollectionWasNullOnRedelivery = new TaskCompletionSource<bool>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class When_consuming_messages : RabbitMqContext
[Test]
public async Task Should_block_until_a_message_is_available()
{
var message = new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), Array.Empty<byte>());
var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty<byte>());
var transportOperations = new TransportOperations(new TransportOperation(message, new UnicastAddressTag(ReceiverQueue)));

await messageDispatcher.Dispatch(transportOperations, new TransportTransaction());
Expand All @@ -26,7 +26,7 @@ public async Task Should_block_until_a_message_is_available()
[Test]
public void Should_be_able_to_receive_messages_without_headers()
{
var message = new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), Array.Empty<byte>());
var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty<byte>());

using (var connection = connectionFactory.CreatePublishConnection())
using (var channel = connection.CreateModel())
Expand All @@ -46,7 +46,7 @@ public void Should_be_able_to_receive_messages_without_headers()
[Test]
public void Should_move_message_without_message_id_to_error_queue()
{
var message = new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), Array.Empty<byte>());
var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty<byte>());

using (var connection = connectionFactory.CreatePublishConnection())
using (var channel = connection.CreateModel())
Expand All @@ -67,7 +67,7 @@ public void Should_move_message_without_message_id_to_error_queue()
[Test]
public async Task Should_handle_retries_for_messages_without_headers()
{
var message = new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), Array.Empty<byte>());
var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty<byte>());
var numRetries = 0;
var handled = new TaskCompletionSource<bool>();

Expand Down Expand Up @@ -109,7 +109,7 @@ public async Task Should_handle_retries_for_messages_without_headers()
[Test]
public async Task Header_collection_is_not_null_after_redelivery_for_headerless_messages()
{
var message = new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), Array.Empty<byte>());
var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty<byte>());
var headerCollectionWasNullOnFirstDelivery = false;
var headerCollectionWasNullOnRedelivery = new TaskCompletionSource<bool>();

Expand Down Expand Up @@ -154,7 +154,7 @@ public async Task Header_collection_is_not_null_after_redelivery_for_headerless_
[Test]
public void Should_up_convert_the_native_type_to_the_enclosed_message_types_header_if_empty()
{
var message = new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), Array.Empty<byte>());
var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty<byte>());

var typeName = typeof(MyMessage).FullName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ConnectionFactory

readonly string endpointName;
readonly global::RabbitMQ.Client.ConnectionFactory connectionFactory;
readonly List<AmqpTcpEndpoint> endpoints = new();
readonly List<AmqpTcpEndpoint> endpoints = [];
readonly object lockObject = new();

public ConnectionFactory(string endpointName, ConnectionConfiguration connectionConfiguration, X509Certificate2Collection clientCertificateCollection, bool disableRemoteCertificateValidation, bool useExternalAuthMechanism, TimeSpan heartbeatInterval, TimeSpan networkRecoveryInterval, List<(string hostName, int port, bool useTls)> additionalClusterNodes)
Expand Down
2 changes: 1 addition & 1 deletion src/NServiceBus.Transport.RabbitMQ/RabbitMQTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class RabbitMQTransport : TransportDefinition
PrefetchCountCalculation prefetchCountCalculation = maxConcurrency => 3 * maxConcurrency;
TimeSpan timeToWaitBeforeTriggeringCircuitBreaker = TimeSpan.FromMinutes(2);

readonly List<(string hostName, int port, bool useTls)> additionalClusterNodes = new();
readonly List<(string hostName, int port, bool useTls)> additionalClusterNodes = [];

/// <summary>
/// Creates a new instance of the RabbitMQ transport.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace NServiceBus.Transport.RabbitMQ
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
Expand All @@ -16,7 +15,7 @@ public static void Fill(this IBasicProperties properties, OutgoingMessage messag
properties.MessageId = message.MessageId;
}

var messageHeaders = message.Headers ?? new Dictionary<string, string>();
var messageHeaders = message.Headers ?? [];

var delayed = CalculateDelay(dispatchProperties, out var delay);

Expand Down