mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-21 12:16:02 +08:00
Convert null checks to modern ThrowIfNull checks (#2089)
Convert null check to modern ThrowIfNull checks
This commit is contained in:
@@ -11,10 +11,7 @@ public static class MqttPublishPacketFactory
|
||||
{
|
||||
public static MqttPublishPacket Create(MqttConnectPacket connectPacket)
|
||||
{
|
||||
if (connectPacket == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(connectPacket));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(connectPacket);
|
||||
|
||||
if (!connectPacket.WillFlag)
|
||||
{
|
||||
@@ -46,10 +43,7 @@ public static class MqttPublishPacketFactory
|
||||
|
||||
public static MqttPublishPacket Create(MqttApplicationMessage applicationMessage)
|
||||
{
|
||||
if (applicationMessage == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(applicationMessage));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(applicationMessage);
|
||||
|
||||
// Copy all values to their matching counterparts.
|
||||
// The not supported values in MQTT 3.1.1 are not serialized (excluded) later.
|
||||
@@ -75,10 +69,7 @@ public static class MqttPublishPacketFactory
|
||||
|
||||
public static MqttPublishPacket Create(MqttRetainedMessageMatch retainedMessage)
|
||||
{
|
||||
if (retainedMessage == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(retainedMessage));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(retainedMessage);
|
||||
|
||||
var publishPacket = Create(retainedMessage.ApplicationMessage);
|
||||
publishPacket.QualityOfServiceLevel = retainedMessage.SubscriptionQualityOfServiceLevel;
|
||||
|
||||
Reference in New Issue
Block a user