Skip to content

Commit 12044d5

Browse files
authored
Merge pull request #1129 from drewnoakes/review-conditional-code
Review conditional code
2 parents 2c17a24 + d5c724e commit 12044d5

Some content is hidden

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

46 files changed

+67
-346
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22

33
<PropertyGroup>
4-
<LangVersion>10</LangVersion>
4+
<LangVersion>13</LangVersion>
55
<Nullable>enable</Nullable>
66
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
77
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>

src/NetMQ.Tests/ClientServer.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ public async Task AsyncWithCancellationToken()
8282
await Assert.ThrowsAnyAsync<OperationCanceledException>(async () => await server.ReceiveStringAsync(source.Token));
8383
}
8484

85-
#if NETCOREAPP3_1
86-
85+
#if NETSTANDARD || NET
8786
[Fact(Timeout = 120)]
88-
public async void AsyncEnumerableCanceled()
87+
public async Task AsyncEnumerableCanceled()
8988
{
9089
using CancellationTokenSource source = new CancellationTokenSource();
9190
using var server = new ServerSocket();
@@ -100,7 +99,7 @@ await Assert.ThrowsAnyAsync<OperationCanceledException>(async () =>
10099
}
101100

102101
[Fact(Timeout = 1000)]
103-
public void AsyncEnumerable()
102+
public async Task AsyncEnumerable()
104103
{
105104
using var server = new ServerSocket();
106105
int port = server.BindRandomPort("tcp://*");
@@ -152,12 +151,10 @@ public void AsyncEnumerable()
152151
client.Send("1");
153152
client.Send("1");
154153

155-
t1.Wait();
156-
t2.Wait();
154+
await Task.WhenAll(t1, t2);
157155

158156
Assert.Equal(15002, totalCount);
159157
}
160-
161158
#endif
162159
}
163160
}

src/NetMQ.Tests/NetMQPollerTest.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System;
2+
using System.Collections.Concurrent;
3+
using System.Collections.Generic;
24
using System.Diagnostics;
35
using System.Net;
46
using System.Net.Sockets;
@@ -8,11 +10,6 @@
810
using NetMQ.Sockets;
911
using Xunit;
1012

11-
#if !NET35
12-
using System.Collections.Concurrent;
13-
using System.Collections.Generic;
14-
#endif
15-
1613
// ReSharper disable AccessToDisposedClosure
1714

1815
namespace NetMQ.Tests
@@ -864,7 +861,6 @@ public void NativeSocket()
864861

865862
#region TaskScheduler tests
866863

867-
#if !NET35
868864
[Fact]
869865
public async Task OneTask()
870866
{
@@ -989,13 +985,11 @@ public async Task TwoThreads()
989985
Assert.Equal(100, count2);
990986
}
991987
}
992-
#endif
993988

994989
#endregion
995990

996991
#region ISynchronizeInvoke tests
997992

998-
#if NET451
999993
[Fact]
1000994
public void ISynchronizeInvokeWorks()
1001995
{
@@ -1017,8 +1011,7 @@ public void ISynchronizeInvokeWorks()
10171011
Assert.True(isCorrectThread);
10181012
}
10191013
}
1020-
#endif
10211014

1022-
#endregion
1015+
#endregion
10231016
}
10241017
}

src/NetMQ.Tests/NetMQQueueTests.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#if !NET35
2-
using System;
3-
using System.Net.Sockets;
1+
using System;
42
using System.Threading;
53
using System.Threading.Tasks;
64
using NetMQ.Sockets;
@@ -81,4 +79,3 @@ public void WithPoller()
8179
}
8280
}
8381
}
84-
#endif

src/NetMQ.Tests/RequestWithRetryTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if !NET35
2-
using System;
1+
using System;
32
using System.Diagnostics;
43
using NetMQ.Sockets;
54
using Xunit;
@@ -205,4 +204,3 @@ public void RequestResponseStringWithRetrySucceedsNotOnFirstTry()
205204
}
206205
}
207206
}
208-
#endif

src/NetMQ.Tests/ThrowingTraceListener.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Diagnostics;
3-
using System.Runtime.Serialization;
43

54
namespace NetMQ.Tests
65
{
@@ -19,7 +18,6 @@ public override void WriteLine(string? message)
1918
{
2019
}
2120

22-
[Serializable]
2321
public class DebugAssertFailureException : Exception
2422
{
2523
public DebugAssertFailureException()
@@ -33,10 +31,6 @@ public DebugAssertFailureException(string message) : base(message)
3331
public DebugAssertFailureException(string message, Exception inner) : base(message, inner)
3432
{
3533
}
36-
37-
protected DebugAssertFailureException(SerializationInfo info, StreamingContext context) : base(info, context)
38-
{
39-
}
4034
}
4135
}
4236
}

src/NetMQ/Core/Mailbox.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ You should have received a copy of the GNU Lesser General Public License
1919
along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
*/
2121

22-
using System;
2322
using System.Diagnostics;
2423
using System.Net.Sockets;
2524
using NetMQ.Core.Utils;

src/NetMQ/Core/Mechanisms/CurveClientMechanism.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Diagnostics;
32
using System.Security.Cryptography;
43
using System.Text;
54
using NaCl;

src/NetMQ/Core/Mechanisms/CurveServerMechanism.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
2-
using System.Linq;
32
using System.Security.Cryptography;
4-
using System.Text;
53
using NaCl;
64
using NetMQ.Core.Utils;
75

src/NetMQ/Core/Mechanisms/Mechanism.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections;
32
using System.Collections.Generic;
43
using System.Text;
54
using NetMQ.Core.Utils;
@@ -191,7 +190,7 @@ protected void AddBasicProperties(Span<byte> output)
191190
}
192191
else
193192
{
194-
written = AddProperty(output, ZmtpPropertyIdentity, new byte[0]);
193+
written = AddProperty(output, ZmtpPropertyIdentity, []);
195194
output = output.Slice(written);
196195
}
197196
}

0 commit comments

Comments
 (0)