Skip to content

Commit f74c15a

Browse files
committed
Annotate all public API for nullability
1 parent aa4ea84 commit f74c15a

Some content is hidden

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

66 files changed

+611
-535
lines changed

src/NetMQ/AsyncReceiveExtensions.cs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#if NETSTANDARD2_0 || NETSTANDARD2_1 || NET47
1+
#nullable enable
2+
#if NETSTANDARD2_0 || NETSTANDARD2_1 || NET47
23

34
using System;
45
using System.Collections.Generic;
56
using System.Text;
67
using System.Threading;
78
using System.Threading.Tasks;
8-
using JetBrains.Annotations;
99

1010
namespace NetMQ
1111
{
@@ -33,7 +33,7 @@ public static class AsyncReceiveExtensions
3333
/// <param name="cancellationToken">The token used to propagate notification that this operation should be canceled.</param>
3434
/// <returns>The content of the received message.</returns>
3535
public static async Task<NetMQMessage> ReceiveMultipartMessageAsync(
36-
[NotNull] this NetMQSocket socket,
36+
this NetMQSocket socket,
3737
int expectedFrameCount = 4,
3838
CancellationToken cancellationToken = default(CancellationToken))
3939
{
@@ -63,9 +63,8 @@ public static async Task<NetMQMessage> ReceiveMultipartMessageAsync(
6363
/// <param name="socket">The socket to receive from.</param>
6464
/// <param name="cancellationToken">The token used to propagate notification that this operation should be canceled.</param>
6565
/// <returns>The content of the received message frame and boolean indicate if another frame of the same message follows.</returns>
66-
[NotNull]
6766
public static Task<(byte[], bool)> ReceiveFrameBytesAsync(
68-
[NotNull] this NetMQSocket socket,
67+
this NetMQSocket socket,
6968
CancellationToken cancellationToken = default(CancellationToken)
7069
)
7170
{
@@ -117,9 +116,8 @@ void Listener(object sender, NetMQSocketEventArgs args)
117116
/// <param name="socket">The socket to receive from.</param>
118117
/// <param name="cancellationToken">The token used to propagate notification that this operation should be canceled.</param>
119118
/// <returns>The content of the received message frame as a string and a boolean indicate if another frame of the same message follows.</returns>
120-
[NotNull]
121119
public static Task<(string, bool)> ReceiveFrameStringAsync(
122-
[NotNull] this NetMQSocket socket,
120+
this NetMQSocket socket,
123121
CancellationToken cancellationToken = default(CancellationToken)
124122
)
125123
{
@@ -134,10 +132,9 @@ void Listener(object sender, NetMQSocketEventArgs args)
134132
/// <param name="encoding">The encoding used to convert the frame's data to a string.</param>
135133
/// <param name="cancellationToken">The token used to propagate notification that this operation should be canceled.</param>
136134
/// <returns>The content of the received message frame as a string and boolean indicate if another frame of the same message follows..</returns>
137-
[NotNull]
138135
public static Task<(string, bool)> ReceiveFrameStringAsync(
139-
[NotNull] this NetMQSocket socket,
140-
[NotNull] Encoding encoding,
136+
this NetMQSocket socket,
137+
Encoding encoding,
141138
CancellationToken cancellationToken = default(CancellationToken))
142139
{
143140
if (NetMQRuntime.Current == null)
@@ -190,7 +187,7 @@ void Listener(object sender, NetMQSocketEventArgs args)
190187
/// </summary>
191188
/// <param name="socket">The socket to receive from.</param>
192189
/// <returns>Boolean indicate if another frame of the same message follows</returns>
193-
public static Task<bool> SkipFrameAsync([NotNull] this NetMQSocket socket)
190+
public static Task<bool> SkipFrameAsync(this NetMQSocket socket)
194191
{
195192
if (NetMQRuntime.Current == null)
196193
throw new InvalidOperationException("NetMQRuntime must be created before calling async functions");
@@ -235,7 +232,7 @@ void Listener(object sender, NetMQSocketEventArgs args)
235232
/// Receive all frames of the next message from <paramref name="socket"/>, asynchronously, then ignore their contents.
236233
/// </summary>
237234
/// <param name="socket">The socket to receive from.</param>
238-
public static async Task SkipMultipartMessageAsync([NotNull] this NetMQSocket socket)
235+
public static async Task SkipMultipartMessageAsync(this NetMQSocket socket)
239236
{
240237
while (true)
241238
{
@@ -256,7 +253,7 @@ public static async Task SkipMultipartMessageAsync([NotNull] this NetMQSocket so
256253
/// <param name="socket">The socket to receive from.</param>
257254
/// <returns>The routing key and a boolean indicate if another frame of the same message follows.</returns>
258255

259-
public static async Task<(RoutingKey, bool)> ReceiveRoutingKeyAsync([NotNull] this NetMQSocket socket)
256+
public static async Task<(RoutingKey, bool)> ReceiveRoutingKeyAsync(this NetMQSocket socket)
260257
{
261258
var (bytes, more) = await socket.ReceiveFrameBytesAsync();
262259

src/NetMQ/AtomicCounterPool.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using JetBrains.Annotations;
1+
#nullable enable
2+
23
using NetMQ.Core.Utils;
34
using System;
45
using System.Threading;
@@ -15,14 +16,13 @@ public interface IAtomicCounterPool : IDisposable
1516
/// Take an AtomicCounter from the pool.
1617
/// </summary>
1718
/// <returns>an atomic counter</returns>
18-
[NotNull]
1919
AtomicCounter Take();
2020

2121
/// <summary>
2222
/// Return the given atomic counter to the common pool.
2323
/// </summary>
2424
/// <param name="counter">the atomic counter to return to the buffer-pool</param>
25-
void Return([NotNull] AtomicCounter counter);
25+
void Return(AtomicCounter counter);
2626
}
2727

2828
/// <summary>
@@ -99,7 +99,7 @@ public static void SetGCCounterPool()
9999
/// Set BufferPool to use the specified IAtomicCounterPool implementation to manage the pool.
100100
/// </summary>
101101
/// <param name="counterPool">the implementation of <see cref="IAtomicCounterPool"/> to use</param>
102-
public static void SetCustomCounterPool([NotNull] IAtomicCounterPool counterPool)
102+
public static void SetCustomCounterPool(IAtomicCounterPool counterPool)
103103
{
104104
var prior = Interlocked.Exchange(ref s_counterPool, counterPool);
105105

@@ -110,7 +110,6 @@ public static void SetCustomCounterPool([NotNull] IAtomicCounterPool counterPool
110110
/// Allocate an atomic counter from the current <see cref="IAtomicCounterPool"/>.
111111
/// </summary>
112112
/// <returns>an atomic counter</returns>
113-
[NotNull]
114113
public static AtomicCounter Take()
115114
{
116115
return s_counterPool.Take();
@@ -120,7 +119,7 @@ public static AtomicCounter Take()
120119
/// Returns <paramref name="counter"/> to the <see cref="IAtomicCounterPool"/>.
121120
/// </summary>
122121
/// <param name="counter">The atomic counter to be returned to the pool.</param>
123-
public static void Return([NotNull] AtomicCounter counter)
122+
public static void Return(AtomicCounter counter)
124123
{
125124
s_counterPool.Return(counter);
126125
}

src/NetMQ/BufferPool.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
#nullable enable
2+
13
using System;
24
using System.ServiceModel.Channels;
35
using System.Threading;
4-
using JetBrains.Annotations;
56

67
namespace NetMQ
78
{
@@ -16,14 +17,13 @@ public interface IBufferPool : IDisposable
1617
/// </summary>
1718
/// <param name="size">the number of bytes to take</param>
1819
/// <returns>a byte-array that comes from the buffer-pool</returns>
19-
[NotNull]
2020
byte[] Take(int size);
2121

2222
/// <summary>
2323
/// Return the given byte-array buffer to the common buffer-pool.
2424
/// </summary>
2525
/// <param name="buffer">the byte-array to return to the buffer-pool</param>
26-
void Return([NotNull] byte[] buffer);
26+
void Return(byte[] buffer);
2727
}
2828

2929
/// <summary>
@@ -180,7 +180,7 @@ public static void SetBufferManagerBufferPool(long maxBufferPoolSize, int maxBuf
180180
/// Set BufferPool to use the specified IBufferPool implementation to manage the buffer-pool.
181181
/// </summary>
182182
/// <param name="bufferPool">the implementation of <see cref="IBufferPool"/> to use</param>
183-
public static void SetCustomBufferPool([NotNull] IBufferPool bufferPool)
183+
public static void SetCustomBufferPool(IBufferPool bufferPool)
184184
{
185185
var prior = Interlocked.Exchange(ref s_bufferPool, bufferPool);
186186

@@ -192,7 +192,6 @@ public static void SetCustomBufferPool([NotNull] IBufferPool bufferPool)
192192
/// </summary>
193193
/// <param name="size">The minimum size required, in bytes.</param>
194194
/// <returns>A byte array having at least <paramref name="size"/> bytes.</returns>
195-
[NotNull]
196195
public static byte[] Take(int size)
197196
{
198197
return s_bufferPool.Take(size);
@@ -202,7 +201,7 @@ public static byte[] Take(int size)
202201
/// Returns <paramref name="buffer"/> to the <see cref="IBufferPool"/>.
203202
/// </summary>
204203
/// <param name="buffer">The byte array to be returned to the pool.</param>
205-
public static void Return([NotNull] byte[] buffer)
204+
public static void Return(byte[] buffer)
206205
{
207206
s_bufferPool.Return(buffer);
208207
}

src/NetMQ/EmptyArray.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#nullable enable
2+
13
namespace NetMQ
24
{
35
internal static class EmptyArray<T>

src/NetMQ/Endianness.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace NetMQ
1+
#nullable enable
2+
3+
namespace NetMQ
24
{
35
/// <summary>
46
/// This enum-type specifies either big-endian (Big) or little-endian (Little),

src/NetMQ/ErrorCode.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#nullable enable
2+
13
namespace NetMQ
24
{
35
/// <summary>

src/NetMQ/EventDelegator.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
using System;
1+
#nullable enable
2+
3+
using System;
24
using System.Threading;
3-
using JetBrains.Annotations;
45

56
namespace NetMQ
67
{
@@ -16,15 +17,15 @@ internal class EventDelegator<T> : IDisposable where T : EventArgs
1617
{
1718
private readonly Action m_registerToEvent;
1819
private readonly Action m_unregisterFromEvent;
19-
private EventHandler<T> m_event;
20+
private EventHandler<T>? m_event;
2021
private int m_counter;
2122

2223
/// <summary>
2324
/// Initialises a new instance.
2425
/// </summary>
2526
/// <param name="registerToEvent">an Action to perform when the first handler is registered for the event</param>
2627
/// <param name="unregisterFromEvent">an Action to perform when the last handler is unregistered from the event</param>
27-
public EventDelegator([NotNull] Action registerToEvent, [NotNull] Action unregisterFromEvent)
28+
public EventDelegator(Action registerToEvent, Action unregisterFromEvent)
2829
{
2930
m_registerToEvent = registerToEvent;
3031
m_unregisterFromEvent = unregisterFromEvent;
@@ -53,7 +54,7 @@ public event EventHandler<T> Event
5354
/// </summary>
5455
/// <param name="sender">the sender that the event-handler that gets notified of this event will receive</param>
5556
/// <param name="args">the subclass of EventArgs that the event-handler will receive</param>
56-
public void Fire([NotNull] object sender, [NotNull] T args)
57+
public void Fire(object sender, T args)
5758
{
5859
m_event?.Invoke(sender, args);
5960
}

src/NetMQ/INetMQPoller.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#nullable enable
2+
13
using System;
24

35
namespace NetMQ

src/NetMQ/INetMQSocket.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
using System;
2-
using JetBrains.Annotations;
1+
#nullable enable
2+
3+
using System;
34
using NetMQ.Core.Utils;
45

56
namespace NetMQ
@@ -54,7 +55,7 @@ public interface INetMQSocket : IOutgoingSocket, IReceivingSocket, ISocketPollab
5455
/// <exception cref="AddressAlreadyInUseException">The specified address is already in use.</exception>
5556
/// <exception cref="NetMQException">No IO thread was found, or the protocol's listener encountered an
5657
/// error during initialisation.</exception>
57-
void Bind([NotNull] string address);
58+
void Bind(string address);
5859

5960
/// <summary>Binds the specified TCP <paramref name="address"/> to an available port, assigned by the operating system.</summary>
6061
/// <returns>the chosen port-number</returns>
@@ -64,7 +65,7 @@ public interface INetMQSocket : IOutgoingSocket, IReceivingSocket, ISocketPollab
6465
/// <exception cref="AddressAlreadyInUseException">The specified address is already in use.</exception>
6566
/// <exception cref="NetMQException">No IO thread was found, or the protocol's listener errored during
6667
/// initialisation.</exception>
67-
int BindRandomPort([NotNull] string address);
68+
int BindRandomPort(string address);
6869

6970
/// <summary>
7071
/// Connect the socket to <paramref name="address"/>.
@@ -74,7 +75,7 @@ public interface INetMQSocket : IOutgoingSocket, IReceivingSocket, ISocketPollab
7475
/// <exception cref="TerminatingException">The socket has been stopped.</exception>
7576
/// <exception cref="NetMQException">No IO thread was found.</exception>
7677
/// <exception cref="AddressAlreadyInUseException">The specified address is already in use.</exception>
77-
void Connect([NotNull] string address);
78+
void Connect(string address);
7879

7980
/// <summary>
8081
/// Disconnect this socket from <paramref name="address"/>.
@@ -83,7 +84,7 @@ public interface INetMQSocket : IOutgoingSocket, IReceivingSocket, ISocketPollab
8384
/// <exception cref="ObjectDisposedException">thrown if the socket was already disposed</exception>
8485
/// <exception cref="TerminatingException">The socket has been stopped.</exception>
8586
/// <exception cref="EndpointNotFoundException">Endpoint was not found and cannot be disconnected.</exception>
86-
void Disconnect([NotNull] string address);
87+
void Disconnect(string address);
8788

8889
/// <summary>
8990
/// Unbind this socket from <paramref name="address"/>.
@@ -92,7 +93,7 @@ public interface INetMQSocket : IOutgoingSocket, IReceivingSocket, ISocketPollab
9293
/// <exception cref="ObjectDisposedException">thrown if the socket was already disposed</exception>
9394
/// <exception cref="TerminatingException">The socket has been stopped.</exception>
9495
/// <exception cref="EndpointNotFoundException">Endpoint was not found and cannot be disconnected.</exception>
95-
void Unbind([NotNull] string address);
96+
void Unbind(string address);
9697

9798
/// <summary>Closes this socket, rendering it unusable. Equivalent to calling <see cref="NetMQSocket.Dispose()"/>.</summary>
9899
void Close();
@@ -137,6 +138,6 @@ public interface INetMQSocket : IOutgoingSocket, IReceivingSocket, ISocketPollab
137138
/// <exception cref="ProtocolNotSupportedException">The protocol of <paramref name="endpoint"/> is not supported.</exception>
138139
/// <exception cref="TerminatingException">The socket has been stopped.</exception>
139140
/// <exception cref="NetMQException">Maximum number of sockets reached.</exception>
140-
void Monitor([NotNull] string endpoint, SocketEvents events = SocketEvents.All);
141+
void Monitor(string endpoint, SocketEvents events = SocketEvents.All);
141142
}
142143
}

src/NetMQ/IOutgoingSocket.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
#nullable enable
2+
3+
using System;
24

35
namespace NetMQ
46
{

0 commit comments

Comments
 (0)