Skip to content

Commit dc89271

Browse files
authored
Merge branch 'main' into feat/add_activity_on_connection
2 parents 06f2d1b + a8dc8ce commit dc89271

23 files changed

+60
-33
lines changed

.github/workflows/build-test.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ jobs:
2020
path: |
2121
~/.nuget/packages
2222
~/AppData/Local/NuGet/v3-cache
23-
key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }}
23+
key: ${{ runner.os }}-v2-nuget-${{ hashFiles('**/*.csproj','projects/Directory.Packages.props') }}
2424
restore-keys: |
25-
${{ runner.os }}-v1-nuget-
25+
${{ runner.os }}-v2-nuget-
2626
- name: Build (Debug)
2727
run: dotnet build ${{ github.workspace }}\Build.csproj
2828
- name: Verify
@@ -142,9 +142,9 @@ jobs:
142142
path: |
143143
~/.nuget/packages
144144
~/.local/share/NuGet/v3-cache
145-
key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }}
145+
key: ${{ runner.os }}-v2-nuget-${{ hashFiles('**/*.csproj','projects/Directory.Packages.props') }}
146146
restore-keys: |
147-
${{ runner.os }}-v1-nuget-
147+
${{ runner.os }}-v2-nuget-
148148
- name: Build (Debug)
149149
run: dotnet build ${{ github.workspace }}/Build.csproj
150150
- name: Verify

projects/Directory.Packages.props

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
-->
1717
<PackageVersion Include="System.IO.Pipelines" Version="8.0.0" />
1818
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
19+
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
20+
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
1921
<PackageVersion Include="System.Threading.RateLimiting" Version="8.0.0" />
2022
<PackageVersion Include="WireMock.Net" Version="1.5.62" />
2123
<PackageVersion Include="xunit" Version="2.9.0" />
@@ -33,13 +35,9 @@
3335
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="8.0.1" />
3436
<PackageVersion Include="System.Memory" Version="4.5.5" />
3537
<PackageVersion Include="System.Threading.Channels" Version="8.0.0" />
36-
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
3738
<PackageVersion Include="System.Net.Http.Json" Version="8.0.1" />
3839
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
3940
</ItemGroup>
40-
<ItemGroup Condition="$(TargetFramework)=='net472'">
41-
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
42-
</ItemGroup>
4341
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
4442
<GlobalPackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
4543
</ItemGroup>

projects/RabbitMQ.Client.OAuth2/CredentialsRefresherEventSource.cs

+1-1
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

+2-2
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

+2-2
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

+1-1
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

+2-2
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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);

projects/RabbitMQ.Client/Logging/RabbitMqClientEventSource.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal sealed partial class RabbitMqClientEventSource : EventSource
4040
{
4141
public static readonly RabbitMqClientEventSource Log = new RabbitMqClientEventSource();
4242

43-
#if NET6_0_OR_GREATER
43+
#if NET
4444
private readonly PollingCounter _connectionOpenedCounter;
4545
private readonly PollingCounter _openConnectionCounter;
4646
private readonly PollingCounter _channelOpenedCounter;
@@ -54,7 +54,7 @@ internal sealed partial class RabbitMqClientEventSource : EventSource
5454
public RabbitMqClientEventSource()
5555
: base("rabbitmq-client")
5656
{
57-
#if NET6_0_OR_GREATER
57+
#if NET
5858
_connectionOpenedCounter = new PollingCounter("total-connections-opened", this, () => s_connectionsOpened)
5959
{
6060
DisplayName = "Total connections opened"
@@ -128,7 +128,7 @@ public void Warn(string message)
128128
}
129129
}
130130

131-
#if NET6_0_OR_GREATER
131+
#if NET
132132
[Event(3, Keywords = Keywords.Log, Level = EventLevel.Error)]
133133
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The properties are preserved with the DynamicallyAccessedMembers attribute.")]
134134
public void Error(string message, RabbitMqExceptionDetail ex)

projects/RabbitMQ.Client/TaskExtensions.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace RabbitMQ.Client
3737
{
3838
internal static class TaskExtensions
3939
{
40-
#if NET6_0_OR_GREATER
40+
#if NET
4141
public static bool IsCompletedSuccessfully(this Task task)
4242
{
4343
return task.IsCompletedSuccessfully;
@@ -49,7 +49,7 @@ public static bool IsCompletedSuccessfully(this Task task)
4949
}
5050
#endif
5151

52-
#if !NET6_0_OR_GREATER
52+
#if !NET
5353
private static readonly TaskContinuationOptions s_tco = TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously;
5454
private static void IgnoreTaskContinuation(Task t, object s) => t.Exception.Handle(e => true);
5555

@@ -126,7 +126,7 @@ private static async Task DoWaitAsync(this Task task, CancellationToken cancella
126126

127127
public static Task WaitAsync(this Task task, TimeSpan timeout)
128128
{
129-
#if NET6_0_OR_GREATER
129+
#if NET
130130
if (task.IsCompletedSuccessfully)
131131
{
132132
return task;
@@ -171,7 +171,7 @@ public static async ValueTask TimeoutAfter(this ValueTask valueTask, TimeSpan ti
171171
return;
172172
}
173173

174-
#if NET6_0_OR_GREATER
174+
#if NET
175175
Task task = valueTask.AsTask();
176176
await task.WaitAsync(timeout)
177177
.ConfigureAwait(false);

projects/RabbitMQ.Client/TcpClientAdapter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public TcpClientAdapter(Socket socket)
2020
_sock = socket ?? throw new InvalidOperationException("socket must not be null");
2121
}
2222

23-
#if NET6_0_OR_GREATER
23+
#if NET
2424
public virtual Task ConnectAsync(IPAddress ep, int port, CancellationToken cancellationToken = default)
2525
{
2626
return _sock.ConnectAsync(ep, port, cancellationToken).AsTask();

projects/Test/Common/Common.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
</ItemGroup>
2727

2828
<ItemGroup>
29+
<PackageReference Include="System.Text.Json" />
2930
<PackageReference Include="EasyNetQ.Management.Client" />
3031
<PackageReference Include="xunit" />
3132
<PackageReference Include="xunit.abstractions" />

projects/Test/Common/IntegrationFixture.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public abstract class IntegrationFixture : IAsyncLifetime
8989
static IntegrationFixture()
9090
{
9191

92-
#if NET6_0_OR_GREATER
92+
#if NET
9393
S_Random = Random.Shared;
9494
#else
9595
S_Random = new Random();

projects/Test/Common/TestOutputWriterEventListener.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected override void OnEventWritten(EventWrittenEventArgs eventData)
7676
{
7777
try
7878
{
79-
#if NET6_0_OR_GREATER
79+
#if NET
8080
if (eventData.Payload.Count > 0)
8181
{
8282
string payloadName = eventData.PayloadNames[0];

projects/Test/Integration/Integration.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
-->
4040

4141
<ItemGroup>
42+
<PackageReference Include="System.Text.Json" />
4243
<PackageReference Include="Microsoft.NET.Test.Sdk" />
4344
<PackageReference Include="xunit" />
4445
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all" />

projects/Test/Integration/TestExchangeDeclare.cs

+25-2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public async Task TestConcurrentExchangeDeclareAndDelete()
112112
var exchangeNames = new ConcurrentBag<string>();
113113
var tasks = new List<Task>();
114114
NotSupportedException nse = null;
115+
Exception unexpectedException = null;
115116
for (int i = 0; i < 256; i++)
116117
{
117118
var t = Task.Run(async () =>
@@ -129,13 +130,24 @@ public async Task TestConcurrentExchangeDeclareAndDelete()
129130
{
130131
nse = e;
131132
}
133+
catch (Exception ex)
134+
{
135+
unexpectedException = ex;
136+
}
132137
});
133138
tasks.Add(t);
134139
}
135140

136141
await Task.WhenAll(tasks);
137142

138-
Assert.Null(nse);
143+
if (nse is not null)
144+
{
145+
Assert.Fail($"got unexpected NotSupportedException: {nse}");
146+
}
147+
if (unexpectedException is not null)
148+
{
149+
Assert.Fail($"got unexpected Exception: {unexpectedException}");
150+
}
139151
tasks.Clear();
140152

141153
foreach (string exchangeName in exchangeNames)
@@ -154,13 +166,24 @@ public async Task TestConcurrentExchangeDeclareAndDelete()
154166
{
155167
nse = e;
156168
}
169+
catch (Exception ex)
170+
{
171+
unexpectedException = ex;
172+
}
157173
});
158174
tasks.Add(t);
159175
}
160176

161177
await Task.WhenAll(tasks);
162178

163-
Assert.Null(nse);
179+
if (nse is not null)
180+
{
181+
Assert.Fail($"got unexpected NotSupportedException: {nse}");
182+
}
183+
if (unexpectedException is not null)
184+
{
185+
Assert.Fail($"got unexpected Exception: {unexpectedException}");
186+
}
164187
}
165188
}
166189
}

projects/Test/OAuth2/OAuth2.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
<ItemGroup>
3030
<PackageReference Include="Microsoft.NET.Test.Sdk" />
31+
<PackageReference Include="System.Text.RegularExpressions" />
3132
<PackageReference Include="xunit" />
3233
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all" />
3334
<PackageReference Include="System.Net.Http" />

projects/Test/SequentialIntegration/SequentialIntegration.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<SignAssembly>true</SignAssembly>
1818
<IsTestProject>true</IsTestProject>
1919
<LangVersion>12.0</LangVersion>
20+
<TestTfmsInParallel>false</TestTfmsInParallel>
2021
</PropertyGroup>
2122

2223
<ItemGroup>
@@ -38,6 +39,7 @@
3839
</ItemGroup>
3940

4041
<ItemGroup>
42+
<PackageReference Include="System.Text.Json" />
4143
<PackageReference Include="Microsoft.NET.Test.Sdk" />
4244
<PackageReference Include="OpenTelemetry.Exporter.InMemory" />
4345
<PackageReference Include="xunit" />

projects/Test/Unit/Unit.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
</ItemGroup>
2525

2626
<ItemGroup>
27+
<PackageReference Include="System.Text.Json" />
2728
<PackageReference Include="Microsoft.NET.Test.Sdk" />
2829
<PackageReference Include="xunit" />
2930
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all" />

0 commit comments

Comments
 (0)