diff --git a/iothub/device/src/DeviceClient.cs b/iothub/device/src/DeviceClient.cs
index d6179291ce..94084b2523 100644
--- a/iothub/device/src/DeviceClient.cs
+++ b/iothub/device/src/DeviceClient.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@@ -16,6 +17,9 @@ namespace Microsoft.Azure.Devices.Client
///
///
public class DeviceClient : IDisposable
+#if !NET451 && !NET472 && !NETSTANDARD2_0
+ , IAsyncDisposable
+#endif
{
///
/// Default operation timeout.
@@ -613,12 +617,50 @@ public void SetConnectionStatusChangesHandler(ConnectionStatusChangesHandler sta
///
/// Releases the unmanaged resources used by the DeviceClient and optionally disposes of the managed resources.
///
+ ///
+ /// The method should be called before disposing.
+ ///
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
+#if !NET451 && !NET472 && !NETSTANDARD2_0
+ // IAsyncDisposable is available in .NET Standard 2.1 and above
+
+ ///
+ /// Disposes the client in an async way. See for more information.
+ ///
+ ///
+ /// Includes a call to .
+ ///
+ ///
+ ///
+ /// await using var client = DeviceClient.CreateFromConnectionString(...);
+ ///
+ /// or
+ ///
+ /// var client = DeviceClient.CreateFromConnectionStirng(...);
+ /// try
+ /// {
+ /// // do work
+ /// }
+ /// finally
+ /// {
+ /// await client.DisposeAsync();
+ /// }
+ ///
+ ///
+ [SuppressMessage("Usage", "CA1816:Dispose methods should call SuppressFinalize", Justification = "SuppressFinalize is called by Dispose(), which this method calls.")]
+ public async ValueTask DisposeAsync()
+ {
+ await CloseAsync().ConfigureAwait(false);
+ Dispose();
+ }
+
+#endif
+
///
/// Releases the unmanaged resources used by the DeviceClient and allows for any derived class to override and
/// provide custom implementation.
diff --git a/iothub/device/src/ModuleClient.cs b/iothub/device/src/ModuleClient.cs
index 8970dd1f0d..abd3f5aa09 100644
--- a/iothub/device/src/ModuleClient.cs
+++ b/iothub/device/src/ModuleClient.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Net;
using System.Net.Http;
@@ -22,6 +23,9 @@ namespace Microsoft.Azure.Devices.Client
/// Contains methods that a module can use to send messages to and receive from the service and interact with module twins.
///
public class ModuleClient : IDisposable
+#if !NET451 && !NET472 && !NETSTANDARD2_0
+ , IAsyncDisposable
+#endif
{
private const string ModuleMethodUriFormat = "/twins/{0}/modules/{1}/methods?" + ClientApiVersionHelper.ApiVersionQueryStringLatest;
private const string DeviceMethodUriFormat = "/twins/{0}/methods?" + ClientApiVersionHelper.ApiVersionQueryStringLatest;
@@ -439,6 +443,41 @@ public void Dispose()
GC.SuppressFinalize(this);
}
+#if !NET451 && !NET472 && !NETSTANDARD2_0
+ // IAsyncDisposable is available in .NET Standard 2.1 and above
+
+ ///
+ /// Disposes the client in an async way. See for more information.
+ ///
+ ///
+ /// Includes a call to .
+ ///
+ ///
+ ///
+ /// await using var client = ModuleClient.CreateFromConnectionString(...);
+ ///
+ /// or
+ ///
+ /// var client = ModuleClient.CreateFromConnectionStirng(...);
+ /// try
+ /// {
+ /// // do work
+ /// }
+ /// finally
+ /// {
+ /// await client.DisposeAsync();
+ /// }
+ ///
+ ///
+ [SuppressMessage("Usage", "CA1816:Dispose methods should call SuppressFinalize", Justification = "SuppressFinalize is called by Dispose(), which this method calls.")]
+ public async ValueTask DisposeAsync()
+ {
+ await CloseAsync().ConfigureAwait(false);
+ Dispose();
+ }
+
+#endif
+
///
/// Releases the unmanaged resources used by the ModuleClient and allows for any derived class to override and
/// provide custom implementation.
diff --git a/iothub/service/src/Common/Security/SharedAccessSignature.cs b/iothub/service/src/Common/Security/SharedAccessSignature.cs
index 42d0b20fc4..f776572790 100644
--- a/iothub/service/src/Common/Security/SharedAccessSignature.cs
+++ b/iothub/service/src/Common/Security/SharedAccessSignature.cs
@@ -7,7 +7,6 @@
using System.Net;
using System.Security.Cryptography;
using System.Text;
-using Microsoft.Azure.Devices.Common.Data;
namespace Microsoft.Azure.Devices.Common.Security
{
@@ -73,7 +72,7 @@ private SharedAccessSignature(
public string Signature { get; private set; }
///
- /// Parses a shared access signature string representation into a ./>
+ /// Parses a shared access signature string representation into a .
///
/// The IoT Hub name.
/// The string representation of the SAS token to parse.