Skip to content

Commit f061446

Browse files
committed
Remove conditions on outdated frameworks
We had a bunch of conditional code on frameworks that are no longer in support. Clean them up.
1 parent 2c17a24 commit f061446

File tree

10 files changed

+10
-127
lines changed

10 files changed

+10
-127
lines changed

src/NetMQ.Tests/NetMQPollerTest.cs

Lines changed: 2 additions & 7 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,7 +985,6 @@ public async Task TwoThreads()
989985
Assert.Equal(100, count2);
990986
}
991987
}
992-
#endif
993988

994989
#endregion
995990

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/Core/Utils/Signaler.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,14 @@ public void Close()
7272

7373
try
7474
{
75-
#if NET35
76-
m_writeSocket.Close();
77-
#else
7875
m_writeSocket.Dispose();
79-
#endif
8076
}
8177
catch (SocketException)
8278
{}
8379

8480
try
8581
{
86-
#if NET35
87-
m_readSocket.Close();
88-
#else
8982
m_readSocket.Dispose();
90-
#endif
9183
}
9284
catch (SocketException)
9385
{}

src/NetMQ/Core/Utils/SocketUtility.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ internal static class SocketUtility
4747
/// <exception cref="SocketException">an error occurred when attempting to access the socket.</exception>
4848
public static void Select(IList? checkRead, IList? checkWrite, IList? checkError, int microSeconds)
4949
{
50-
#if NET35
51-
// .NET 3.5 has a bug, such that -1 is not blocking the select call - therefore we use here instead the maximum integer value.
52-
if (microSeconds == -1)
53-
microSeconds = int.MaxValue;
54-
#endif
55-
5650
Socket.Select(checkRead, checkWrite, checkError, microSeconds);
5751
}
5852
}

src/NetMQ/DnsEndPoint.cs

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

src/NetMQ/Monitoring/NetMQMonitor.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System;
22
using System.Threading;
3-
#if !NET35
43
using System.Threading.Tasks;
5-
#endif
64
using AsyncIO;
75
using NetMQ.Core;
86
using NetMQ.Sockets;
@@ -289,7 +287,6 @@ public void Start()
289287
}
290288
}
291289

292-
#if !NET35
293290
/// <summary>
294291
/// Start a background task for the monitoring operation.
295292
/// </summary>
@@ -304,7 +301,6 @@ public Task StartAsync()
304301

305302
return Task.Factory.StartNew(Start);
306303
}
307-
#endif
308304

309305
/// <summary>
310306
/// Stop monitoring. Blocks until monitoring completed.
@@ -352,11 +348,7 @@ protected virtual void Dispose(bool disposing)
352348

353349
m_monitoringSocket.ReceiveReady -= Handle;
354350

355-
#if NET35
356-
m_isStoppedEvent.Close();
357-
#else
358351
m_isStoppedEvent.Dispose();
359-
#endif
360352

361353
if (m_ownsMonitoringSocket && !attachedToPoller)
362354
{

src/NetMQ/NetMQBeacon.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,7 @@ private void Configure(string interfaceName, int port)
7676
{
7777
m_poller.Remove(m_udpSocket);
7878

79-
#if NET35
80-
m_udpSocket.Close();
81-
#else
8279
m_udpSocket.Dispose();
83-
#endif
8480
}
8581

8682
m_udpPort = port;
@@ -182,11 +178,7 @@ public void Run(PairSocket shim)
182178
}
183179

184180
// the beacon might never been configured
185-
#if NET35
186-
m_udpSocket?.Close();
187-
#else
188181
m_udpSocket?.Dispose();
189-
#endif
190182
}
191183

192184
private void PingElapsed(object? sender, NetMQTimerEventArgs e)

src/NetMQ/NetMQPoller.cs

Lines changed: 6 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66
using System.Net.Sockets;
77
using System.Threading;
88
using NetMQ.Core.Utils;
9-
#if !NET35
109
using System.Threading.Tasks;
11-
#endif
12-
#if NET40
13-
using System.ComponentModel;
14-
#endif
1510

1611
using Switch = NetMQ.Core.Utils.Switch;
1712

@@ -21,15 +16,10 @@ namespace NetMQ
2116
/// Enable polling on multiple NetMQSockets
2217
/// </summary>
2318
public sealed class NetMQPoller :
24-
#if !NET35
2519
TaskScheduler,
26-
#endif
27-
#if NET40
28-
ISynchronizeInvoke,
29-
#endif
30-
#pragma warning disable 618
20+
#pragma warning disable 618 // Type or member is obsolete
3121
INetMQPoller, ISocketPollableCollection, IEnumerable, IDisposable
32-
#pragma warning restore 618
22+
#pragma warning restore 618 // Type or member is obsolete
3323
{
3424
private readonly List<NetMQSocket> m_sockets = new List<NetMQSocket>();
3525
private readonly List<NetMQTimer> m_timers = new List<NetMQTimer>();
@@ -39,18 +29,13 @@ public sealed class NetMQPoller :
3929
private readonly StopSignaler m_stopSignaler = new StopSignaler();
4030

4131
private NetMQSelector.Item[]? m_pollSet;
42-
private NetMQSocket[]? m_pollact;
32+
private NetMQSocket[]? m_pollact;
4333

44-
private volatile bool m_isPollSetDirty = true;
34+
private volatile bool m_isPollSetDirty = true;
4535
private int m_disposeState = (int)DisposeState.Undisposed;
4636

47-
#if NET35
48-
private Thread m_pollerThread;
49-
#endif
50-
5137
#region Scheduling
5238

53-
#if !NET35
5439
private readonly NetMQQueue<Task> m_tasksQueue = new NetMQQueue<Task>();
5540
private readonly ThreadLocal<bool> m_isSchedulerThread = new ThreadLocal<bool>(() => false);
5641

@@ -130,12 +115,6 @@ public void Run(Action action)
130115
else
131116
new Task(action).Start(this);
132117
}
133-
#else
134-
private void Run(Action action)
135-
{
136-
action();
137-
}
138-
#endif
139118

140119
#endregion
141120

@@ -146,8 +125,6 @@ public NetMQPoller()
146125
{
147126
m_sockets.Add(((ISocketPollable)m_stopSignaler).Socket);
148127

149-
#if !NET35
150-
151128
m_tasksQueue.ReceiveReady += delegate
152129
{
153130
Debug.Assert(m_disposeState != (int)DisposeState.Disposed);
@@ -159,7 +136,6 @@ public NetMQPoller()
159136
};
160137

161138
m_sockets.Add(((ISocketPollable)m_tasksQueue).Socket);
162-
#endif
163139
}
164140

165141
/// <summary>
@@ -172,11 +148,7 @@ public NetMQPoller()
172148
/// </summary>
173149
public bool IsDisposed => m_disposeState == (int)DisposeState.Disposed;
174150

175-
#if NET35
176-
private bool IsPollerThread => ReferenceEquals(m_pollerThread, Thread.CurrentThread);
177-
#else
178151
private bool IsPollerThread => m_isSchedulerThread.Value;
179-
#endif
180152

181153
#region Add / Remove
182154

@@ -353,7 +325,6 @@ public void Remove(Socket socket)
353325
#endregion
354326

355327
#region Contains
356-
#if !NET35
357328

358329
/// <summary>
359330
/// Check if poller contains the socket asynchronously.
@@ -404,7 +375,7 @@ public Task<bool> ContainsAsync(Socket socket)
404375
Run(() => tcs.SetResult(m_pollinSockets.ContainsKey(socket)));
405376
return tcs.Task;
406377
}
407-
#endif
378+
408379
#endregion
409380

410381
#region Start / Stop
@@ -451,31 +422,6 @@ public void RunAsync(string threadName, bool isBackgroundThread)
451422
m_switch.WaitForOn();
452423
}
453424

454-
#if NET35
455-
/// <summary>
456-
/// Runs the poller on the caller's thread. Only returns when <see cref="Stop"/> or <see cref="StopAsync"/> are called from another thread.
457-
/// </summary>
458-
public void Run()
459-
{
460-
CheckDisposed();
461-
if (IsRunning)
462-
throw new InvalidOperationException("NetMQPoller is already running");
463-
464-
m_pollerThread = Thread.CurrentThread;
465-
m_stopSignaler.Reset();
466-
m_switch.SwitchOn();
467-
468-
try
469-
{
470-
RunPoller();
471-
}
472-
finally
473-
{
474-
m_pollerThread = null;
475-
m_switch.SwitchOff();
476-
}
477-
}
478-
#else
479425
/// <summary>
480426
/// Runs the poller on the caller's thread. Only returns when <see cref="Stop"/> or <see cref="StopAsync"/> are called from another thread.
481427
/// </summary>
@@ -514,9 +460,7 @@ public void Run(SynchronizationContext syncContext)
514460
SynchronizationContext.SetSynchronizationContext(oldSynchronisationContext);
515461
m_switch.SwitchOff();
516462
}
517-
518463
}
519-
#endif
520464

521465
/// <summary>
522466
/// Runs the poller on the caller's thread. Only returns when <see cref="Stop"/> or <see cref="StopAsync"/> are called from another thread.
@@ -693,9 +637,7 @@ private void OnSocketEventsChanged(object? sender, NetMQSocketEventArgs e)
693637

694638
private void RebuildPollset()
695639
{
696-
#if !NET35
697640
Debug.Assert(m_isSchedulerThread.Value);
698-
#endif
699641

700642
// Recreate the m_pollSet and m_pollact arrays.
701643
m_pollSet = new NetMQSelector.Item[m_sockets.Count + m_pollinSockets.Count];
@@ -777,10 +719,9 @@ public void Dispose()
777719

778720
m_sockets.Remove(((ISocketPollable)m_stopSignaler).Socket);
779721
m_stopSignaler.Dispose();
780-
#if !NET35
722+
781723
m_sockets.Remove(((ISocketPollable)m_tasksQueue).Socket);
782724
m_tasksQueue.Dispose();
783-
#endif
784725

785726
foreach (var socket in m_sockets)
786727
{

src/NetMQ/NetMQQueue.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#if !NET35
21
using System;
32
using System.Collections.Concurrent;
43
using System.Collections.Generic;
@@ -163,4 +162,3 @@ public void Dispose()
163162
}
164163
}
165164
}
166-
#endif

0 commit comments

Comments
 (0)