diff --git a/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs b/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs index baa3515..c1859c2 100644 --- a/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs +++ b/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs @@ -22,11 +22,7 @@ public sealed class DefaultColorBehavior : IColorBehavior /// The color to test. /// The object to test. /// true if is a equivalent to this ; otherwise, false. - public bool Equals(in Color color, object? obj) - { - if (obj is not Color color2) return false; - return Equals(color, color2); - } + public bool Equals(in Color color, object? obj) => obj is Color color2 && Equals(color, color2); /// /// Tests whether the specified object is a and is equivalent to this . diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index 1457e0a..ca6a5b2 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -2,6 +2,7 @@ // ReSharper disable UnusedMember.Global // ReSharper disable AutoPropertyCanBeMadeGetOnly.Global +using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -160,6 +161,8 @@ public abstract class AbstractRGBDevice : Placeable, IRGBDevice diff --git a/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs index 5d357b6..db22aa4 100644 --- a/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs +++ b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs @@ -1,5 +1,6 @@ // ReSharper disable MemberCanBePrivate.Global +using System; using System.Diagnostics; using System.Threading; using System.Threading.Tasks; @@ -178,7 +179,12 @@ public class DeviceUpdateTrigger : AbstractUpdateTrigger, IDeviceUpdateTrigger } /// - public override void Dispose() => Stop(); + public override void Dispose() + { + Stop(); + + GC.SuppressFinalize(this); + } #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs index 280e520..e51ed8a 100644 --- a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs +++ b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs @@ -100,6 +100,8 @@ public class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider try { _CoolerMasterSDK.Reload(); } catch { /* Unlucky.. */ } + + GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs index b44a90c..f5d2fad 100644 --- a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs @@ -33,6 +33,8 @@ public abstract class CoolerMasterRGBDevice : AbstractRGBDevice + diff --git a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs index 5480370..b64c72a 100644 --- a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs +++ b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs @@ -49,6 +49,8 @@ public abstract class NovationRGBDevice : AbstractRGBDevice - /// Defines which device types will be separated by zones. Defaults to | . + /// Defines which device types will be separated by zones. Defaults to | | . /// public RGBDeviceType PerZoneDeviceFlag { get; } = RGBDeviceType.LedStripe | RGBDeviceType.Mainboard | RGBDeviceType.Speaker; @@ -141,6 +141,8 @@ public class OpenRGBDeviceProvider : AbstractRGBDeviceProvider _clients.Clear(); DeviceDefinitions.Clear(); Devices = Enumerable.Empty(); + + GC.SuppressFinalize(this); } #endregion } diff --git a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs index 09f1a27..77c5bd2 100644 --- a/RGB.NET.Devices.Razer/RazerDeviceProvider.cs +++ b/RGB.NET.Devices.Razer/RazerDeviceProvider.cs @@ -301,6 +301,8 @@ public class RazerDeviceProvider : AbstractRGBDeviceProvider // DarthAffe 03.03.2020: Fails with an access-violation - verify if an unload is already triggered by uninit //try { _RazerSDK.UnloadRazerSDK(); } //catch { /* at least we tried */ } + + GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs b/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs index 7144da6..ee15533 100644 --- a/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs +++ b/RGB.NET.Devices.SteelSeries/SteelSeriesDeviceProvider.cs @@ -137,6 +137,8 @@ public class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider try { SteelSeriesSDK.Dispose(); } catch { /* shit happens */ } + + GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.WS281X/Generic/SerialPortConnection.cs b/RGB.NET.Devices.WS281X/Generic/SerialPortConnection.cs index 7d4ea4d..f581e3f 100644 --- a/RGB.NET.Devices.WS281X/Generic/SerialPortConnection.cs +++ b/RGB.NET.Devices.WS281X/Generic/SerialPortConnection.cs @@ -1,4 +1,5 @@ -using System.IO.Ports; +using System; +using System.IO.Ports; namespace RGB.NET.Devices.WS281X; @@ -61,7 +62,12 @@ public class SerialPortConnection : ISerialConnection public void WriteLine(string line) => SerialPort.WriteLine(line); /// - public void Dispose() => SerialPort.Dispose(); + public void Dispose() + { + SerialPort.Dispose(); + + GC.SuppressFinalize(this); + } #endregion } \ No newline at end of file diff --git a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs index 0e7a9b7..a3619e2 100644 --- a/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs +++ b/RGB.NET.Devices.WS281X/NodeMCU/NodeMCUWS2812USBUpdateQueue.cs @@ -171,6 +171,8 @@ public class NodeMCUWS2812USBUpdateQueue : UpdateQueue ResetDevice(); _httpClient.Dispose(); } + + GC.SuppressFinalize(this); } private string GetUrl(string path) => $"http://{_hostname}/{path}"; diff --git a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs index e2adc45..6a5c49d 100644 --- a/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs +++ b/RGB.NET.Devices.WS281X/WS281XDeviceProvider.cs @@ -75,6 +75,8 @@ public class WS281XDeviceProvider : AbstractRGBDeviceProvider base.Dispose(); DeviceDefinitions.Clear(); + + GC.SuppressFinalize(this); } #endregion diff --git a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs index 502927a..eb0cc75 100644 --- a/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Wooting/Keyboard/WootingKeyboardRGBDevice.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using RGB.NET.Core; using RGB.NET.Devices.Wooting.Generic; using RGB.NET.Devices.Wooting.Native; @@ -55,6 +56,8 @@ public class WootingKeyboardRGBDevice : WootingRGBDevice