mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 10:08:31 +00:00
Fixed some code issues (dispose finalizers)
This commit is contained in:
parent
180b0e4538
commit
d6aed5c5a2
@ -22,11 +22,7 @@ public sealed class DefaultColorBehavior : IColorBehavior
|
|||||||
/// <param name="color">The color to test.</param>
|
/// <param name="color">The color to test.</param>
|
||||||
/// <param name="obj">The object to test.</param>
|
/// <param name="obj">The object to test.</param>
|
||||||
/// <returns><c>true</c> if <paramref name="obj" /> is a <see cref="Color" /> equivalent to this <see cref="Color" />; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if <paramref name="obj" /> is a <see cref="Color" /> equivalent to this <see cref="Color" />; otherwise, <c>false</c>.</returns>
|
||||||
public bool Equals(in Color color, object? obj)
|
public bool Equals(in Color color, object? obj) => obj is Color color2 && Equals(color, color2);
|
||||||
{
|
|
||||||
if (obj is not Color color2) return false;
|
|
||||||
return Equals(color, color2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests whether the specified object is a <see cref="Color" /> and is equivalent to this <see cref="Color" />.
|
/// Tests whether the specified object is a <see cref="Color" /> and is equivalent to this <see cref="Color" />.
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
// ReSharper disable UnusedMember.Global
|
// ReSharper disable UnusedMember.Global
|
||||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -160,6 +161,8 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
|
|||||||
try { LedMapping.Clear(); } catch { /* this really shouldn't happen */ }
|
try { LedMapping.Clear(); } catch { /* this really shouldn't happen */ }
|
||||||
|
|
||||||
IdGenerator.ResetCounter(GetType().Assembly);
|
IdGenerator.ResetCounter(GetType().Assembly);
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
// ReSharper disable MemberCanBePrivate.Global
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -178,7 +179,12 @@ public class DeviceUpdateTrigger : AbstractUpdateTrigger, IDeviceUpdateTrigger
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Dispose() => Stop();
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -100,6 +100,8 @@ public class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
|
|
||||||
try { _CoolerMasterSDK.Reload(); }
|
try { _CoolerMasterSDK.Reload(); }
|
||||||
catch { /* Unlucky.. */ }
|
catch { /* Unlucky.. */ }
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -33,6 +33,8 @@ public abstract class CoolerMasterRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDe
|
|||||||
_CoolerMasterSDK.EnableLedControl(false, DeviceInfo.DeviceIndex);
|
_CoolerMasterSDK.EnableLedControl(false, DeviceInfo.DeviceIndex);
|
||||||
|
|
||||||
base.Dispose();
|
base.Dispose();
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -71,6 +71,8 @@ public class DebugDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
base.Dispose();
|
base.Dispose();
|
||||||
|
|
||||||
_fakeDeviceDefinitions.Clear();
|
_fakeDeviceDefinitions.Clear();
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -104,6 +104,8 @@ public class MsiDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
|
|
||||||
try { _MsiSDK.UnloadMsiSDK(); }
|
try { _MsiSDK.UnloadMsiSDK(); }
|
||||||
catch { /* at least we tried */ }
|
catch { /* at least we tried */ }
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -53,6 +53,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
<Content Include="..\Resources\icon.png" Link="icon.png" Pack="true" PackagePath="\" />
|
||||||
|
<None Include="..\.editorconfig" Link=".editorconfig" />
|
||||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@ -49,6 +49,8 @@ public abstract class NovationRGBDevice<TDeviceInfo> : AbstractRGBDevice<TDevice
|
|||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
base.Dispose();
|
base.Dispose();
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -35,7 +35,7 @@ public class OpenRGBDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
public bool ForceAddAllDevices { get; set; } = false;
|
public bool ForceAddAllDevices { get; set; } = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines which device types will be separated by zones. Defaults to <see cref="RGBDeviceType.LedStripe" /> | <see cref="RGBDeviceType.Mainboard" | <see cref="RGBDeviceType.Speaker" />.
|
/// Defines which device types will be separated by zones. Defaults to <see cref="RGBDeviceType.LedStripe" /> | <see cref="RGBDeviceType.Mainboard"/> | <see cref="RGBDeviceType.Speaker" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RGBDeviceType PerZoneDeviceFlag { get; } = RGBDeviceType.LedStripe | RGBDeviceType.Mainboard | RGBDeviceType.Speaker;
|
public RGBDeviceType PerZoneDeviceFlag { get; } = RGBDeviceType.LedStripe | RGBDeviceType.Mainboard | RGBDeviceType.Speaker;
|
||||||
|
|
||||||
@ -141,6 +141,8 @@ public class OpenRGBDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
_clients.Clear();
|
_clients.Clear();
|
||||||
DeviceDefinitions.Clear();
|
DeviceDefinitions.Clear();
|
||||||
Devices = Enumerable.Empty<IRGBDevice>();
|
Devices = Enumerable.Empty<IRGBDevice>();
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
// DarthAffe 03.03.2020: Fails with an access-violation - verify if an unload is already triggered by uninit
|
||||||
//try { _RazerSDK.UnloadRazerSDK(); }
|
//try { _RazerSDK.UnloadRazerSDK(); }
|
||||||
//catch { /* at least we tried */ }
|
//catch { /* at least we tried */ }
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -137,6 +137,8 @@ public class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
|
|
||||||
try { SteelSeriesSDK.Dispose(); }
|
try { SteelSeriesSDK.Dispose(); }
|
||||||
catch { /* shit happens */ }
|
catch { /* shit happens */ }
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.IO.Ports;
|
using System;
|
||||||
|
using System.IO.Ports;
|
||||||
|
|
||||||
namespace RGB.NET.Devices.WS281X;
|
namespace RGB.NET.Devices.WS281X;
|
||||||
|
|
||||||
@ -61,7 +62,12 @@ public class SerialPortConnection : ISerialConnection
|
|||||||
public void WriteLine(string line) => SerialPort.WriteLine(line);
|
public void WriteLine(string line) => SerialPort.WriteLine(line);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Dispose() => SerialPort.Dispose();
|
public void Dispose()
|
||||||
|
{
|
||||||
|
SerialPort.Dispose();
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -171,6 +171,8 @@ public class NodeMCUWS2812USBUpdateQueue : UpdateQueue
|
|||||||
ResetDevice();
|
ResetDevice();
|
||||||
_httpClient.Dispose();
|
_httpClient.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetUrl(string path) => $"http://{_hostname}/{path}";
|
private string GetUrl(string path) => $"http://{_hostname}/{path}";
|
||||||
|
|||||||
@ -75,6 +75,8 @@ public class WS281XDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
base.Dispose();
|
base.Dispose();
|
||||||
|
|
||||||
DeviceDefinitions.Clear();
|
DeviceDefinitions.Clear();
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
using RGB.NET.Devices.Wooting.Generic;
|
using RGB.NET.Devices.Wooting.Generic;
|
||||||
using RGB.NET.Devices.Wooting.Native;
|
using RGB.NET.Devices.Wooting.Native;
|
||||||
@ -55,6 +56,8 @@ public class WootingKeyboardRGBDevice : WootingRGBDevice<WootingKeyboardRGBDevic
|
|||||||
_WootingSDK.Reset();
|
_WootingSDK.Reset();
|
||||||
|
|
||||||
base.Dispose();
|
base.Dispose();
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -102,6 +102,8 @@ public class WootingDeviceProvider : AbstractRGBDeviceProvider
|
|||||||
try { _WootingSDK.UnloadWootingSDK(); }
|
try { _WootingSDK.UnloadWootingSDK(); }
|
||||||
catch { /* at least we tried */ }
|
catch { /* at least we tried */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user