Skip to content

Commit

Permalink
Use collection initializers (#1250)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasohlund authored Oct 11, 2023
1 parent 7fc49f7 commit 0749f9c
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ public async Task Outgoing_operations_are_stored_atomically(Type contextProvider
[Test]
public void Proper_exception_is_thrown_if_queue_does_not_exist()
{
var operation = new TransportOperation(new OutgoingMessage("1", new Dictionary<string, string>(), new byte[0]), new UnicastAddressTag("InvalidQueue"));
var operation = new TransportOperation(new OutgoingMessage("1", [], new byte[0]), new UnicastAddressTag("InvalidQueue"));
Assert.That(async () => await dispatcher.Dispatch(new TransportOperations(operation), new TransportTransaction()), Throws.TypeOf<QueueNotFoundException>());
}

static TransportOperation CreateTransportOperation(string id, string destination, DispatchConsistency consistency)
{
return new TransportOperation(
new OutgoingMessage(id, new Dictionary<string, string>(), new byte[0]),
new OutgoingMessage(id, [], new byte[0]),
new UnicastAddressTag(destination),
requiredDispatchConsistency: consistency
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace NServiceBus.Transport.SqlServer.IntegrationTests
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Transactions;
Expand Down Expand Up @@ -50,7 +49,7 @@ static async Task SendMessage(TableBasedQueue tableBasedQueue, SqlConnectionFact
using (var connection = await sqlConnectionFactory.OpenNewConnection(cancellationToken))
using (var tx = connection.BeginTransaction())
{
var message = new OutgoingMessage(Guid.NewGuid().ToString(), new Dictionary<string, string>(), new byte[0]);
var message = new OutgoingMessage(Guid.NewGuid().ToString(), [], new byte[0]);
await tableBasedQueue.Send(message, TimeSpan.MaxValue, connection, tx, cancellationToken);
tx.Commit();
scope.Complete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static IContextProvider CreateContext(Type contextType, SqlConnectionFactory sql
static TransportOperation CreateTransportOperation(string id, string destination, DispatchConsistency consistency)
{
return new TransportOperation(
new OutgoingMessage(id, new Dictionary<string, string>(), new byte[0]),
new OutgoingMessage(id, [], new byte[0]),
new UnicastAddressTag(destination),
requiredDispatchConsistency: consistency
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public async Task Defaults_to_no_ttbr()
context.Set(transportTransaction);

var operation = new TransportOperation(
new OutgoingMessage("1", new Dictionary<string, string>(), new byte[0]),
new OutgoingMessage("1", [], new byte[0]),
new UnicastAddressTag(ValidAddress)
);

Expand Down Expand Up @@ -91,7 +91,7 @@ public async Task Delivery_constraint_is_respected()
context.Set(transportTransaction);

var operation = new TransportOperation(
new OutgoingMessage("1", new Dictionary<string, string>(), new byte[0]),
new OutgoingMessage("1", [], new byte[0]),
new UnicastAddressTag(ValidAddress),
new DispatchProperties
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace NServiceBus.Transport.SqlServer.UnitTests.Sending
{
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Routing;
Expand Down Expand Up @@ -75,7 +74,7 @@ public void It_sorts_isolated_and_default_dispatch()

static TransportOperation CreateTransportOperations(string messageId, string destination, DispatchConsistency dispatchConsistency = DispatchConsistency.Default)
{
return new TransportOperation(new OutgoingMessage(messageId, new Dictionary<string, string>(), new byte[0]), new UnicastAddressTag(destination), requiredDispatchConsistency: dispatchConsistency);
return new TransportOperation(new OutgoingMessage(messageId, [], new byte[0]), new UnicastAddressTag(destination), requiredDispatchConsistency: dispatchConsistency);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Dictionary<string, string> GetProperties(string endpoint)
return result;
}

Dictionary<string, string> schemas = new Dictionary<string, string>();
Dictionary<string, string> catalogs = new Dictionary<string, string>();
Dictionary<string, string> schemas = [];
Dictionary<string, string> catalogs = [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal void TryGet(string queueName, out string schema, out string catalog)
catalogs.TryGetValue(queueName, out catalog);
}

Dictionary<string, string> schemas = new Dictionary<string, string>();
Dictionary<string, string> catalogs = new Dictionary<string, string>();
Dictionary<string, string> schemas = [];
Dictionary<string, string> catalogs = [];
}
}
2 changes: 1 addition & 1 deletion src/NServiceBus.Transport.SqlServer/Queuing/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Message(string transportId, string originalHeaders, byte[] body, bool exp
void InitializeHeaders()
{
var parsedHeaders = string.IsNullOrEmpty(originalHeaders)
? new Dictionary<string, string>()
? []
: DictionarySerializer.DeSerialize(originalHeaders);

LegacyCallbacks.SubstituteReplyToWithCallbackQueueIfExists(parsedHeaders);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void ClearFailureInfoForMessage(string messageId)
}
}

Dictionary<string, FailureInfoNode> failureInfoPerMessage = new Dictionary<string, FailureInfoNode>();
Dictionary<string, FailureInfoNode> failureInfoPerMessage = [];
LinkedList<string> leastRecentlyUsedMessages = new LinkedList<string>();
object lockObject = new object();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class FakePromotableResourceManager : IEnlistmentNotification
ConnectionAttributes connectionAttributes;
QueueAddressTranslator addressTranslator;
DueDelayedMessageProcessor dueDelayedMessageProcessor;
Dictionary<string, object> diagnostics = new Dictionary<string, object>();
Dictionary<string, object> diagnostics = [];
SqlConnectionFactory connectionFactory;
ISubscriptionStore subscriptionStore;
IDelayedMessageStore delayedMessageStore = new SendOnlyDelayedMessageStore();
Expand Down

0 comments on commit 0749f9c

Please sign in to comment.