From aafd4ea6580a3ed73ea853d19457e1b16cbaa60f Mon Sep 17 00:00:00 2001 From: PMExtra Date: Wed, 1 Apr 2020 15:30:24 +0800 Subject: [PATCH] Fix. --- Build/MQTTnet.nuspec | 2 +- Source/MQTTnet/Extensions/UserPropertyExtension.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec index e09ed01..c409f86 100644 --- a/Build/MQTTnet.nuspec +++ b/Build/MQTTnet.nuspec @@ -22,7 +22,7 @@ * [Server] Added interceptor for unsubscriptions. * [MQTTnet.Server] Added interceptor for unsubscriptions. * [MQTTnet.AspNetCore] improved compatibility with AspNetCore 3.1 -* [MqttApplicationMessage] Added GetUserProperty convenience method (thanks to @PMExtra). +* [Core] Added MqttApplicationMessage.GetUserProperty<T>() convenience method (thanks to @PMExtra). Copyright Christian Kratky 2016-2019 MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin diff --git a/Source/MQTTnet/Extensions/UserPropertyExtension.cs b/Source/MQTTnet/Extensions/UserPropertyExtension.cs index 273be25..b4c83b4 100644 --- a/Source/MQTTnet/Extensions/UserPropertyExtension.cs +++ b/Source/MQTTnet/Extensions/UserPropertyExtension.cs @@ -7,7 +7,7 @@ namespace MQTTnet.Extensions { public static string GetUserProperty(this MqttApplicationMessage message, string propertyName, StringComparison comparisonType = StringComparison.OrdinalIgnoreCase) { - return message.UserProperties.SingleOrDefault(up => up.Name.Equals(propertyName, comparisonType))?.Value; + return message?.UserProperties?.SingleOrDefault(up => up.Name.Equals(propertyName, comparisonType))?.Value; } public static T GetUserProperty(this MqttApplicationMessage message, string propertyName, StringComparison comparisonType = StringComparison.OrdinalIgnoreCase)