mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-24 22:53:04 +08:00
Convert null checks to modern ThrowIfNull checks (#2089)
Convert null check to modern ThrowIfNull checks
This commit is contained in:
@@ -19,10 +19,7 @@ public sealed class MqttClientUnsubscribeOptionsBuilder
|
||||
|
||||
public MqttClientUnsubscribeOptionsBuilder WithTopicFilter(string topic)
|
||||
{
|
||||
if (topic is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(topic));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(topic);
|
||||
|
||||
if (_unsubscribeOptions.TopicFilters is null)
|
||||
{
|
||||
@@ -36,10 +33,7 @@ public sealed class MqttClientUnsubscribeOptionsBuilder
|
||||
|
||||
public MqttClientUnsubscribeOptionsBuilder WithTopicFilter(MqttTopicFilter topicFilter)
|
||||
{
|
||||
if (topicFilter is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(topicFilter));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(topicFilter);
|
||||
|
||||
return WithTopicFilter(topicFilter.Topic);
|
||||
}
|
||||
@@ -59,10 +53,7 @@ public sealed class MqttClientUnsubscribeOptionsBuilder
|
||||
/// </summary>
|
||||
public MqttClientUnsubscribeOptionsBuilder WithUserProperty(MqttUserProperty userProperty)
|
||||
{
|
||||
if (userProperty is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(userProperty));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(userProperty);
|
||||
|
||||
if (_unsubscribeOptions.UserProperties is null)
|
||||
{
|
||||
|
||||
@@ -12,10 +12,7 @@ public static class MqttClientUnsubscribeOptionsValidator
|
||||
{
|
||||
public static void ThrowIfNotSupported(MqttClientUnsubscribeOptions options, MqttProtocolVersion protocolVersion)
|
||||
{
|
||||
if (options == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(options);
|
||||
|
||||
if (protocolVersion == MqttProtocolVersion.V500)
|
||||
{
|
||||
|
||||
@@ -15,15 +15,8 @@ public sealed class MqttClientUnsubscribeResultFactory
|
||||
|
||||
public MqttClientUnsubscribeResult Create(MqttUnsubscribePacket unsubscribePacket, MqttUnsubAckPacket unsubAckPacket)
|
||||
{
|
||||
if (unsubscribePacket == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(unsubscribePacket));
|
||||
}
|
||||
|
||||
if (unsubAckPacket == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(unsubAckPacket));
|
||||
}
|
||||
ArgumentNullException.ThrowIfNull(unsubscribePacket);
|
||||
ArgumentNullException.ThrowIfNull(unsubAckPacket);
|
||||
|
||||
// MQTTv3.1.1 has no reason code at all!
|
||||
if (unsubAckPacket.ReasonCodes != null && unsubAckPacket.ReasonCodes.Count != unsubscribePacket.TopicFilters.Count)
|
||||
|
||||
Reference in New Issue
Block a user