Skip to content

Commit 0e5eb97

Browse files
Enable Nullable on the solution (#1753)
* Enable nullable * Approve API changes * Add validation to AuthMechanisms property * Improve property validation messages * Use factory method to create ConfirmsAwareChannel * Refine null check for message header lookup in `SendMessage`. * Simplify `PublishMessage` and `RawSendInCaseOfFailure` methods by converting to expression-bodied implementations. * Refine header lookup and initialization in `MessagePump` for improved null safety and cleaner logic. * Simplify `Channel_ModelShutdown` logic by consolidating conditional checks. --------- Co-authored-by: Daniel Marbach <danielmarbach@users.noreply.github.com>
1 parent 11c3e98 commit 0e5eb97

File tree

81 files changed

+361
-291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+361
-291
lines changed

src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/ChannelExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests
1+
#nullable enable
2+
3+
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests
24
{
35
using System.Collections.Generic;
46
using System.Threading.Tasks;
@@ -8,7 +10,7 @@ static class ChannelExtensions
810
{
911
public static Task<QueueDeclareOk> DeclareQuorumQueue(this IChannel channel, string queueName)
1012
{
11-
return channel.QueueDeclareAsync(queueName, true, false, false, new Dictionary<string, object>
13+
return channel.QueueDeclareAsync(queueName, true, false, false, new Dictionary<string, object?>
1214
{
1315
{ "x-queue-type", "quorum" }
1416
});

src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/ConfigurationHelpers.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using NServiceBus;
1+
#nullable enable
2+
3+
using NServiceBus;
24
using NServiceBus.AcceptanceTests.EndpointTemplates;
35

46
static class ConfigurationHelpers

src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/ConfigureEndpointRabbitMQTransport.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
#nullable enable
2+
3+
using System;
24
using System.Collections.Generic;
35
using System.Linq;
46
using System.Threading;
@@ -10,7 +12,7 @@
1012

1113
class ConfigureEndpointRabbitMQTransport : IConfigureEndpointTestExecution
1214
{
13-
TestRabbitMQTransport transport;
15+
TestRabbitMQTransport? transport;
1416
readonly QueueType queueType;
1517

1618
public ConfigureEndpointRabbitMQTransport(QueueType queueType = QueueType.Classic)
@@ -20,7 +22,7 @@ public ConfigureEndpointRabbitMQTransport(QueueType queueType = QueueType.Classi
2022

2123
public Task Configure(string endpointName, EndpointConfiguration configuration, RunSettings settings, PublisherMetadata publisherMetadata)
2224
{
23-
transport = new TestRabbitMQTransport(RoutingTopology.Conventional(queueType, type => type.FullName), ConnectionHelper.ConnectionString)
25+
transport = new TestRabbitMQTransport(RoutingTopology.Conventional(queueType, type => type.FullName!), ConnectionHelper.ConnectionString)
2426
{
2527
// The startup costs for creating a policy for every test queue add up, and the tests shouldn't be impacted by the default delivery limit.
2628
ValidateDeliveryLimits = false

src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/ConnectionHelper.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests
1+
#nullable enable
2+
3+
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests
24
{
35
using System;
46
using System.Security.Authentication;

src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/DelayedDelivery/When_deferring_a_message_longer_than_allowed_maximum.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests.DelayedDelivery
1+
#nullable enable
2+
3+
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests.DelayedDelivery
24
{
35
using System;
46
using System.Threading.Tasks;

src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/QuorumEndpoint.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests
1+
#nullable enable
2+
3+
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests
24
{
35
using NServiceBus.AcceptanceTests.EndpointTemplates;
46

src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/QuorumQueues/When_classic_endpoint_uses_quorum_error_queue.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests
1+
#nullable enable
2+
3+
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests
24
{
35
using System;
46
using System.Threading.Tasks;

src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/QuorumQueues/When_classic_endpoint_uses_quorum_queue.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests
1+
#nullable enable
2+
3+
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests
24
{
35
using System;
46
using System.Threading.Tasks;

src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/QuorumQueues/When_immediate_retries_with_quorum_queues.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests
1+
#nullable enable
2+
3+
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests
24
{
35
using System;
46
using System.Linq;
@@ -23,8 +25,7 @@ public async Task Should_do_the_configured_number_of_retries()
2325
{
2426
Assert.That(context.ForwardedToErrorQueue, Is.True);
2527
Assert.That(context.NumberOfTimesInvoked, Is.EqualTo(numberOfRetries + 1), "Message should be retried 5 times immediately");
26-
Assert.That(context.Logs.Count(l => l.Message
27-
.StartsWith($"Immediate Retry is going to retry message '{context.MessageId}' because of an exception:")), Is.EqualTo(numberOfRetries));
28+
Assert.That(context.Logs.Count(l => l.Message?.StartsWith($"Immediate Retry is going to retry message '{context.MessageId}' because of an exception:") ?? false), Is.EqualTo(numberOfRetries));
2829
});
2930
}
3031

@@ -36,7 +37,7 @@ class Context : ScenarioContext
3637

3738
public bool ForwardedToErrorQueue { get; set; }
3839

39-
public string MessageId { get; set; }
40+
public string? MessageId { get; set; }
4041
}
4142

4243
public class RetryEndpoint : EndpointConfigurationBuilder

src/NServiceBus.Transport.RabbitMQ.AcceptanceTests/QuorumQueues/When_quorum_endpoint_uses_classic_error_queue.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests
1+
#nullable enable
2+
3+
namespace NServiceBus.Transport.RabbitMQ.AcceptanceTests
24
{
35
using System;
46
using System.Threading.Tasks;

0 commit comments

Comments
 (0)