Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint: Code Improvement & Cleanup #123

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/AfterConnectEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.AfterConnect"/> event.
/// <para>This event is called after a connect is sent to the broker.</para>
/// <para><see cref="AfterConnectEventArgs.ConnectResult"/> contains the result of the connect operation.</para>
/// <para><see cref="ConnectResult"/> contains the result of the connect operation.</para>
/// </summary>
public class AfterConnectEventArgs : EventArgs
{
Expand Down
4 changes: 2 additions & 2 deletions Source/HiveMQtt/Client/Events/AfterDisconnectEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace HiveMQtt.Client.Events;
/// </para>
/// <para>
/// If the disconnect was caused by a call to <see cref="HiveMQClient.DisconnectAsync"/>, then
/// <see cref="AfterDisconnectEventArgs.CleanDisconnect"/> will be <c>true</c>. If the disconnect
/// was caused by a failure, then <see cref="AfterDisconnectEventArgs.CleanDisconnect"/> will be
/// <see cref="CleanDisconnect"/> will be <c>true</c>. If the disconnect
/// was caused by a failure, then <see cref="CleanDisconnect"/> will be
/// <c>false</c>.
/// </para>
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/AfterSubscribeEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.AfterSubscribe"/> event.
/// <para>This event is called after a subscribe is sent to the broker.</para>
/// <para><see cref="AfterSubscribeEventArgs.SubscribeResult"/> contains the result of the subscribe operation.</para>
/// <para><see cref="SubscribeResult"/> contains the result of the subscribe operation.</para>
/// </summary>
public class AfterSubscribeEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/AfterUnsubscribeEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.AfterUnsubscribe"/> event.
/// <para>This event is called after a unsubscribe is sent to the broker.</para>
/// <para><see cref="AfterUnsubscribeEventArgs.UnsubscribeResult"/> contains the result of the unsubscribe operation.</para>
/// <para><see cref="UnsubscribeResult"/> contains the result of the unsubscribe operation.</para>
/// </summary>
public class AfterUnsubscribeEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/BeforeConnectEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.BeforeConnect"/> event.
/// <para>This event is called before a connect is sent to the broker.</para>
/// <para><see cref="BeforeConnectEventArgs.Options"/> contains the options of the connect operation.</para>
/// <para><see cref="Options"/> contains the options of the connect operation.</para>
/// </summary>
public class BeforeConnectEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/BeforeSubscribeEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.BeforeSubscribe"/> event.
/// <para>This event is called before a subscribe is sent to the broker.</para>
/// <para><see cref="BeforeSubscribeEventArgs.Options"/> contains the options of the subscribe operation.</para>
/// <para><see cref="Options"/> contains the options of the subscribe operation.</para>
/// </summary>
public class BeforeSubscribeEventArgs : EventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.BeforeUnsubscribe"/> event.
/// <para>This event is called before an unsubscribe is sent to the broker.</para>
/// <para><see cref="BeforeUnsubscribeEventArgs.Subscriptions"/> contains the subscriptions to unsubscribe.</para>
/// <para><see cref="Subscriptions"/> contains the subscriptions to unsubscribe.</para>
/// </summary>
public class BeforeUnsubscribeEventArgs : EventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnConnAckReceived"/> event.
/// <para>This event is called when a CONNACK packet is received from the broker.</para>
/// <para><see cref="OnConnAckReceivedEventArgs.ConnAckPacket"/> contains the received CONNACK packet.</para>
/// <para><see cref="ConnAckPacket"/> contains the received CONNACK packet.</para>
/// </summary>
public class OnConnAckReceivedEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/OnConnectSentEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnConnectSent"/> event.
/// <para>This event is called when a CONNECT packet is sent to the broker.</para>
/// <para><see cref="OnConnectSentEventArgs.ConnectPacket"/> contains the sent CONNECT packet.</para>
/// <para><see cref="ConnectPacket"/> contains the sent CONNECT packet.</para>
/// </summary>
public class OnConnectSentEventArgs : EventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnDisconnectReceived"/> event.
/// <para>This event is called when a DISCONNECT packet is received from the broker.</para>
/// <para><see cref="OnDisconnectReceivedEventArgs.DisconnectPacket"/> contains the received DISCONNECT packet.</para>
/// <para><see cref="DisconnectPacket"/> contains the received DISCONNECT packet.</para>
/// </summary>
public class OnDisconnectReceivedEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/OnDisconnectSentEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnDisconnectSent"/> event.
/// <para>This event is called when a DISCONNECT packet is sent to the broker.</para>
/// <para><see cref="OnDisconnectSentEventArgs.DisconnectPacket"/> contains the sent DISCONNECT packet.</para>
/// <para><see cref="DisconnectPacket"/> contains the sent DISCONNECT packet.</para>
/// </summary>
public class OnDisconnectSentEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/OnPingReqSentEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnPingReqSent"/> event.
/// <para>This event is called when a PINGREQ packet is sent to the broker.</para>
/// <para><see cref="OnPingReqSentEventArgs.PingReqPacket"/> contains the sent PINGREQ packet.</para>
/// <para><see cref="PingReqPacket"/> contains the sent PINGREQ packet.</para>
/// </summary>
public class OnPingReqSentEventArgs : EventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnPingRespReceived"/> event.
/// <para>This event is called when a PINGRESP packet is received from the broker.</para>
/// <para><see cref="OnPingRespReceivedEventArgs.PingRespPacket"/> contains the received PINGRESP packet.</para>
/// <para><see cref="PingRespPacket"/> contains the received PINGRESP packet.</para>
/// </summary>
public class OnPingRespReceivedEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/OnPubAckReceivedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnPubAckReceived"/> event.
/// <para>This event is called when a PUBACK packet is received from the broker.</para>
/// <para><see cref="OnPubAckReceivedEventArgs.PubAckPacket"/> contains the received PUBACK packet.</para>
/// <para><see cref="PubAckPacket"/> contains the received PUBACK packet.</para>
/// </summary>
public class OnPubAckReceivedEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/OnPubAckSentEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnPubAckSent"/> event.
/// <para>This event is called when a PUBACK packet is sent to the broker.</para>
/// <para><see cref="OnPubAckSentEventArgs.PubAckPacket"/> contains the sent PUBACK packet.</para>
/// <para><see cref="PubAckPacket"/> contains the sent PUBACK packet.</para>
/// </summary>
public class OnPubAckSentEventArgs : EventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnPubCompReceived"/> event.
/// <para>This event is called when a PUBCOMP packet is received from the broker.</para>
/// <para><see cref="OnPubCompReceivedEventArgs.PubCompPacket"/> contains the received PUBCOMP packet.</para>
/// <para><see cref="PubCompPacket"/> contains the received PUBCOMP packet.</para>
/// </summary>
public class OnPubCompReceivedEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/OnPubCompSentEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnPubCompReceived"/> event.
/// <para>This event is called when a PUBCOMP packet is received from the broker.</para>
/// <para><see cref="OnPubCompReceivedEventArgs.PubCompPacket"/> contains the received PUBCOMP packet.</para>
/// <para><see cref="PubCompPacket"/> contains the received PUBCOMP packet.</para>
/// </summary>
public class OnPubCompSentEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/OnPubRecReceivedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnPubRecReceived"/> event.
/// <para>This event is called when a PUBREC packet is received from the broker.</para>
/// <para><see cref="OnPubRecReceivedEventArgs.PubRecPacket"/> contains the received PUBREC packet.</para>
/// <para><see cref="PubRecPacket"/> contains the received PUBREC packet.</para>
/// </summary>
public class OnPubRecReceivedEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/OnPubRecSentEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnPubRecSent"/> event.
/// <para>This event is called when a PUBREC packet is sent to the broker.</para>
/// <para><see cref="OnPubRecSentEventArgs.PubRecPacket"/> contains the sent PUBREC packet.</para>
/// <para><see cref="PubRecPacket"/> contains the sent PUBREC packet.</para>
/// </summary>
public class OnPubRecSentEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/OnPubRelReceivedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnPubRelReceived"/> event.
/// <para>This event is called when a PUBREL packet is received from the broker.</para>
/// <para><see cref="OnPubRelReceivedEventArgs.PubRelPacket"/> contains the received PUBREL packet.</para>
/// <para><see cref="PubRelPacket"/> contains the received PUBREL packet.</para>
/// </summary>
public class OnPubRelReceivedEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/OnPubRelSentEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnPubRelSent"/> event.
/// <para>This event is called when a PUBREL packet is sent to the broker.</para>
/// <para><see cref="OnPubRelSentEventArgs.PubRelPacket"/> contains the sent PUBREL packet.</para>
/// <para><see cref="PubRelPacket"/> contains the sent PUBREL packet.</para>
/// </summary>
public class OnPubRelSentEventArgs : EventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="PublishPacket.OnPublishQoS1Complete"/> event.
/// <para>This event is called when a QoS level 1 publish as been completed.</para>
/// <para><see cref="OnPublishQoS1CompleteEventArgs.PubAckPacket"/> contains the received PUBACK packet.</para>
/// <para><see cref="PubAckPacket"/> contains the received PUBACK packet.</para>
/// </summary>
public class OnPublishQoS1CompleteEventArgs : EventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="PublishPacket.OnPublishQoS2Complete"/> event.
/// <para>This event is called when a QoS level 2 publish as been completed.</para>
/// <para><see cref="OnPublishQoS2CompleteEventArgs.PacketList"/> contains the list of
/// <para><see cref="PacketList"/> contains the list of
/// packets sent/received in the QoS 2 transaction chain.</para>
/// </summary>
public class OnPublishQoS2CompleteEventArgs : EventArgs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnPublishReceived"/> event.
/// <para>This event is called when a PUBLISH packet is received from the broker.</para>
/// <para><see cref="OnPublishReceivedEventArgs.PublishPacket"/> contains the received PUBLISH packet.</para>
/// <para><see cref="PublishPacket"/> contains the received PUBLISH packet.</para>
/// </summary>
public class OnPublishReceivedEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/OnPublishSentEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnPublishSent"/> event.
/// <para>This event is called when a PUBLISH packet is sent to the broker.</para>
/// <para><see cref="OnPublishSentEventArgs.PublishPacket"/> contains the sent PUBLISH packet.</para>
/// <para><see cref="PublishPacket"/> contains the sent PUBLISH packet.</para>
/// </summary>
public class OnPublishSentEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/OnSubAckReceivedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnSubAckReceived"/> event.
/// <para>This event is called when a SUBACK packet is received from the broker.</para>
/// <para><see cref="OnSubAckReceivedEventArgs.SubAckPacket"/> contains the received SUBACK packet.</para>
/// <para><see cref="SubAckPacket"/> contains the received SUBACK packet.</para>
/// </summary>
public class OnSubAckReceivedEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Events/OnSubscribeSentEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnSubscribeSent"/> event.
/// <para>This event is called when a SUBSCRIBE packet is sent to the broker.</para>
/// <para><see cref="OnSubscribeSentEventArgs.SubscribePacket"/> contains the sent SUBSCRIBE packet.</para>
/// <para><see cref="SubscribePacket"/> contains the sent SUBSCRIBE packet.</para>
/// </summary>
public class OnSubscribeSentEventArgs : EventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnUnsubAckReceived"/> event.
/// <para>This event is called when a UNSUBACK packet is received from the broker.</para>
/// <para><see cref="OnUnsubAckReceivedEventArgs.UnsubAckPacket"/> contains the received UNSUBACK packet.</para>
/// <para><see cref="UnsubAckPacket"/> contains the received UNSUBACK packet.</para>
/// </summary>
public class OnUnsubAckReceivedEventArgs : EventArgs
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace HiveMQtt.Client.Events;
/// <summary>
/// Event arguments for the <see cref="HiveMQClient.OnUnsubscribeSent"/> event.
/// <para>This event is called when a UNSUBSCRIBE packet is sent to the broker.</para>
/// <para><see cref="OnUnsubscribeSentEventArgs.UnsubscribePacket"/> contains the sent UNSUBSCRIBE packet.</para>
/// <para><see cref="UnsubscribePacket"/> contains the sent UNSUBSCRIBE packet.</para>
/// </summary>
public class OnUnsubscribeSentEventArgs : EventArgs
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/Options/DisconnectOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public DisconnectOptions()

/// <summary>
/// Gets or sets the session expiry. This sets the expiration for the session
/// to the indicated value. The value respresents the session expiration time
/// to the indicated value. The value represents the session expiration time
/// in seconds.
/// </summary>
public int? SessionExpiry { get; set; }
Expand Down
15 changes: 3 additions & 12 deletions Source/HiveMQtt/Client/internal/Validator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ public class Validator
/// <param name="clientId">The client identifier to validate.</param>
public static void ValidateClientId(string clientId)
{
if (clientId is null)
{
throw new ArgumentNullException(nameof(clientId));
}
ArgumentNullException.ThrowIfNull(clientId);

if (clientId.Length > 65535)
{
Expand Down Expand Up @@ -62,10 +59,7 @@ public static void ValidateClientId(string clientId)
/// <exception cref="HiveMQttClientException">Thrown when the topic name contains any null characters.</exception>
public static void ValidateTopicName(string topic)
{
if (topic is null)
{
throw new ArgumentNullException(nameof(topic));
}
ArgumentNullException.ThrowIfNull(topic);

if (topic.Length > 65535)
{
Expand Down Expand Up @@ -99,10 +93,7 @@ public static void ValidateTopicName(string topic)
/// <exception cref="HiveMQttClientException">Thrown when the topic filter contains any null characters.</exception>
public static void ValidateTopicFilter(string topic)
{
if (topic is null)
{
throw new ArgumentNullException(nameof(topic));
}
ArgumentNullException.ThrowIfNull(topic);

if (topic.Length > 65535)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/HiveMQtt/MQTT5/PacketDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal class PacketDecoder
{
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();

public static Boolean TryDecode(ReadOnlySequence<byte> buffer, out ControlPacket decodedPacket, out SequencePosition consumed)
public static bool TryDecode(ReadOnlySequence<byte> buffer, out ControlPacket decodedPacket, out SequencePosition consumed)
{
try
{
Expand Down
5 changes: 4 additions & 1 deletion Source/HiveMQtt/MQTT5/Packets/ConnectPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ public byte[] Encode()
_ = EncodeUTF8String(vhAndPayloadStream, this.clientOptions.LastWillAndTestament.Topic);

// Will Payload
_ = EncodeBinaryData(vhAndPayloadStream, this.clientOptions.LastWillAndTestament.Payload);
if (this.clientOptions.LastWillAndTestament.Payload != null)
{
_ = EncodeBinaryData(vhAndPayloadStream, this.clientOptions.LastWillAndTestament.Payload);
}
}

// Username
Expand Down
4 changes: 2 additions & 2 deletions Source/HiveMQtt/MQTT5/Types/MQTT5LastWillProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ internal class MQTT5LastWillProperties
{
public MQTT5LastWillProperties() => this.UserProperties = new Dictionary<string, string>();

public UInt32? WillDelayInterval { get; set; }
public uint? WillDelayInterval { get; set; }

public byte? PayloadFormatIndicator { get; set; }

public UInt32? MessageExpiryInterval { get; set; }
public uint? MessageExpiryInterval { get; set; }

public string? ContentType { get; set; }

Expand Down
Loading