Skip to content

Commit a8dc8ce

Browse files
authored
Merge pull request #1741 from danielmarbach/condition
Simplify preprocessor directives
2 parents e4e05a0 + 8109c96 commit a8dc8ce

15 files changed

+23
-23
lines changed

projects/RabbitMQ.Client.OAuth2/CredentialsRefresherEventSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class CredentialsRefresherEventSource : EventSource
4646
public void Stopped(string name) => WriteEvent(2, "Stopped", name);
4747

4848
[Event(3)]
49-
#if NET6_0_OR_GREATER
49+
#if NET
5050
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Parameters to this method are primitive and are trimmer safe")]
5151
#endif
5252
public void RefreshedCredentials(string name) => WriteEvent(3, "RefreshedCredentials", name);

projects/RabbitMQ.Client/DefaultEndpointResolver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace RabbitMQ.Client
3737
{
3838
public class DefaultEndpointResolver : IEndpointResolver
3939
{
40-
#if !NET6_0_OR_GREATER
40+
#if !NET
4141
private readonly Random s_rnd = new Random();
4242
#endif
4343
private readonly List<AmqpTcpEndpoint> _endpoints;
@@ -49,7 +49,7 @@ public DefaultEndpointResolver(IEnumerable<AmqpTcpEndpoint> tcpEndpoints)
4949

5050
public IEnumerable<AmqpTcpEndpoint> All()
5151
{
52-
#if NET6_0_OR_GREATER
52+
#if NET
5353
return _endpoints.OrderBy(item => Random.Shared.Next());
5454
#else
5555
return _endpoints.OrderBy(item => s_rnd.Next());

projects/RabbitMQ.Client/Impl/AsyncManualResetEvent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public async ValueTask WaitAsync(CancellationToken cancellationToken)
6464
cancellationToken.ThrowIfCancellationRequested();
6565

6666
CancellationTokenRegistration tokenRegistration =
67-
#if NET6_0_OR_GREATER
67+
#if NET
6868
cancellationToken.UnsafeRegister(
6969
static state =>
7070
{
@@ -87,7 +87,7 @@ public async ValueTask WaitAsync(CancellationToken cancellationToken)
8787
}
8888
finally
8989
{
90-
#if NET6_0_OR_GREATER
90+
#if NET
9191
await tokenRegistration.DisposeAsync()
9292
.ConfigureAwait(false);
9393
#else

projects/RabbitMQ.Client/Impl/AsyncRpcContinuations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public AsyncRpcContinuation(TimeSpan continuationTimeout, CancellationToken canc
6060
*/
6161
_continuationTimeoutCancellationTokenSource = new CancellationTokenSource(continuationTimeout);
6262

63-
#if NET6_0_OR_GREATER
63+
#if NET
6464
_continuationTimeoutCancellationTokenRegistration = _continuationTimeoutCancellationTokenSource.Token.UnsafeRegister((object? state) =>
6565
{
6666
var tcs = (TaskCompletionSource<T>)state!;

projects/RabbitMQ.Client/Impl/Connection.Commands.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private async ValueTask StartAndTuneAsync(CancellationToken cancellationToken)
7676
{
7777
var connectionStartCell = new TaskCompletionSource<ConnectionStartDetails?>(TaskCreationOptions.RunContinuationsAsynchronously);
7878

79-
#if NET6_0_OR_GREATER
79+
#if NET
8080
using CancellationTokenRegistration ctr = cancellationToken.UnsafeRegister((object? state) =>
8181
{
8282
if (state != null)
@@ -197,7 +197,7 @@ private IAuthMechanismFactory GetAuthMechanismFactory(string supportedMechanismN
197197
// Our list is in order of preference, the server one is not.
198198
foreach (IAuthMechanismFactory factory in _config.AuthMechanisms)
199199
{
200-
#if NET6_0_OR_GREATER
200+
#if NET
201201
if (supportedMechanismNames.Contains(factory.Name, StringComparison.OrdinalIgnoreCase))
202202
#else
203203
if (supportedMechanismNames.IndexOf(factory.Name, StringComparison.OrdinalIgnoreCase) >= 0)

projects/RabbitMQ.Client/Impl/RecordedBinding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public override bool Equals(object? obj)
106106

107107
public override int GetHashCode()
108108
{
109-
#if NET6_0_OR_GREATER
109+
#if NET
110110
return HashCode.Combine(_isQueueBinding, _destination, _source, _routingKey, _arguments);
111111
#else
112112
unchecked

projects/RabbitMQ.Client/Impl/SocketFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static async Task<ITcpClient> OpenAsync(AmqpTcpEndpoint amqpTcpEndpoint,
4545
{
4646
IPAddress[] ipAddresses = await Dns.GetHostAddressesAsync(
4747
amqpTcpEndpoint.HostName
48-
#if NET6_0_OR_GREATER
48+
#if NET
4949
, cancellationToken
5050
#endif
5151
).ConfigureAwait(false);

projects/RabbitMQ.Client/Impl/SslHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static async Task<Stream> TcpUpgradeAsync(Stream tcpStream, SslOption opt
6868

6969
Task TryAuthenticating(SslOption opts)
7070
{
71-
#if NET6_0_OR_GREATER
71+
#if NET
7272
X509RevocationMode certificateRevocationCheckMode = X509RevocationMode.NoCheck;
7373
if (opts.CheckCertificateRevocation)
7474
{

projects/RabbitMQ.Client/Impl/WireFormatting.Read.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public static int ReadShortstr(ReadOnlySpan<byte> span, out string value)
172172
// equals span.Length >= byteCount + 1
173173
if (span.Length > byteCount)
174174
{
175-
#if NETCOREAPP
175+
#if NET
176176
value = UTF8.GetString(span.Slice(1, byteCount));
177177
#else
178178
unsafe

projects/RabbitMQ.Client/Impl/WireFormatting.Write.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static int GetArrayByteCount(IList? val)
8686
}
8787

8888
[MethodImpl(MethodImplOptions.AggressiveInlining)]
89-
#if NETCOREAPP
89+
#if NET
9090
public static int GetByteCount(ReadOnlySpan<char> val) => val.IsEmpty ? 0 : UTF8.GetByteCount(val);
9191
#else
9292
public static int GetByteCount(string val) => string.IsNullOrEmpty(val) ? 0 : UTF8.GetByteCount(val);

0 commit comments

Comments
 (0)