Convert null checks to modern ThrowIfNull checks (#2089)

Convert null check to modern ThrowIfNull checks
This commit is contained in:
Andrea Vouk
2024-10-26 11:41:58 +02:00
committed by GitHub
parent 0506857f0d
commit 63d85184e1
85 changed files with 209 additions and 783 deletions
@@ -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);