Skip to content

Commit 16cbddb

Browse files
authored
Improved Package Spec & Reduced Warnings (#168)
1 parent 88db36e commit 16cbddb

File tree

5 files changed

+33
-34
lines changed

5 files changed

+33
-34
lines changed

Source/HiveMQtt/HiveMQtt.csproj

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup Label="Build">
4-
<AssemblyName>HiveMQtt</AssemblyName>
5-
<Description>The HiveMQ MQTT Client is a MQTT 5.0 compatible C# library.</Description>
6-
</PropertyGroup>
7-
8-
<PropertyGroup>
9-
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net6.0;net7.0;net8.0;</TargetFrameworks>
105
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
11-
</PropertyGroup>
6+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
7+
8+
<IncludeSymbols>true</IncludeSymbols>
9+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1210

13-
<PropertyGroup>
1411
<MinVerTagPrefix>v</MinVerTagPrefix>
1512
</PropertyGroup>
1613

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

2321
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

Tests/HiveMQtt.Test/HiveMQClient/Operational/QueuedPublishesTest.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public class QueuedPublishesTest
1010
[Fact]
1111
public async Task Queued_Messages_Chain_Async()
1212
{
13-
1413
var batchSize = 1000;
1514

1615
var tasks = new[]
@@ -78,7 +77,7 @@ private async Task<int> RelayClientAsync()
7877
// Republish the Message to the second topic
7978
var payload = args.PublishMessage.Payload;
8079
var publishResult = await subscribeClient.PublishAsync(secondTopic, payload, QualityOfService.ExactlyOnceDelivery).ConfigureAwait(false);
81-
Assert.NotNull(publishResult.QoS2ReasonCode);
80+
Assert.NotNull(publishResult?.QoS2ReasonCode);
8281

8382
// Atomically increment the relayCount
8483
Interlocked.Increment(ref relayCount);

Tests/HiveMQtt.Test/HiveMQClient/PublishBuilderTest.cs

+23-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace HiveMQtt.Test.HiveMQClient;
22

3-
using System.Text;
43
using System.Threading.Tasks;
54
using HiveMQtt.Client;
65
using HiveMQtt.MQTT5.ReasonCodes;
@@ -9,6 +8,9 @@ namespace HiveMQtt.Test.HiveMQClient;
98

109
public class PublishBuilderTest
1110
{
11+
12+
private readonly byte[] payload = { 0x01, 0x02, 0x03 };
13+
1214
[Fact]
1315
public async Task MostBasicPublishWithQoS0Async()
1416
{
@@ -18,15 +20,15 @@ public async Task MostBasicPublishWithQoS0Async()
1820

1921
var message = new PublishMessageBuilder()
2022
.WithTopic("tests/MostBasicPublishWithQoS0Async")
21-
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
22-
.WithQualityOfService(MQTT5.Types.QualityOfService.AtMostOnceDelivery)
23+
.WithPayload(this.payload)
24+
.WithQualityOfService(QualityOfService.AtMostOnceDelivery)
2325
.Build();
2426

2527
var result = await client.PublishAsync(message).ConfigureAwait(false);
2628
Assert.IsType<Client.Results.PublishResult>(result);
2729
Assert.Null(result.QoS1ReasonCode);
2830
Assert.Null(result.QoS2ReasonCode);
29-
Assert.Equal(MQTT5.Types.QualityOfService.AtMostOnceDelivery, result.Message.QoS);
31+
Assert.Equal(QualityOfService.AtMostOnceDelivery, result.Message.QoS);
3032

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

4244
var message = new PublishMessageBuilder()
4345
.WithTopic("tests/MostBasicPublishWithQoS1Async")
44-
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
45-
.WithQualityOfService(MQTT5.Types.QualityOfService.AtLeastOnceDelivery)
46+
.WithPayload(this.payload)
47+
.WithQualityOfService(QualityOfService.AtLeastOnceDelivery)
4648
.Build();
4749
var result = await client.PublishAsync(message).ConfigureAwait(false);
4850
Assert.IsType<Client.Results.PublishResult>(result);
4951
Assert.NotNull(result.QoS1ReasonCode);
5052
Assert.Null(result.QoS2ReasonCode);
51-
Assert.Equal(MQTT5.Types.QualityOfService.AtLeastOnceDelivery, result.Message.QoS);
53+
Assert.Equal(QualityOfService.AtLeastOnceDelivery, result.Message.QoS);
5254

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

6466
var message = new PublishMessageBuilder()
6567
.WithTopic("tests/MostBasicPublishWithQoS1Async")
66-
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
67-
.WithQualityOfService(MQTT5.Types.QualityOfService.ExactlyOnceDelivery)
68+
.WithPayload(this.payload)
69+
.WithQualityOfService(QualityOfService.ExactlyOnceDelivery)
6870
.Build();
6971
var result = await client.PublishAsync(message).ConfigureAwait(false);
7072
Assert.IsType<Client.Results.PublishResult>(result);
7173
Assert.NotNull(result.QoS2ReasonCode);
7274
Assert.Null(result.QoS1ReasonCode);
73-
Assert.Equal(MQTT5.Types.QualityOfService.ExactlyOnceDelivery, result.Message.QoS);
75+
Assert.Equal(QualityOfService.ExactlyOnceDelivery, result.Message.QoS);
7476

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

8688
var message = new PublishMessageBuilder()
8789
.WithTopic("tests/MultiPublishWithQoS0Async")
88-
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
89-
.WithQualityOfService(MQTT5.Types.QualityOfService.AtMostOnceDelivery)
90+
.WithPayload(this.payload)
91+
.WithQualityOfService(QualityOfService.AtMostOnceDelivery)
9092
.Build();
9193

9294
Client.Results.PublishResult result;
@@ -97,7 +99,7 @@ public async Task MultiPublishWithQoS0Async()
9799
Assert.IsType<Client.Results.PublishResult>(result);
98100
Assert.Null(result.QoS1ReasonCode);
99101
Assert.Null(result.QoS2ReasonCode);
100-
Assert.Equal(MQTT5.Types.QualityOfService.AtMostOnceDelivery, result.Message.QoS);
102+
Assert.Equal(QualityOfService.AtMostOnceDelivery, result.Message.QoS);
101103
}
102104

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

114116
var message = new PublishMessageBuilder()
115117
.WithTopic("tests/MultiPublishWithQoS1Async")
116-
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
117-
.WithQualityOfService(MQTT5.Types.QualityOfService.AtLeastOnceDelivery)
118+
.WithPayload(this.payload)
119+
.WithQualityOfService(QualityOfService.AtLeastOnceDelivery)
118120
.Build();
119121
Client.Results.PublishResult result;
120122

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

140142
var message = new PublishMessageBuilder()
141143
.WithTopic("tests/MultiPublishWithQoS2Async")
142-
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
143-
.WithQualityOfService(MQTT5.Types.QualityOfService.ExactlyOnceDelivery)
144+
.WithPayload(this.payload)
145+
.WithQualityOfService(QualityOfService.ExactlyOnceDelivery)
144146
.Build();
145147
Client.Results.PublishResult result;
146148

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

165167
var message = new PublishMessageBuilder()
166168
.WithTopic("tests/PublishWithOptionsAsync")
167-
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
168-
.WithQualityOfService(MQTT5.Types.QualityOfService.AtMostOnceDelivery)
169+
.WithPayload(this.payload)
170+
.WithQualityOfService(QualityOfService.AtMostOnceDelivery)
169171
.WithUserProperty("test", "test")
170172
.Build();
171173

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

190192
var message = new PublishMessageBuilder()
191193
.WithTopic("tests/PublishPayloadFormatIndicatorAsync")
192-
.WithPayload(new byte[] { 0x01, 0x02, 0x03 })
193-
.WithQualityOfService(MQTT5.Types.QualityOfService.AtMostOnceDelivery)
194+
.WithPayload(this.payload)
195+
.WithQualityOfService(QualityOfService.AtMostOnceDelivery)
194196
.WithPayloadFormatIndicator(MQTT5PayloadFormatIndicator.UTF8Encoded)
195197
.Build();
196198

Tests/HiveMQtt.Test/HiveMQClient/PublishTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ async void Client2MessageHandler(object? sender, OnMessageReceivedEventArgs even
221221

222222
// client 3 will receive the final message
223223
#pragma warning disable VSTHRD100 // Avoid async void methods
224-
async void Client3MessageHandler(object? sender, OnMessageReceivedEventArgs eventArgs)
224+
void Client3MessageHandler(object? sender, OnMessageReceivedEventArgs eventArgs)
225225
{
226226
Interlocked.Increment(ref client3MessageCount);
227227
Assert.NotNull(eventArgs.PublishMessage);

Tests/HiveMQtt.Test/HiveMQtt.Test.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup Label="Build">
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;</TargetFrameworks>
55
<ReleaseVersion>0.1.0</ReleaseVersion>
66
</PropertyGroup>
77

0 commit comments

Comments
 (0)