Skip to content

Commit

Permalink
Improved Package Spec & Reduced Warnings (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
pglombardo authored May 29, 2024
1 parent 88db36e commit 16cbddb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 34 deletions.
16 changes: 7 additions & 9 deletions Source/HiveMQtt/HiveMQtt.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Label="Build">
<AssemblyName>HiveMQtt</AssemblyName>
<Description>The HiveMQ MQTT Client is a MQTT 5.0 compatible C# library.</Description>
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0;</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

<PropertyGroup>
<MinVerTagPrefix>v</MinVerTagPrefix>
</PropertyGroup>

<PropertyGroup Label="Package">
<Product>HiveMQtt</Product>
<Description>The HiveMQ MQTT Client is a MQTT 5.0 compatible C# library.</Description>
<PackageTags>MQTT;HIVEMQ;IOT</PackageTags>
<PackageTags>MQTT;HIVEMQ;IOT;MQTTClient;MQTT5;QoS;MQTTTopics;IndustrialIoT;ConnectedDevices;EdgeComputing;IoTDevices;Queue;Message;EmbeddedSystems;M2M;SensorNetwork</PackageTags>
<Copyright>Copyright (c) HiveMQ GmbH</Copyright>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class QueuedPublishesTest
[Fact]
public async Task Queued_Messages_Chain_Async()
{

var batchSize = 1000;

var tasks = new[]
Expand Down Expand Up @@ -78,7 +77,7 @@ private async Task<int> RelayClientAsync()
// Republish the Message to the second topic
var payload = args.PublishMessage.Payload;
var publishResult = await subscribeClient.PublishAsync(secondTopic, payload, QualityOfService.ExactlyOnceDelivery).ConfigureAwait(false);

Check warning on line 79 in Tests/HiveMQtt.Test/HiveMQClient/Operational/QueuedPublishesTest.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-6.0.x

Possible null reference argument for parameter 'payload' in 'Task<PublishResult> HiveMQClient.PublishAsync(string topic, byte[] payload, QualityOfService qos = QualityOfService.AtMostOnceDelivery)'.

Check warning on line 79 in Tests/HiveMQtt.Test/HiveMQClient/Operational/QueuedPublishesTest.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-7.0.x

Possible null reference argument for parameter 'payload' in 'Task<PublishResult> HiveMQClient.PublishAsync(string topic, byte[] payload, QualityOfService qos = QualityOfService.AtMostOnceDelivery)'.

Check warning on line 79 in Tests/HiveMQtt.Test/HiveMQClient/Operational/QueuedPublishesTest.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-8.0.x

Possible null reference argument for parameter 'payload' in 'Task<PublishResult> HiveMQClient.PublishAsync(string topic, byte[] payload, QualityOfService qos = QualityOfService.AtMostOnceDelivery)'.
Assert.NotNull(publishResult.QoS2ReasonCode);
Assert.NotNull(publishResult?.QoS2ReasonCode);

// Atomically increment the relayCount
Interlocked.Increment(ref relayCount);
Expand Down
44 changes: 23 additions & 21 deletions Tests/HiveMQtt.Test/HiveMQClient/PublishBuilderTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace HiveMQtt.Test.HiveMQClient;

using System.Text;
using System.Threading.Tasks;
using HiveMQtt.Client;
using HiveMQtt.MQTT5.ReasonCodes;
Expand All @@ -9,6 +8,9 @@ namespace HiveMQtt.Test.HiveMQClient;

public class PublishBuilderTest
{

Check warning on line 10 in Tests/HiveMQtt.Test/HiveMQClient/PublishBuilderTest.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-6.0.x

An opening brace should not be followed by a blank line. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1505.md)

Check warning on line 10 in Tests/HiveMQtt.Test/HiveMQClient/PublishBuilderTest.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-7.0.x

An opening brace should not be followed by a blank line. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1505.md)

Check warning on line 10 in Tests/HiveMQtt.Test/HiveMQClient/PublishBuilderTest.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-8.0.x

An opening brace should not be followed by a blank line. (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1505.md)

private readonly byte[] payload = { 0x01, 0x02, 0x03 };

[Fact]
public async Task MostBasicPublishWithQoS0Async()
{
Expand All @@ -18,15 +20,15 @@ public async Task MostBasicPublishWithQoS0Async()

var message = new PublishMessageBuilder()
.WithTopic("tests/MostBasicPublishWithQoS0Async")
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
.WithQualityOfService(MQTT5.Types.QualityOfService.AtMostOnceDelivery)
.WithPayload(this.payload)
.WithQualityOfService(QualityOfService.AtMostOnceDelivery)
.Build();

var result = await client.PublishAsync(message).ConfigureAwait(false);
Assert.IsType<Client.Results.PublishResult>(result);
Assert.Null(result.QoS1ReasonCode);
Assert.Null(result.QoS2ReasonCode);
Assert.Equal(MQTT5.Types.QualityOfService.AtMostOnceDelivery, result.Message.QoS);
Assert.Equal(QualityOfService.AtMostOnceDelivery, result.Message.QoS);

var disconnectResult = await client.DisconnectAsync().ConfigureAwait(false);
Assert.True(disconnectResult);
Expand All @@ -41,14 +43,14 @@ public async Task MostBasicPublishWithQoS1Async()

var message = new PublishMessageBuilder()
.WithTopic("tests/MostBasicPublishWithQoS1Async")
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
.WithQualityOfService(MQTT5.Types.QualityOfService.AtLeastOnceDelivery)
.WithPayload(this.payload)
.WithQualityOfService(QualityOfService.AtLeastOnceDelivery)
.Build();
var result = await client.PublishAsync(message).ConfigureAwait(false);
Assert.IsType<Client.Results.PublishResult>(result);
Assert.NotNull(result.QoS1ReasonCode);
Assert.Null(result.QoS2ReasonCode);
Assert.Equal(MQTT5.Types.QualityOfService.AtLeastOnceDelivery, result.Message.QoS);
Assert.Equal(QualityOfService.AtLeastOnceDelivery, result.Message.QoS);

var disconnectResult = await client.DisconnectAsync().ConfigureAwait(false);
Assert.True(disconnectResult);
Expand All @@ -63,14 +65,14 @@ public async Task MostBasicPublishWithQoS2Async()

var message = new PublishMessageBuilder()
.WithTopic("tests/MostBasicPublishWithQoS1Async")
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
.WithQualityOfService(MQTT5.Types.QualityOfService.ExactlyOnceDelivery)
.WithPayload(this.payload)
.WithQualityOfService(QualityOfService.ExactlyOnceDelivery)
.Build();
var result = await client.PublishAsync(message).ConfigureAwait(false);
Assert.IsType<Client.Results.PublishResult>(result);
Assert.NotNull(result.QoS2ReasonCode);
Assert.Null(result.QoS1ReasonCode);
Assert.Equal(MQTT5.Types.QualityOfService.ExactlyOnceDelivery, result.Message.QoS);
Assert.Equal(QualityOfService.ExactlyOnceDelivery, result.Message.QoS);

var disconnectResult = await client.DisconnectAsync().ConfigureAwait(false);
Assert.True(disconnectResult);
Expand All @@ -85,8 +87,8 @@ public async Task MultiPublishWithQoS0Async()

var message = new PublishMessageBuilder()
.WithTopic("tests/MultiPublishWithQoS0Async")
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
.WithQualityOfService(MQTT5.Types.QualityOfService.AtMostOnceDelivery)
.WithPayload(this.payload)
.WithQualityOfService(QualityOfService.AtMostOnceDelivery)
.Build();

Client.Results.PublishResult result;
Expand All @@ -97,7 +99,7 @@ public async Task MultiPublishWithQoS0Async()
Assert.IsType<Client.Results.PublishResult>(result);
Assert.Null(result.QoS1ReasonCode);
Assert.Null(result.QoS2ReasonCode);
Assert.Equal(MQTT5.Types.QualityOfService.AtMostOnceDelivery, result.Message.QoS);
Assert.Equal(QualityOfService.AtMostOnceDelivery, result.Message.QoS);
}

var disconnectResult = await client.DisconnectAsync().ConfigureAwait(false);
Expand All @@ -113,8 +115,8 @@ public async Task MultiPublishWithQoS1Async()

var message = new PublishMessageBuilder()
.WithTopic("tests/MultiPublishWithQoS1Async")
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
.WithQualityOfService(MQTT5.Types.QualityOfService.AtLeastOnceDelivery)
.WithPayload(this.payload)
.WithQualityOfService(QualityOfService.AtLeastOnceDelivery)
.Build();
Client.Results.PublishResult result;

Expand All @@ -139,8 +141,8 @@ public async Task MultiPublishWithQoS2Async()

var message = new PublishMessageBuilder()
.WithTopic("tests/MultiPublishWithQoS2Async")
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
.WithQualityOfService(MQTT5.Types.QualityOfService.ExactlyOnceDelivery)
.WithPayload(this.payload)
.WithQualityOfService(QualityOfService.ExactlyOnceDelivery)
.Build();
Client.Results.PublishResult result;

Expand All @@ -164,8 +166,8 @@ public async Task PublishWithOptionsAsync()

var message = new PublishMessageBuilder()
.WithTopic("tests/PublishWithOptionsAsync")
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
.WithQualityOfService(MQTT5.Types.QualityOfService.AtMostOnceDelivery)
.WithPayload(this.payload)
.WithQualityOfService(QualityOfService.AtMostOnceDelivery)
.WithUserProperty("test", "test")
.Build();

Expand All @@ -189,8 +191,8 @@ public async Task PublishPayloadFormatIndicatorAsync()

var message = new PublishMessageBuilder()
.WithTopic("tests/PublishPayloadFormatIndicatorAsync")
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
.WithQualityOfService(MQTT5.Types.QualityOfService.AtMostOnceDelivery)
.WithPayload(this.payload)
.WithQualityOfService(QualityOfService.AtMostOnceDelivery)
.WithPayloadFormatIndicator(MQTT5PayloadFormatIndicator.UTF8Encoded)
.Build();

Expand Down
2 changes: 1 addition & 1 deletion Tests/HiveMQtt.Test/HiveMQClient/PublishTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ async void Client2MessageHandler(object? sender, OnMessageReceivedEventArgs even

// client 3 will receive the final message
#pragma warning disable VSTHRD100 // Avoid async void methods
async void Client3MessageHandler(object? sender, OnMessageReceivedEventArgs eventArgs)
void Client3MessageHandler(object? sender, OnMessageReceivedEventArgs eventArgs)
{
Interlocked.Increment(ref client3MessageCount);
Assert.NotNull(eventArgs.PublishMessage);
Expand Down
2 changes: 1 addition & 1 deletion Tests/HiveMQtt.Test/HiveMQtt.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Label="Build">
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;</TargetFrameworks>
<ReleaseVersion>0.1.0</ReleaseVersion>
</PropertyGroup>

Expand Down

0 comments on commit 16cbddb

Please sign in to comment.