Skip to content

Commit

Permalink
Make Device class sealed instead of calling GC.SuppressFinalize
Browse files Browse the repository at this point in the history
  • Loading branch information
tmittet committed Nov 17, 2023
1 parent 3018adf commit f40f0a9
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions src/HidApi.Net/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ namespace HidApi;
/// Represents a HID device.
/// </summary>
/// <remarks>Call Dispose to free all unmanaged resources.</remarks>
public class Device : IDisposable
public sealed class Device : IDisposable
{
private bool disposed;
private readonly DeviceSafeHandle handle;

/// <summary>
Expand Down Expand Up @@ -299,24 +298,6 @@ public ReadOnlySpan<byte> GetReportDescriptor(int bufSize = 4096)
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
if (!disposed)
{
if (disposing)
{
handle.Dispose();
}
disposed = true;
}
}

~Device()
{
Dispose(false);
handle.Dispose();
}
}

0 comments on commit f40f0a9

Please sign in to comment.