Skip to content

Commit 0493401

Browse files
committed
switch to NRT for the whole client
1 parent e247e8b commit 0493401

File tree

97 files changed

+1474
-679
lines changed

Some content is hidden

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

97 files changed

+1474
-679
lines changed

projects/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<PackageVersion Include="Ductus.FluentDocker" Version="2.10.59" />
88
<PackageVersion Include="EasyNetQ.Management.Client" Version="2.0.0" />
99
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
10+
<PackageVersion Include="Nullable" Version="1.3.1" />
1011
<PackageVersion Include="OpenTelemetry.Api" Version="1.7.0" />
1112
<PackageVersion Include="OpenTelemetry.Exporter.InMemory" Version="1.8.0" />
1213
<!--
@@ -41,7 +42,6 @@
4142
<GlobalPackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
4243
</ItemGroup>
4344
<ItemGroup Condition="'$(IsPackable)'=='true'">
44-
<GlobalPackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" />
4545
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
4646
<GlobalPackageReference Include="MinVer" Version="5.0.0" />
4747
</ItemGroup>

projects/RabbitMQ.Client/FrameworkExtension/DictionaryExtension.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
namespace RabbitMQ
3535
{
36-
#nullable enable
3736
#if NETSTANDARD
3837
internal static class DictionaryExtension
3938
{

projects/RabbitMQ.Client/RabbitMQ.Client.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
https://devblogs.microsoft.com/dotnet/embracing-nullable-reference-types/#what-should-library-authors-do
3535
Note: only setting language version 8.0 for nullable reference types!
3636
-->
37-
<LangVersion>8.0</LangVersion>
37+
<LangVersion>9.0</LangVersion>
38+
<Nullable>enable</Nullable>
3839
</PropertyGroup>
3940

4041
<PropertyGroup Condition="'$(Configuration)' == 'Release' And '$(CI)' == 'true'">
@@ -64,6 +65,7 @@
6465
See https://github.com/rabbitmq/rabbitmq-dotnet-client/pull/1481#pullrequestreview-1847905299
6566
-->
6667
<PackageReference Include="System.IO.Pipelines" />
68+
<PackageReference Include="Nullable" PrivateAssets="all" />
6769
</ItemGroup>
6870

6971
<ItemGroup Condition="$(TargetFramework) == 'netstandard2.0'">

projects/RabbitMQ.Client/client/api/AmqpTcpEndpoint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public static AmqpTcpEndpoint[] ParseMultiple(string addresses)
266266
/// <summary>
267267
/// Compares this instance by value (protocol, hostname, port) against another instance.
268268
/// </summary>
269-
public override bool Equals(object obj)
269+
public override bool Equals(object? obj)
270270
{
271271
if (!(obj is AmqpTcpEndpoint other))
272272
{

projects/RabbitMQ.Client/client/api/AmqpTimestamp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public AmqpTimestamp(long unixTime) : this()
6666

6767
public bool Equals(AmqpTimestamp other) => UnixTime == other.UnixTime;
6868

69-
public override bool Equals(object obj) => obj is AmqpTimestamp other && Equals(other);
69+
public override bool Equals(object? obj) => obj is AmqpTimestamp other && Equals(other);
7070

7171
public override int GetHashCode() => UnixTime.GetHashCode();
7272

projects/RabbitMQ.Client/client/api/AsyncDefaultBasicConsumer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public string[] ConsumerTags
4848
/// If our <see cref="IChannel"/> shuts down, this property will contain a description of the reason for the
4949
/// shutdown. Otherwise it will contain null. See <see cref="ShutdownEventArgs"/>.
5050
/// </summary>
51-
public ShutdownEventArgs ShutdownReason { get; protected set; }
51+
public ShutdownEventArgs? ShutdownReason { get; protected set; }
5252

5353
/// <summary>
5454
/// Signalled when the consumer gets cancelled.
@@ -64,7 +64,7 @@ public event AsyncEventHandler<ConsumerEventArgs> ConsumerCancelled
6464
/// Retrieve the <see cref="IChannel"/> this consumer is associated with,
6565
/// for use in acknowledging received messages, for instance.
6666
/// </summary>
67-
public IChannel Channel { get; set; }
67+
public IChannel? Channel { get; set; }
6868

6969
/// <summary>
7070
/// Called when the consumer is cancelled for reasons other than by a basicCancel:

projects/RabbitMQ.Client/client/api/BasicCredentialsProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class BasicCredentialsProvider : ICredentialsProvider
3939
private readonly string _userName;
4040
private readonly string _password;
4141

42-
public BasicCredentialsProvider(string name, string userName, string password)
42+
public BasicCredentialsProvider(string? name, string userName, string password)
4343
{
4444
_name = name ?? string.Empty;
4545
_userName = userName ?? throw new ArgumentNullException(nameof(userName));

projects/RabbitMQ.Client/client/api/BasicProperties.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131

3232
using System;
3333
using System.Collections.Generic;
34+
using System.Diagnostics.CodeAnalysis;
3435
using RabbitMQ.Client.Framing.Impl;
3536
using RabbitMQ.Client.Impl;
3637

3738
namespace RabbitMQ.Client
3839
{
39-
#nullable enable
4040
/// <summary>
4141
/// AMQP specification content header properties for content class "basic".
4242
/// </summary>
@@ -74,7 +74,7 @@ public PublicationAddress? ReplyToAddress
7474
{
7575
get
7676
{
77-
PublicationAddress.TryParse(ReplyTo, out PublicationAddress result);
77+
PublicationAddress.TryParse(ReplyTo, out PublicationAddress? result);
7878
return result;
7979
}
8080

@@ -85,7 +85,7 @@ public BasicProperties()
8585
{
8686
}
8787

88-
public BasicProperties(ReadOnlyBasicProperties input)
88+
public BasicProperties(IReadOnlyBasicProperties input)
8989
{
9090
ContentType = input.ContentType;
9191
ContentEncoding = input.ContentEncoding;
@@ -118,19 +118,30 @@ public BasicProperties(ReadOnlyBasicProperties input)
118118
public void ClearAppId() => AppId = default;
119119
public void ClearClusterId() => ClusterId = default;
120120

121+
[MemberNotNullWhen(true, nameof(ContentType))]
121122
public bool IsContentTypePresent() => ContentType != default;
123+
[MemberNotNullWhen(true, nameof(ContentEncoding))]
122124
public bool IsContentEncodingPresent() => ContentEncoding != default;
125+
[MemberNotNullWhen(true, nameof(Headers))]
123126
public bool IsHeadersPresent() => Headers != default;
124127
public bool IsDeliveryModePresent() => DeliveryMode != default;
125128
public bool IsPriorityPresent() => Priority != default;
129+
[MemberNotNullWhen(true, nameof(CorrelationId))]
126130
public bool IsCorrelationIdPresent() => CorrelationId != default;
131+
[MemberNotNullWhen(true, nameof(ReplyTo))]
127132
public bool IsReplyToPresent() => ReplyTo != default;
133+
[MemberNotNullWhen(true, nameof(Expiration))]
128134
public bool IsExpirationPresent() => Expiration != default;
135+
[MemberNotNullWhen(true, nameof(MessageId))]
129136
public bool IsMessageIdPresent() => MessageId != default;
130137
public bool IsTimestampPresent() => Timestamp != default;
138+
[MemberNotNullWhen(true, nameof(Type))]
131139
public bool IsTypePresent() => Type != default;
140+
[MemberNotNullWhen(true, nameof(UserId))]
132141
public bool IsUserIdPresent() => UserId != default;
142+
[MemberNotNullWhen(true, nameof(AppId))]
133143
public bool IsAppIdPresent() => AppId != default;
144+
[MemberNotNullWhen(true, nameof(ClusterId))]
134145
public bool IsClusterIdPresent() => ClusterId != default;
135146

136147
ushort IAmqpHeader.ProtocolClassId => ClassConstants.Basic;

projects/RabbitMQ.Client/client/api/BinaryTableValue.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
// Copyright (c) 2007-2024 Broadcom. All Rights Reserved.
3030
//---------------------------------------------------------------------------
3131

32+
using System;
33+
3234
namespace RabbitMQ.Client
3335
{
3436
/// <summary>Wrapper for a byte[]. May appear as values read from
@@ -61,9 +63,9 @@ namespace RabbitMQ.Client
6163
public class BinaryTableValue
6264
{
6365
/// <summary>
64-
/// Creates a new instance of the <see cref="BinaryTableValue"/> with null for its Bytes property.
66+
/// Creates a new instance of the <see cref="BinaryTableValue"/> with an empty array for its Bytes property.
6567
/// </summary>
66-
public BinaryTableValue() : this(null)
68+
public BinaryTableValue() : this(Array.Empty<byte>())
6769
{
6870
}
6971

projects/RabbitMQ.Client/client/api/ConnectionConfig.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
namespace RabbitMQ.Client
3939
{
40-
#nullable enable
4140
/// <summary>
4241
/// The configuration of a connection.
4342
/// </summary>
@@ -151,7 +150,7 @@ public sealed class ConnectionConfig
151150
internal readonly Func<AmqpTcpEndpoint, CancellationToken, Task<IFrameHandler>> FrameHandlerFactoryAsync;
152151

153152
internal ConnectionConfig(string virtualHost, string userName, string password,
154-
ICredentialsProvider credentialsProvider, ICredentialsRefresher credentialsRefresher,
153+
ICredentialsProvider? credentialsProvider, ICredentialsRefresher credentialsRefresher,
155154
IEnumerable<IAuthMechanismFactory> authMechanisms,
156155
IDictionary<string, object?> clientProperties, string? clientProvidedName,
157156
ushort maxChannelCount, uint maxFrameSize, uint maxInboundMessageBodySize, bool topologyRecoveryEnabled,

0 commit comments

Comments
 (0)