Skip to content

Commit b782d03

Browse files
committed
Fix invalid assertion in TcpListener
1 parent 77bad9f commit b782d03

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public virtual void SetAddress(string addr)
123123
m_address.Resolve(addr, m_options.IPv4Only);
124124

125125
Assumes.NotNull(m_address.Address);
126-
Assumes.NotNull(m_handle);
126+
Assumes.Null(m_handle);
127127

128128
try
129129
{

src/NetMQ/Utils/Assumes.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ internal static class Assumes
99
[Conditional("DEBUG")]
1010
public static void NotNull<T>([NotNull] T o) where T : class?
1111
{
12-
Debug.Assert(o is object, $"Unexpected null of type {typeof(T).Name}");
12+
Debug.Assert(o is not null, $"Unexpected null value of type {typeof(T).Name}");
1313
}
1414
#pragma warning restore CS8777 // Parameter must have a non-null value when exiting.
15+
16+
[Conditional("DEBUG")]
17+
public static void Null<T>([MaybeNull] T o) where T : class?
18+
{
19+
Debug.Assert(o is null, $"Unexpected non-null value of type {typeof(T).Name}");
20+
}
1521
}
1622
}

0 commit comments

Comments
 (0)