diff --git a/src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/ConfigureEndpointRabbitMQTransport.cs b/src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/ConfigureEndpointRabbitMQTransport.cs index 887338373..dea4c90a8 100644 --- a/src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/ConfigureEndpointRabbitMQTransport.cs +++ b/src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/ConfigureEndpointRabbitMQTransport.cs @@ -74,6 +74,6 @@ public override async Task Initialize(HostSettings host return infrastructure; } - public List QueuesToCleanup { get; } = new List(); + public List QueuesToCleanup { get; } = []; } } \ No newline at end of file diff --git a/src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/When_the_broker_connection_is_lost.cs b/src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/When_the_broker_connection_is_lost.cs index 9d88f8894..56c976431 100644 --- a/src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/When_the_broker_connection_is_lost.cs +++ b/src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/When_the_broker_connection_is_lost.cs @@ -70,7 +70,7 @@ async Task BreakConnectionBySendingInvalidMessage(CancellationToken cancellation { try { - var outgoingMessage = new OutgoingMessage("Foo", new Dictionary(), new byte[0]); + var outgoingMessage = new OutgoingMessage("Foo", [], new byte[0]); var props = new DispatchProperties { DiscardIfNotReceivedBefore = diff --git a/src/NServiceBus.Transport.RabbitMQ.Tests/OutgoingMessageBuilder.cs b/src/NServiceBus.Transport.RabbitMQ.Tests/OutgoingMessageBuilder.cs index db273029a..28df7a24a 100644 --- a/src/NServiceBus.Transport.RabbitMQ.Tests/OutgoingMessageBuilder.cs +++ b/src/NServiceBus.Transport.RabbitMQ.Tests/OutgoingMessageBuilder.cs @@ -78,8 +78,8 @@ public OutgoingMessageBuilder WithIntent(MessageIntent intent) Type eventType; string messageId = Guid.NewGuid().ToString(); byte[] body; - Dictionary headers = new Dictionary(); - DispatchProperties constraints = new DispatchProperties(); + Dictionary headers = []; + DispatchProperties constraints = []; DispatchConsistency dispatchConsistency = DispatchConsistency.Default; } } \ No newline at end of file diff --git a/src/NServiceBus.Transport.RabbitMQ.Tests/When_consuming_from_classic_queues.cs b/src/NServiceBus.Transport.RabbitMQ.Tests/When_consuming_from_classic_queues.cs index 2580e17d4..7d97347fd 100644 --- a/src/NServiceBus.Transport.RabbitMQ.Tests/When_consuming_from_classic_queues.cs +++ b/src/NServiceBus.Transport.RabbitMQ.Tests/When_consuming_from_classic_queues.cs @@ -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(), Array.Empty()); + var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty()); var headerCollectionWasNullOnFirstDelivery = false; var headerCollectionWasNullOnRedelivery = new TaskCompletionSource(); diff --git a/src/NServiceBus.Transport.RabbitMQ.Tests/When_consuming_messages.cs b/src/NServiceBus.Transport.RabbitMQ.Tests/When_consuming_messages.cs index c2f39191f..7265a073c 100644 --- a/src/NServiceBus.Transport.RabbitMQ.Tests/When_consuming_messages.cs +++ b/src/NServiceBus.Transport.RabbitMQ.Tests/When_consuming_messages.cs @@ -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(), Array.Empty()); + var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty()); var transportOperations = new TransportOperations(new TransportOperation(message, new UnicastAddressTag(ReceiverQueue))); await messageDispatcher.Dispatch(transportOperations, new TransportTransaction()); @@ -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(), Array.Empty()); + var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty()); using (var connection = connectionFactory.CreatePublishConnection()) using (var channel = connection.CreateModel()) @@ -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(), Array.Empty()); + var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty()); using (var connection = connectionFactory.CreatePublishConnection()) using (var channel = connection.CreateModel()) @@ -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(), Array.Empty()); + var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty()); var numRetries = 0; var handled = new TaskCompletionSource(); @@ -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(), Array.Empty()); + var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty()); var headerCollectionWasNullOnFirstDelivery = false; var headerCollectionWasNullOnRedelivery = new TaskCompletionSource(); @@ -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(), Array.Empty()); + var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], Array.Empty()); var typeName = typeof(MyMessage).FullName; diff --git a/src/NServiceBus.Transport.RabbitMQ/Connection/ConnectionFactory.cs b/src/NServiceBus.Transport.RabbitMQ/Connection/ConnectionFactory.cs index d1cd649e2..bdf57dc94 100644 --- a/src/NServiceBus.Transport.RabbitMQ/Connection/ConnectionFactory.cs +++ b/src/NServiceBus.Transport.RabbitMQ/Connection/ConnectionFactory.cs @@ -16,7 +16,7 @@ class ConnectionFactory readonly string endpointName; readonly global::RabbitMQ.Client.ConnectionFactory connectionFactory; - readonly List endpoints = new(); + readonly List 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) diff --git a/src/NServiceBus.Transport.RabbitMQ/RabbitMQTransport.cs b/src/NServiceBus.Transport.RabbitMQ/RabbitMQTransport.cs index 0671f4be9..b6093d680 100644 --- a/src/NServiceBus.Transport.RabbitMQ/RabbitMQTransport.cs +++ b/src/NServiceBus.Transport.RabbitMQ/RabbitMQTransport.cs @@ -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 = []; /// /// Creates a new instance of the RabbitMQ transport. diff --git a/src/NServiceBus.Transport.RabbitMQ/Sending/BasicPropertiesExtensions.cs b/src/NServiceBus.Transport.RabbitMQ/Sending/BasicPropertiesExtensions.cs index 503a7f64b..390df2e6f 100644 --- a/src/NServiceBus.Transport.RabbitMQ/Sending/BasicPropertiesExtensions.cs +++ b/src/NServiceBus.Transport.RabbitMQ/Sending/BasicPropertiesExtensions.cs @@ -1,7 +1,6 @@ namespace NServiceBus.Transport.RabbitMQ { using System; - using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; @@ -16,7 +15,7 @@ public static void Fill(this IBasicProperties properties, OutgoingMessage messag properties.MessageId = message.MessageId; } - var messageHeaders = message.Headers ?? new Dictionary(); + var messageHeaders = message.Headers ?? []; var delayed = CalculateDelay(dispatchProperties, out var delay);