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
@@ -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)