Skip to content

Commit 2c17a24

Browse files
authored
Merge pull request #1128 from chrbauer/feature/net8-target-added
Add net8.0 target and increase net47 to net472
2 parents 5a3a2d0 + b88c9a0 commit 2c17a24

Some content is hidden

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

61 files changed

+214
-210
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
run: dotnet build src/NetMQ.sln /p:Configuration=Release /verbosity:minimal
3535
- name: test net9.0
3636
run: dotnet test -v n -p:ParallelizeTestCollections=false --configuration Release --no-build -f net9.0 src\NetMQ.Tests\NetMQ.Tests.csproj
37-
- name: test net47
38-
run: dotnet test -v n -p:ParallelizeTestCollections=false --configuration Release --no-build -f net47 src\NetMQ.Tests\NetMQ.Tests.csproj
37+
- name: test net472
38+
run: dotnet test -v n -p:ParallelizeTestCollections=false --configuration Release --no-build -f net472 src\NetMQ.Tests\NetMQ.Tests.csproj
3939
- name: coverage
4040
run: |
4141
OpenCover.Console.exe -register:user -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test --no-build --configuration Release -f net6.0 --logger:trx;LogFileName=results.trx /p:DebugType=full src\NetMQ.Tests\NetMQ.Tests.csproj" -filter:"+[NetMQ*]* -[NetMQ.Tests*]*" -output:".\NetMQ_coverage.xml" -oldStyle

.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/NetMQ.Tests/ClientServer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void Tcp()
5454
}
5555

5656
[Fact]
57-
public async void Async()
57+
public async Task Async()
5858
{
5959
using var server = new ServerSocket();
6060
using var client = new ClientSocket();
@@ -72,7 +72,7 @@ public async void Async()
7272
}
7373

7474
[Fact]
75-
public async void AsyncWithCancellationToken()
75+
public async Task AsyncWithCancellationToken()
7676
{
7777
using CancellationTokenSource source = new CancellationTokenSource();
7878
using var server = new ServerSocket();

src/NetMQ.Tests/CurveTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using NetMQ.Sockets;
33
using Xunit;
44

5-
#if NET47
5+
#if NETFRAMEWORK
66
using ZeroMQ;
77
#endif
88

@@ -39,7 +39,7 @@ public void CurveTest()
3939

4040
}
4141

42-
#if NET47
42+
#if NETFRAMEWORK
4343
[Fact]
4444
public void WithLibzmqClient()
4545
{

src/NetMQ.Tests/MessageTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public void Issue52_ReqToRouterBug()
128128

129129
var msg = router.ReceiveMultipartMessage();
130130
Assert.Equal(3, msg.FrameCount);
131-
Assert.Equal(msg[2].ConvertToString(), testmessage);
131+
Assert.Equal(testmessage, msg[2].ConvertToString());
132132
}
133133
}
134134

src/NetMQ.Tests/NetMQ.Tests.csproj

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
88
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
99
<IsTestProject>true</IsTestProject>
10-
<TargetFrameworks>net9.0;net47</TargetFrameworks>
10+
<TargetFrameworks>net9.0;net472</TargetFrameworks>
1111
</PropertyGroup>
1212

1313
<PropertyGroup>
@@ -20,13 +20,13 @@
2020
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND '$(TargetIsMono)' == 'true' AND EXISTS('/usr/lib/mono')">/usr/lib/mono</BaseFrameworkPathOverrideForMono>
2121
<BaseFrameworkPathOverrideForMono Condition="'$(BaseFrameworkPathOverrideForMono)' == '' AND '$(TargetIsMono)' == 'true' AND EXISTS('/usr/local/lib/mono')">/usr/local/lib/mono</BaseFrameworkPathOverrideForMono>
2222

23-
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net47'">$(BaseFrameworkPathOverrideForMono)/4.7-api</FrameworkPathOverride>
23+
<FrameworkPathOverride Condition="'$(BaseFrameworkPathOverrideForMono)' != '' AND '$(TargetFramework)' == 'net472'">$(BaseFrameworkPathOverrideForMono)/4.7-api</FrameworkPathOverride>
2424

2525
<!-- Add the Facades directory. Not sure how else to do this. Necessary at least for .NET 4.5 -->
2626
<AssemblySearchPaths Condition="'$(BaseFrameworkPathOverrideForMono)' != ''">$(FrameworkPathOverride)/Facades;$(AssemblySearchPaths)</AssemblySearchPaths>
2727
</PropertyGroup>
2828

29-
<ItemGroup Condition=" '$(TargetFramework)' == 'net47' ">
29+
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
3030
<Reference Include="mscorlib" />
3131
<Reference Include="System" />
3232
<Reference Include="System.Core" />
@@ -39,14 +39,17 @@
3939
</ItemGroup>
4040

4141
<ItemGroup>
42-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
42+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
4343
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
44-
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.6.0" />
45-
<PackageReference Include="xunit" Version="2.4.2-pre.13" />
46-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
44+
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.6.3" />
45+
<PackageReference Include="xunit" Version="2.9.3" />
46+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.1">
47+
<PrivateAssets>all</PrivateAssets>
48+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
49+
</PackageReference>
4750
</ItemGroup>
4851

49-
<ItemGroup Condition=" '$(TargetFramework)' == 'net47' ">
52+
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' ">
5053
<PackageReference Include="ZeroMQ" Version="4.1.0.31" />
5154
</ItemGroup>
5255

src/NetMQ.Tests/NetMQMonitorTests.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public void Monitoring()
5757
}
5858
}
5959

60-
#if !NET35
60+
6161
[Fact]
62-
public void StartAsync()
62+
public async Task StartAsync()
6363
{
6464
using (var rep = new ResponseSocket())
6565
using (var monitor = new NetMQMonitor(rep, "inproc://foo", SocketEvents.Closed))
@@ -68,10 +68,11 @@ public void StartAsync()
6868
Thread.Sleep(200);
6969
Assert.Equal(TaskStatus.Running, task.Status);
7070
monitor.Stop();
71-
Assert.True(task.Wait(TimeSpan.FromMilliseconds(1000)));
71+
var completedTask = await Task.WhenAny(task, Task.Delay(1000));
72+
Assert.Equal(task, completedTask);
7273
}
7374
}
74-
#endif
75+
7576

7677
[Fact]
7778
public void NoHangWhenMonitoringUnboundInprocAddress()
@@ -126,7 +127,7 @@ public void ErrorCodeTest()
126127
}
127128

128129
[Fact]
129-
public void MonitorDisposeProperlyWhenDisposedAfterMonitoredTcpSocket()
130+
public async Task MonitorDisposeProperlyWhenDisposedAfterMonitoredTcpSocket()
130131
{
131132
// The bug:
132133
// Given we monitor a netmq tcp socket
@@ -141,7 +142,7 @@ public void MonitorDisposeProperlyWhenDisposedAfterMonitoredTcpSocket()
141142
using (var req = new RequestSocket())
142143
{
143144
monitor = new NetMQMonitor(req, "inproc://#monitor", SocketEvents.All);
144-
Task.Factory.StartNew(monitor.Start);
145+
_ = Task.Factory.StartNew(monitor.Start);
145146

146147
// Bug only occurs when monitoring a tcp socket
147148
var port = res.BindRandomPort("tcp://127.0.0.1");
@@ -152,10 +153,12 @@ public void MonitorDisposeProperlyWhenDisposedAfterMonitoredTcpSocket()
152153
res.SendFrame("response");
153154
Assert.Equal("response", req.ReceiveFrameString());
154155
}
155-
Thread.Sleep(100);
156+
157+
await Task.Delay(100);
156158
// Monitor.Dispose should complete
157-
var completed = Task.Factory.StartNew(() => monitor.Dispose()).Wait(1000);
158-
Assert.True(completed);
159+
var task = Task.Factory.StartNew(() => monitor.Dispose());
160+
var completedTask = await Task.WhenAny(task, Task.Delay(1000));
161+
Assert.Equal(task, completedTask);
159162
}
160163
// NOTE If this test fails, it will hang because context.Dispose will block
161164
}

src/NetMQ.Tests/NetMQPollerTest.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#if !NET35
1212
using System.Collections.Concurrent;
13+
using System.Collections.Generic;
1314
#endif
1415

1516
// ReSharper disable AccessToDisposedClosure
@@ -318,7 +319,7 @@ public void AddTwoSocketAfterRemoving()
318319

319320

320321
[Fact]
321-
public void RemoveSocket()
322+
public async Task RemoveSocket()
322323
{
323324
using (var router1 = new RouterSocket())
324325
using (var router2 = new RouterSocket())
@@ -395,8 +396,8 @@ public void RemoveSocket()
395396

396397
poller.Stop();
397398
// await the pollerTask, 1ms should suffice
398-
pollerTask.Wait(1);
399-
Assert.True(pollerTask.IsCompleted);
399+
var completedTask = await Task.WhenAny(pollerTask, Task.Delay(1));
400+
Assert.Equal(pollerTask, completedTask);
400401
}
401402
}
402403

@@ -865,7 +866,7 @@ public void NativeSocket()
865866

866867
#if !NET35
867868
[Fact]
868-
public void OneTask()
869+
public async Task OneTask()
869870
{
870871
bool triggered = false;
871872

@@ -879,27 +880,27 @@ public void OneTask()
879880
Assert.True(poller.CanExecuteTaskInline, "Should be on NetMQPoller thread");
880881
});
881882
task.Start(poller);
882-
task.Wait();
883+
await task;
883884

884885
Assert.True(triggered);
885886
}
886887
}
887888

888889
[Fact]
889-
public void SetsCurrentTaskScheduler()
890+
public async Task SetsCurrentTaskScheduler()
890891
{
891892
using (var poller = new NetMQPoller())
892893
{
893894
poller.RunAsync();
894895

895896
var task = new Task(() => Assert.Same(TaskScheduler.Current, poller));
896897
task.Start(poller);
897-
task.Wait();
898+
await task;
898899
}
899900
}
900901

901902
[Fact]
902-
public void CanExecuteTaskInline()
903+
public async Task CanExecuteTaskInline()
903904
{
904905
using (var poller = new NetMQPoller())
905906
{
@@ -911,12 +912,12 @@ public void CanExecuteTaskInline()
911912

912913
var task = new Task(() => Assert.True(poller.CanExecuteTaskInline));
913914
task.Start(poller);
914-
task.Wait();
915+
await task;
915916
}
916917
}
917918

918919
[Fact]
919-
public void ContinueWith()
920+
public async Task ContinueWith()
920921
{
921922
int threadId1 = 0;
922923
int threadId2 = 1;
@@ -941,8 +942,7 @@ public void ContinueWith()
941942
}, poller);
942943

943944
task.Start(poller);
944-
task.Wait();
945-
task2.Wait();
945+
await Task.WhenAll(new List<Task>{task, task2});
946946

947947
Assert.Equal(threadId1, threadId2);
948948
Assert.Equal(1, runCount1);
@@ -951,7 +951,7 @@ public void ContinueWith()
951951
}
952952

953953
[Fact]
954-
public void TwoThreads()
954+
public async Task TwoThreads()
955955
{
956956
int count1 = 0;
957957
int count2 = 0;
@@ -982,9 +982,8 @@ public void TwoThreads()
982982
}
983983
});
984984

985-
t1.Wait(1000);
986-
t2.Wait(1000);
987-
Task.WaitAll(allTasks.ToArray(), 1000);
985+
await Task.WhenAny(Task.WhenAll(new List<Task>{ t1, t2 }), Task.Delay(1000));
986+
await Task.WhenAny(Task.WhenAll(allTasks.ToArray()), Task.Delay(1000));
988987

989988
Assert.Equal(100, count1);
990989
Assert.Equal(100, count2);

src/NetMQ.Tests/NetMQQueueTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void EnqueueDequeue()
2424
}
2525

2626
[Fact]
27-
public void EnqueueShouldNotBlockWhenCapacityIsZero()
27+
public async Task EnqueueShouldNotBlockWhenCapacityIsZero()
2828
{
2929
using (var mockSocket = new PairSocket())
3030
using (var queue = new NetMQQueue<int>())
@@ -39,8 +39,8 @@ public void EnqueueShouldNotBlockWhenCapacityIsZero()
3939
}
4040
});
4141

42-
bool completed = task.Wait(TimeSpan.FromSeconds(1));
43-
Assert.True(completed, "Enqueue task should have completed " + socketWatermarkCapacity + " enqueue within 1 second");
42+
var completedTask = await Task.WhenAny(task, Task.Delay(1000));
43+
Assert.True(task == completedTask, "Enqueue task should have completed " + socketWatermarkCapacity + " enqueue within 1 second");
4444
}
4545
}
4646

src/NetMQ.Tests/PgmTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public void TwoPublishers()
187187
}
188188

189189
[Fact(Skip = "Requires MSMQ for PGM sockets")]
190-
public void Sending1000Messages()
190+
public async Task Sending1000Messages()
191191
{
192192
// creating two different context and sending 1000 messages
193193

@@ -230,8 +230,8 @@ public void Sending1000Messages()
230230
}
231231
});
232232

233-
pubTask.Wait();
234-
subTask.Wait();
233+
await pubTask;
234+
await subTask;
235235

236236
Assert.Equal(1000, count);
237237
}
@@ -266,7 +266,7 @@ public void LargeMessage()
266266
[Theory(Skip = "Requires MSMQ for PGM sockets")]
267267
[InlineData("pgm://239.0.0.1:1000")]
268268
[InlineData("tcp://localhost:60000")]
269-
public void SubscriberCleanupOnUnbind(string address)
269+
public async Task SubscriberCleanupOnUnbind(string address)
270270
{
271271
for (var i = 0; i < 10; i++)
272272
{
@@ -290,8 +290,8 @@ public void SubscriberCleanupOnUnbind(string address)
290290
// var duration = DateTime.Now - time;
291291

292292
monitor.Stop();
293-
294-
monitorTask.Wait();
293+
294+
await monitorTask;
295295
}
296296
}
297297
}

0 commit comments

Comments
 (0)