Skip to content

Commit b6884c5

Browse files
authored
Merge pull request #1189 from rabbitmq/rabbitmq-dotnet-client-1172
Ensure target frameworks make sense for 7.0
2 parents 08d4417 + f18c719 commit b6884c5

File tree

13 files changed

+93
-89
lines changed

13 files changed

+93
-89
lines changed

.github/workflows/main.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
with:
2323
submodules: true
2424
- name: Cache installers
25-
uses: actions/cache@v2
25+
uses: actions/cache@v3
2626
with:
2727
# Note: the cache path is relative to the workspace directory
2828
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action
@@ -66,11 +66,11 @@ jobs:
6666
with:
6767
submodules: true
6868
- name: Setup .NET
69-
uses: actions/setup-dotnet@v1
69+
uses: actions/setup-dotnet@v2
7070
with:
71-
dotnet-version: 3.1.x
71+
dotnet-version: 6.x
7272
- name: Cache NuGet packages
73-
uses: actions/cache@v2
73+
uses: actions/cache@v3
7474
with:
7575
path: |
7676
~/.nuget/packages
@@ -83,6 +83,6 @@ jobs:
8383
- name: Build
8484
run: dotnet build --no-restore --verbosity=normal
8585
- name: Test
86-
run: dotnet test --no-restore --no-build --logger "console;verbosity=detailed" --framework "netcoreapp3.1"
86+
run: dotnet test --no-restore --no-build --logger "console;verbosity=detailed" --framework "net6.0"
8787
env:
8888
RABBITMQ_RABBITMQCTL_PATH: DOCKER:${{job.services.rabbitmq.id}}

projects/Benchmarks/Benchmarks.csproj

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4+
<TargetFrameworks>net6.0;net472</TargetFrameworks>
45
<OutputType>Exe</OutputType>
56
<AssemblyOriginatorKeyFile>../rabbit.snk</AssemblyOriginatorKeyFile>
67
<SignAssembly>true</SignAssembly>
7-
<TargetFrameworks>netcoreapp3.1;net48</TargetFrameworks>
8-
<ReleaseVersion>8.0</ReleaseVersion>
98
</PropertyGroup>
109

1110
<ItemGroup>
12-
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
13-
<PackageReference Include="Ductus.FluentDocker" Version="2.7.3" />
11+
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
12+
<PackageReference Include="Ductus.FluentDocker" Version="2.10.45" />
1413
</ItemGroup>
1514

1615
<ItemGroup>
1716
<ProjectReference Include="..\RabbitMQ.Client\RabbitMQ.Client.csproj" />
18-
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
17+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" />
1918
</ItemGroup>
2019

2120
</Project>

projects/RabbitMQ.Client/RabbitMQ.Client.csproj

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;netstandard2.0</TargetFrameworks>
4+
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
55
<NoWarn>$(NoWarn);CS1591</NoWarn>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
77
<AssemblyTitle>RabbitMQ Client Library for .NET</AssemblyTitle>
@@ -36,11 +36,6 @@
3636
<Deterministic>true</Deterministic>
3737
</PropertyGroup>
3838

39-
<!-- disable nullable warnings for .NET Standard 2.0 -->
40-
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
41-
<NoWarn>$(NoWarn);nullable</NoWarn>
42-
</PropertyGroup>
43-
4439
<Target Name="SetVersionFromConcourseData" AfterTargets="MinVer" Condition="'$(CONCOURSE_PULL_REQUEST_NUMBER)' != ''">
4540
<PropertyGroup>
4641
<PackageVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch)-$(MinVerPreRelease)-pr.$(CONCOURSE_PULL_REQUEST_NUMBER)</PackageVersion>
@@ -62,15 +57,12 @@
6257
</ItemGroup>
6358

6459
<ItemGroup>
65-
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
66-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
67-
<PackageReference Include="MinVer" Version="2.4.0" PrivateAssets="All" />
68-
<PackageReference Include="System.Threading.Channels" Version="5.0.0" />
69-
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.3" PrivateAssets="All" />
70-
</ItemGroup>
71-
72-
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
60+
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0" PrivateAssets="All" />
61+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" />
62+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
63+
<PackageReference Include="MinVer" Version="3.1.0" PrivateAssets="All" />
7364
<PackageReference Include="System.Memory" Version="4.5.4" />
65+
<PackageReference Include="System.Threading.Channels" Version="6.0.0" />
7466
</ItemGroup>
7567

7668
</Project>

projects/RabbitMQ.Client/client/impl/Connection.Commands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private IAuthMechanismFactory GetAuthMechanismFactory(string supportedMechanismN
170170
// Our list is in order of preference, the server one is not.
171171
foreach (var factory in _config.AuthMechanisms)
172172
{
173-
if (supportedMechanismNames.Contains(factory.Name, StringComparison.OrdinalIgnoreCase))
173+
if (supportedMechanismNames.IndexOf(factory.Name, StringComparison.OrdinalIgnoreCase) >= 0)
174174
{
175175
return factory;
176176
}

projects/TestApplications/CreateChannel/CreateChannel.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<TargetFrameworks>net6.0;net472</TargetFrameworks>
66
</PropertyGroup>
77

88
<ItemGroup>

projects/TestApplications/MassPublish/MassPublish.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<TargetFrameworks>net6.0;net472</TargetFrameworks>
66
</PropertyGroup>
77

88
<ItemGroup>

projects/Unit/Fixtures.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ public class TimingFixture
423423
{
424424
public static readonly TimeSpan TimingInterval = TimeSpan.FromMilliseconds(300);
425425
public static readonly TimeSpan TimingInterval_2X = TimeSpan.FromMilliseconds(600);
426+
public static readonly TimeSpan TimingInterval_4X = TimeSpan.FromMilliseconds(1200);
426427
public static readonly TimeSpan SafetyMargin = TimeSpan.FromMilliseconds(150);
427428
public static readonly TimeSpan TestTimeout = TimeSpan.FromSeconds(5);
428429
}

projects/Unit/RabbitMQCtl.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ namespace RabbitMQ.Client.Unit
4343
#nullable enable
4444
public static class RabbitMQCtl
4545
{
46+
private static readonly char[] newLine = new char[] { '\n' };
4647
private static readonly Func<string, Process> s_invokeRabbitMqCtl = GetRabbitMqCtlInvokeAction();
4748

4849
private static Func<string, Process> GetRabbitMqCtlInvokeAction()
@@ -209,7 +210,8 @@ public static void CloseAllConnections()
209210

210211
private static string[] EnumerateConnectionsPid()
211212
{
212-
return ExecRabbitMQCtl("list_connections --silent pid").Split('\n', StringSplitOptions.RemoveEmptyEntries);
213+
string rabbitmqCtlResult = ExecRabbitMQCtl("list_connections --silent pid");
214+
return rabbitmqCtlResult.Split(newLine, StringSplitOptions.RemoveEmptyEntries);
213215
}
214216

215217
public static void RestartRabbitMQ()

projects/Unit/TestBlockingCell.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public void TestBackgroundUpdateSucceedsWithInfiniteTimeoutTimeSpan()
164164
public void TestBackgroundUpdateFails()
165165
{
166166
var k = new BlockingCell<int>();
167-
SetAfter(TimingInterval_2X, k, 123);
167+
SetAfter(TimingInterval_4X, k, 123);
168168

169169
ResetTimer();
170170
Assert.Throws<TimeoutException>(() => k.WaitForValue(TimingInterval));

projects/Unit/TestChannelAllocation.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838

3939
namespace RabbitMQ.Client.Unit
4040
{
41-
42-
4341
public class TestIModelAllocation : IDisposable
4442
{
4543
public const int CHANNEL_COUNT = 100;

projects/Unit/TestPublisherConfirms.cs

Lines changed: 61 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,14 @@ namespace RabbitMQ.Client.Unit
4545
public class TestPublisherConfirms : IntegrationFixture
4646
{
4747
private const string QueueName = "RabbitMQ.Client.Unit.TestPublisherConfirms";
48+
private readonly byte[] _body;
4849

4950
public TestPublisherConfirms(ITestOutputHelper output) : base(output)
5051
{
52+
var rnd = new Random();
53+
_body = new byte[4096];
54+
rnd.NextBytes(_body);
55+
5156
}
5257

5358
[Fact]
@@ -64,18 +69,22 @@ public void TestWaitForConfirmsWithTimeout()
6469
{
6570
TestWaitForConfirms(200, (ch) =>
6671
{
67-
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(4));
68-
Assert.True(ch.WaitForConfirmsAsync(cts.Token).GetAwaiter().GetResult());
72+
using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(4)))
73+
{
74+
Assert.True(ch.WaitForConfirmsAsync(cts.Token).GetAwaiter().GetResult());
75+
}
6976
});
7077
}
7178

7279
[Fact]
7380
public void TestWaitForConfirmsWithTimeout_AllMessagesAcked_WaitingHasTimedout_ReturnTrue()
7481
{
75-
TestWaitForConfirms(2000, (ch) =>
82+
TestWaitForConfirms(10000, (ch) =>
7683
{
77-
using var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(1));
78-
Assert.Throws<TaskCanceledException>(() => ch.WaitForConfirmsAsync(cts.Token).GetAwaiter().GetResult());
84+
using (var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(1)))
85+
{
86+
Assert.Throws<TaskCanceledException>(() => ch.WaitForConfirmsAsync(cts.Token).GetAwaiter().GetResult());
87+
}
7988
});
8089
}
8190

@@ -90,67 +99,70 @@ public void TestWaitForConfirmsWithTimeout_MessageNacked_WaitingHasTimedout_Retu
9099
.GetMethod("HandleAckNack", BindingFlags.Instance | BindingFlags.NonPublic)
91100
.Invoke(actualModel, new object[] { 10UL, false, true });
92101

93-
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(4));
94-
Assert.False(ch.WaitForConfirmsAsync(cts.Token).GetAwaiter().GetResult());
102+
using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(4)))
103+
{
104+
Assert.False(ch.WaitForConfirmsAsync(cts.Token).GetAwaiter().GetResult());
105+
}
95106
});
96107
}
97108

98109
[Fact]
99110
public async Task TestWaitForConfirmsWithEvents()
100111
{
101-
IModel ch = _conn.CreateModel();
102-
ch.ConfirmSelect();
112+
using (IModel ch = _conn.CreateModel())
113+
{
114+
ch.ConfirmSelect();
103115

104-
ch.QueueDeclare(QueueName);
105-
int n = 200;
106-
// number of event handler invocations
107-
int c = 0;
116+
ch.QueueDeclare(QueueName);
117+
int n = 200;
118+
// number of event handler invocations
119+
int c = 0;
108120

109-
ch.BasicAcks += (_, args) =>
110-
{
111-
Interlocked.Increment(ref c);
112-
};
113-
try
114-
{
115-
for (int i = 0; i < n; i++)
121+
ch.BasicAcks += (_, args) =>
122+
{
123+
Interlocked.Increment(ref c);
124+
};
125+
try
116126
{
117-
ch.BasicPublish("", QueueName, _encoding.GetBytes("msg"));
127+
for (int i = 0; i < n; i++)
128+
{
129+
ch.BasicPublish("", QueueName, _encoding.GetBytes("msg"));
130+
}
131+
await ch.WaitForConfirmsAsync().ConfigureAwait(false);
132+
133+
// Note: number of event invocations is not guaranteed
134+
// to be equal to N because acks can be batched,
135+
// so we primarily care about event handlers being invoked
136+
// in this test
137+
Assert.True(c > 5);
138+
}
139+
finally
140+
{
141+
ch.QueueDelete(QueueName);
118142
}
119-
await ch.WaitForConfirmsAsync().ConfigureAwait(false);
120-
121-
// Note: number of event invocations is not guaranteed
122-
// to be equal to N because acks can be batched,
123-
// so we primarily care about event handlers being invoked
124-
// in this test
125-
Assert.True(c > 5);
126-
}
127-
finally
128-
{
129-
ch.QueueDelete(QueueName);
130-
ch.Close();
131143
}
132144
}
133145

134146
protected void TestWaitForConfirms(int numberOfMessagesToPublish, Action<IModel> fn)
135147
{
136-
IModel ch = _conn.CreateModel();
137-
ch.ConfirmSelect();
138-
ch.QueueDeclare(QueueName);
139-
140-
ReadOnlyMemory<byte> body = _encoding.GetBytes("msg");
141-
for (int i = 0; i < numberOfMessagesToPublish; i++)
148+
using (IModel ch = _conn.CreateModel())
142149
{
143-
ch.BasicPublish("", QueueName, body);
144-
}
150+
ch.ConfirmSelect();
151+
ch.QueueDeclare(QueueName);
145152

146-
try
147-
{
148-
fn(ch);
149-
}
150-
finally
151-
{
152-
ch.QueueDelete(QueueName);
153-
ch.Close();
153+
for (int i = 0; i < numberOfMessagesToPublish; i++)
154+
{
155+
ch.BasicPublish("", QueueName, _body);
156+
}
157+
158+
try
159+
{
160+
fn(ch);
161+
}
162+
finally
163+
{
164+
ch.QueueDelete(QueueName);
165+
}
154166
}
155167
}
156168
}

projects/Unit/Unit.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFrameworks>net6.0;net472</TargetFrameworks>
55
<AssemblyOriginatorKeyFile>../rabbit.snk</AssemblyOriginatorKeyFile>
66
<SignAssembly>true</SignAssembly>
77
<LangVersion>latest</LangVersion>
@@ -13,15 +13,15 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
17-
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
18-
<PackageReference Include="PublicApiGenerator" Version="10.2.0" />
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
17+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" />
18+
<PackageReference Include="PublicApiGenerator" Version="10.3.0" />
1919
<PackageReference Include="xunit" Version="2.4.1" />
2020
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
2121
<PrivateAssets>all</PrivateAssets>
2222
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2323
</PackageReference>
24-
<PackageReference Include="Verify.Xunit" Version="11.18.2" />
24+
<PackageReference Include="Verify.Xunit" Version="16.5.4" />
2525
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
2626
</ItemGroup>
2727

run-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ fi
1313

1414
cd "$script_dir"
1515

16-
dotnet test --no-build --logger 'console;verbosity=detailed' --framework 'netcoreapp3.1' ./RabbitMQDotNetClient.sln < /dev/null
16+
dotnet test --no-build --logger 'console;verbosity=detailed' --framework 'net6.0' ./RabbitMQDotNetClient.sln < /dev/null

0 commit comments

Comments
 (0)