mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-29 09:52:55 +08:00
Convert null checks to modern ThrowIfNull checks (#2089)
Convert null check to modern ThrowIfNull checks
This commit is contained in:
@@ -25,10 +25,7 @@ public sealed class MqttV5PacketEncoder
|
||||
|
||||
public MqttPacketBuffer Encode(MqttPacket packet)
|
||||
{
|
||||
if (packet == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(packet));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(packet);
|
||||
|
||||
// Leave enough head space for max header size (fixed + 4 variable remaining length = 5 bytes)
|
||||
const int ReservedHeaderSize = 5;
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace MQTTnet.Formatter.V5
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
// Absence of the flag means it is supported!
|
||||
// Absence of the flag means it is supported!
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -230,10 +230,7 @@ namespace MQTTnet.Formatter.V5
|
||||
|
||||
public void WriteTo(MqttBufferWriter target)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(target));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(target);
|
||||
|
||||
target.WriteVariableByteInteger((uint)_bufferWriter.Length);
|
||||
target.Write(_bufferWriter);
|
||||
|
||||
Reference in New Issue
Block a user