diff --git a/iothub/device/src/DeviceClient.cs b/iothub/device/src/DeviceClient.cs index 57e91e77a2..43966a49c6 100644 --- a/iothub/device/src/DeviceClient.cs +++ b/iothub/device/src/DeviceClient.cs @@ -15,7 +15,7 @@ namespace Microsoft.Azure.Devices.Client /// Contains methods that a device can use to send messages to and receive from the service. /// /// - public class DeviceClient : IDisposable + public sealed class DeviceClient : IDisposable { /// /// Default operation timeout. @@ -608,25 +608,7 @@ public void SetConnectionStatusChangesHandler(ConnectionStatusChangesHandler sta /// /// Releases the unmanaged resources used by the DeviceClient and optionally disposes of the managed resources. /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Releases the unmanaged resources used by the DeviceClient and allows for any derived class to override and - /// provide custom implementation. - /// - /// Setting to true will release both managed and unmanaged resources. - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - InternalClient?.Dispose(); - InternalClient = null; - } - } + public void Dispose() => InternalClient?.Dispose(); /// /// Set a callback that will be called whenever the client receives a state update diff --git a/iothub/device/src/ModuleClient.cs b/iothub/device/src/ModuleClient.cs index aee3b0a706..901a84d57e 100644 --- a/iothub/device/src/ModuleClient.cs +++ b/iothub/device/src/ModuleClient.cs @@ -21,7 +21,7 @@ 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 + public sealed class ModuleClient : IDisposable { private const string ModuleMethodUriFormat = "/twins/{0}/modules/{1}/methods?" + ClientApiVersionHelper.ApiVersionQueryStringLatest; private const string DeviceMethodUriFormat = "/twins/{0}/methods?" + ClientApiVersionHelper.ApiVersionQueryStringLatest; @@ -433,25 +433,7 @@ public void SetConnectionStatusChangesHandler(ConnectionStatusChangesHandler sta /// /// Releases the unmanaged resources used by the ModuleClient and optionally disposes of the managed resources. /// - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Releases the unmanaged resources used by the ModuleClient and allows for any derived class to override and - /// provide custom implementation. - /// - /// Setting to true will release both managed and unmanaged resources. - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - InternalClient?.Dispose(); - InternalClient = null; - } - } + public void Dispose() => InternalClient?.Dispose(); /// /// Set a callback that will be called whenever the client receives a state update