Skip to content

Commit 3b8923b

Browse files
authored
Merge pull request #1056 from jonorossi/remove-netstandard-16-symbols
Remove .NET Standard 1.6 conditional code
2 parents ebe5ad3 + 1b0d1b1 commit 3b8923b

File tree

8 files changed

+12
-76
lines changed

8 files changed

+12
-76
lines changed

src/NetMQ/Core/MonitorEvent.cs

-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ internal class MonitorEvent
2020

2121
static MonitorEvent()
2222
{
23-
#if NETSTANDARD1_6
24-
s_sizeOfIntPtr = Marshal.SizeOf<IntPtr>();
25-
#else
2623
s_sizeOfIntPtr = Marshal.SizeOf(typeof(IntPtr));
27-
#endif
2824

2925
if (s_sizeOfIntPtr > 4)
3026
s_sizeOfIntPtr = 8;

src/NetMQ/Core/Transports/Pgm/PgmSocket.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,16 @@ internal void Init()
9595
{
9696
string xMsg = $"SocketException with SocketErrorCode={x.SocketErrorCode}, Message={x.Message}, in PgmSocket.Init, within AsyncSocket.Create(AddressFamily.InterNetwork, SocketType.Rdm, PGM_PROTOCOL_TYPE), {this}";
9797
Debug.WriteLine(xMsg);
98-
// If running on Microsoft Windows, suggest to the developer that he may need to install MSMQ in order to get PGM socket support.
9998

100-
#if NETSTANDARD1_6
99+
// If running on Microsoft Windows, suggest to the developer that he may need to install MSMQ in order to get PGM socket support.
100+
#if NETSTANDARD1_1_OR_GREATER
101101
bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
102102
#else
103-
PlatformID p = Environment.OSVersion.Platform;
104103
bool isWindows = true;
105-
switch (p)
104+
switch (Environment.OSVersion.Platform)
106105
{
107106
case PlatformID.Win32NT:
108-
break;
109107
case PlatformID.Win32S:
110-
break;
111108
case PlatformID.Win32Windows:
112109
break;
113110
default:
@@ -122,6 +119,7 @@ internal void Init()
122119
throw new FaultException(innerException: x, message: xMsg);
123120
}
124121
#endif
122+
125123
Handle.ExclusiveAddressUse = false;
126124
Handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
127125
}

src/NetMQ/Core/Transports/Tcp/TcpAddress.cs

-4
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ public void Resolve(string name, bool ip4Only)
102102
}
103103
else if (!IPAddress.TryParse(addrStr, out ipAddress))
104104
{
105-
#if NETSTANDARD1_6
106-
var availableAddresses = Dns.GetHostEntryAsync(addrStr).Result.AddressList;
107-
#else
108105
var availableAddresses = Dns.GetHostEntry(addrStr).AddressList;
109-
#endif
110106

111107
ipAddress = ip4Only
112108
? availableAddresses.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork)

src/NetMQ/Core/Utils/Clock.cs

-8
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,13 @@ internal static class Clock
3939
/// </summary>
4040
private static long s_lastTime;
4141

42-
#if !NETSTANDARD1_6
4342
/// <summary>
4443
/// This flag indicates whether the rdtsc instruction is supported on this platform.
4544
/// </summary>
4645
private static readonly bool s_rdtscSupported;
47-
#endif
4846

4947
static Clock()
5048
{
51-
#if !NETSTANDARD1_6
5249
try
5350
{
5451
if (Environment.OSVersion.Platform == PlatformID.Win32NT ||
@@ -66,7 +63,6 @@ static Clock()
6663
{
6764
s_rdtscSupported = false;
6865
}
69-
#endif
7066
}
7167

7268
/// <summary>
@@ -109,11 +105,7 @@ public static long NowMs()
109105
/// </summary>
110106
public static long Rdtsc()
111107
{
112-
#if NETSTANDARD1_6
113-
return 0;
114-
#else
115108
return s_rdtscSupported ? (long?)Opcode.Rdtsc?.Invoke() ?? 0 : 0;
116-
#endif
117109
}
118110
}
119111
}

src/NetMQ/Core/Utils/OpCode.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if !NETSTANDARD1_6
2-
using System;
1+
using System;
32
using System.Reflection;
43
using System.Runtime.InteropServices;
54

@@ -181,5 +180,4 @@ public static extern bool VirtualFree(IntPtr lpAddress, UIntPtr dwSize,
181180
FreeType dwFreeType);
182181
}
183182
}
184-
}
185-
#endif
183+
}

src/NetMQ/Core/Utils/PollerBase.cs

-4
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,8 @@ public int Load
8686
{
8787
get
8888
{
89-
#if NETSTANDARD1_6
90-
return Volatile.Read(ref m_load);
91-
#else
9289
Thread.MemoryBarrier();
9390
return m_load;
94-
#endif
9591
}
9692
}
9793

src/NetMQ/NetMQBeacon.cs

-4
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,7 @@ public string? HostName
360360

361361
try
362362
{
363-
#if NETSTANDARD1_6
364-
return m_hostName = Dns.GetHostEntryAsync(boundTo).Result.HostName;
365-
#else
366363
return m_hostName = Dns.GetHostEntry(boundTo).HostName;
367-
#endif
368364
}
369365
catch
370366
{

src/NetMQ/NetMQException.cs

+6-42
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
using System;
22
using System.Net.Sockets;
33
using System.Runtime.Serialization;
4-
5-
#if !NETSTANDARD1_6
64
using System.Security.Permissions;
7-
#endif
8-
95
using NetMQ.Core;
106

117
namespace NetMQ
128
{
139
/// <summary>
1410
/// Base class for custom exceptions within the NetMQ library.
1511
/// </summary>
16-
#if !NETSTANDARD1_6
1712
[Serializable]
18-
#endif
1913
public class NetMQException : Exception
2014
{
2115
/// <summary>
@@ -50,8 +44,6 @@ public NetMQException(string message, Exception innerException)
5044
: base(message, innerException)
5145
{}
5246

53-
#if !NETSTANDARD1_6
54-
5547
/// <summary>Constructor for serialisation.</summary>
5648
protected NetMQException(SerializationInfo info, StreamingContext context)
5749
: base(info, context)
@@ -67,8 +59,6 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
6759
base.GetObjectData(info, context);
6860
}
6961

70-
#endif
71-
7262
#endregion
7363

7464
/// <summary>
@@ -182,9 +172,7 @@ private static NetMQException Create(ErrorCode errorCode, string? message, Excep
182172
/// <summary>
183173
/// AddressAlreadyInUseException is a NetMQException that is used within SocketBase.Bind to signal an address-conflict.
184174
/// </summary>
185-
#if !NETSTANDARD1_6
186175
[Serializable]
187-
#endif
188176
public class AddressAlreadyInUseException : NetMQException
189177
{
190178
/// <summary>
@@ -206,21 +194,17 @@ public AddressAlreadyInUseException(string? message)
206194
{
207195
}
208196

209-
#if !NETSTANDARD1_6
210197
/// <summary>Constructor for serialisation.</summary>
211198
protected AddressAlreadyInUseException(SerializationInfo info, StreamingContext context)
212199
: base(info, context)
213200
{
214201
}
215-
#endif
216202
}
217203

218204
/// <summary>
219205
/// EndpointNotFoundException is a NetMQException that is used within Ctx.FindEndpoint to signal a failure to find a specified address.
220206
/// </summary>
221-
#if !NETSTANDARD1_6
222207
[Serializable]
223-
#endif
224208
public class EndpointNotFoundException : NetMQException
225209
{
226210
/// <summary>
@@ -250,22 +234,18 @@ public EndpointNotFoundException()
250234
{
251235
}
252236

253-
#if !NETSTANDARD1_6
254237
/// <summary>Constructor for serialisation.</summary>
255238
protected EndpointNotFoundException(SerializationInfo info, StreamingContext context)
256239
: base(info, context)
257240
{
258241
}
259-
#endif
260242
}
261243

262244
/// <summary>
263245
/// TerminatingException is a NetMQException that is used within SocketBase and Ctx to signal
264246
/// that you're making the mistake of trying to do further work after terminating the message-queueing system.
265247
/// </summary>
266-
#if !NETSTANDARD1_6
267248
[Serializable]
268-
#endif
269249
public class TerminatingException : NetMQException
270250
{
271251
/// <summary>
@@ -294,21 +274,18 @@ internal TerminatingException()
294274
: this(null, null)
295275
{
296276
}
297-
#if !NETSTANDARD1_6
277+
298278
/// <summary>Constructor for serialisation.</summary>
299279
protected TerminatingException(SerializationInfo info, StreamingContext context)
300280
: base(info, context)
301281
{
302282
}
303-
#endif
304283
}
305284

306285
/// <summary>
307286
/// InvalidException is a NetMQException that is used within the message-queueing system to signal invalid value errors.
308287
/// </summary>
309-
#if !NETSTANDARD1_6
310288
[Serializable]
311-
#endif
312289
public class InvalidException : NetMQException
313290
{
314291
/// <summary>
@@ -337,21 +314,18 @@ public InvalidException()
337314
: this(null, null)
338315
{
339316
}
340-
#if !NETSTANDARD1_6
317+
341318
/// <summary>Constructor for serialisation.</summary>
342319
protected InvalidException(SerializationInfo info, StreamingContext context)
343320
: base(info, context)
344321
{
345322
}
346-
#endif
347323
}
348324

349325
/// <summary>
350326
/// FaultException is a NetMQException that is used within the message-queueing system to signal general fault conditions.
351327
/// </summary>
352-
#if !NETSTANDARD1_6
353328
[Serializable]
354-
#endif
355329
public class FaultException : NetMQException
356330
{
357331
/// <summary>
@@ -380,22 +354,19 @@ public FaultException()
380354
: this(null, null)
381355
{
382356
}
383-
#if !NETSTANDARD1_6
357+
384358
/// <summary>Constructor for serialisation.</summary>
385359
protected FaultException(SerializationInfo info, StreamingContext context)
386360
: base(info, context)
387361
{
388362
}
389-
#endif
390363
}
391364

392365
/// <summary>
393366
/// ProtocolNotSupportedException is a NetMQException that is used within the message-queueing system to signal
394367
/// mistakes in properly utilizing the communications protocols.
395368
/// </summary>
396-
#if !NETSTANDARD1_6
397369
[Serializable]
398-
#endif
399370
public class ProtocolNotSupportedException : NetMQException
400371
{
401372
/// <summary>
@@ -424,22 +395,19 @@ public ProtocolNotSupportedException()
424395
: this(null, null)
425396
{
426397
}
427-
#if !NETSTANDARD1_6
398+
428399
/// <summary>Constructor for serialisation.</summary>
429400
protected ProtocolNotSupportedException(SerializationInfo info, StreamingContext context)
430401
: base(info, context)
431402
{
432403
}
433-
#endif
434404
}
435405

436406
/// <summary>
437407
/// HostUnreachableException is an Exception that is used within the message-queueing system
438408
/// to signal failures to communicate with a host.
439409
/// </summary>
440-
#if !NETSTANDARD1_6
441410
[Serializable]
442-
#endif
443411
public class HostUnreachableException : NetMQException
444412
{
445413
/// <summary>
@@ -468,22 +436,19 @@ public HostUnreachableException()
468436
: this(null, null)
469437
{
470438
}
471-
#if !NETSTANDARD1_6
439+
472440
/// <summary>Constructor for serialisation.</summary>
473441
protected HostUnreachableException(SerializationInfo info, StreamingContext context)
474442
: base(info, context)
475443
{
476444
}
477-
#endif
478445
}
479446

480447
/// <summary>
481448
/// FiniteStateMachineException is an Exception that is used within the message-queueing system
482449
/// to signal errors in the send/receive order with request/response sockets.
483450
/// </summary>
484-
#if !NETSTANDARD1_6
485451
[Serializable]
486-
#endif
487452
public class FiniteStateMachineException : NetMQException
488453
{
489454
/// <summary>
@@ -512,12 +477,11 @@ public FiniteStateMachineException()
512477
: this(null, null)
513478
{
514479
}
515-
#if !NETSTANDARD1_6
480+
516481
/// <summary>Constructor for serialisation.</summary>
517482
protected FiniteStateMachineException(SerializationInfo info, StreamingContext context)
518483
: base(info, context)
519484
{
520485
}
521-
#endif
522486
}
523487
}

0 commit comments

Comments
 (0)