1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 10:08:31 +00:00

Merge pull request #313 from DarthAffe/Test/PerformanceOptimization

Test/performance optimization
This commit is contained in:
DarthAffe 2023-04-19 22:08:45 +02:00 committed by GitHub
commit 25fef22218
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
194 changed files with 412 additions and 545 deletions

View File

@ -3,9 +3,11 @@
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global // ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
using System; using System;
using System.Buffers;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
namespace RGB.NET.Core; namespace RGB.NET.Core;
@ -100,12 +102,7 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
DeviceUpdate(); DeviceUpdate();
// Send LEDs to SDK // Send LEDs to SDK
List<Led> ledsToUpdate = GetLedsToUpdate(flushLeds).ToList(); UpdateLeds(GetLedsToUpdate(flushLeds));
foreach (Led led in ledsToUpdate)
led.Update();
UpdateLeds(ledsToUpdate);
} }
/// <summary> /// <summary>
@ -124,37 +121,39 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
/// </remarks> /// </remarks>
/// <param name="leds">The enumerable of leds to convert.</param> /// <param name="leds">The enumerable of leds to convert.</param>
/// <returns>The enumerable of custom data and color tuples for the specified leds.</returns> /// <returns>The enumerable of custom data and color tuples for the specified leds.</returns>
protected virtual IEnumerable<(object key, Color color)> GetUpdateData(IEnumerable<Led> leds) [MethodImpl(MethodImplOptions.AggressiveInlining)]
{ protected (object key, Color color) GetUpdateData(Led led)
if (ColorCorrections.Count > 0)
{
foreach (Led led in leds)
{ {
Color color = led.Color; Color color = led.Color;
object key = led.CustomData ?? led.Id; object key = led.CustomData ?? led.Id;
foreach (IColorCorrection colorCorrection in ColorCorrections) // ReSharper disable once ForCanBeConvertedToForeach - This causes an allocation that's not really needed here
colorCorrection.ApplyTo(ref color); for (int i = 0; i < ColorCorrections.Count; i++)
ColorCorrections[i].ApplyTo(ref color);
yield return (key, color); return (key, color);
}
}
else
{
foreach (Led led in leds)
{
Color color = led.Color;
object key = led.CustomData ?? led.Id;
yield return (key, color);
}
}
} }
/// <summary> /// <summary>
/// Sends all the updated <see cref="Led"/> to the device. /// Sends all the updated <see cref="Led"/> to the device.
/// </summary> /// </summary>
protected virtual void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate)); protected virtual void UpdateLeds(IEnumerable<Led> ledsToUpdate)
{
(object key, Color color)[] buffer = ArrayPool<(object, Color)>.Shared.Rent(LedMapping.Count);
int counter = 0;
foreach (Led led in ledsToUpdate)
{
led.Update();
buffer[counter] = GetUpdateData(led);
++counter;
}
UpdateQueue.SetData(new ReadOnlySpan<(object, Color)>(buffer)[..counter]);
ArrayPool<(object, Color)>.Shared.Return(buffer);
}
/// <inheritdoc /> /// <inheritdoc />
public virtual void Dispose() public virtual void Dispose()

View File

@ -1,4 +1,5 @@
using System.Collections; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -61,5 +62,14 @@ public abstract class AbstractLedGroup : AbstractDecoratable<ILedGroupDecorator>
/// <inheritdoc /> /// <inheritdoc />
public IEnumerator<Led> GetEnumerator() => GetLeds().GetEnumerator(); public IEnumerator<Led> GetEnumerator() => GetLeds().GetEnumerator();
/// <inheritdoc />
IDisposable? ILedGroup.ToListUnsafe(out IList<Led> leds) => ToListUnsafe(out leds);
protected virtual IDisposable? ToListUnsafe(out IList<Led> leds)
{
leds = ToList();
return null;
}
#endregion #endregion
} }

View File

@ -1,6 +1,7 @@
// ReSharper disable UnusedMemberInSuper.Global // ReSharper disable UnusedMemberInSuper.Global
// ReSharper disable UnusedMember.Global // ReSharper disable UnusedMember.Global
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace RGB.NET.Core; namespace RGB.NET.Core;
@ -45,4 +46,6 @@ public interface ILedGroup : IDecoratable<ILedGroupDecorator>, IEnumerable<Led>
/// </summary> /// </summary>
/// <returns>A list containing all <see cref="Led"/> in this group.</returns> /// <returns>A list containing all <see cref="Led"/> in this group.</returns>
IList<Led> ToList(); IList<Led> ToList();
internal IDisposable? ToListUnsafe(out IList<Led> leds);
} }

View File

@ -1,7 +1,9 @@
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global // ReSharper disable UnusedMember.Global
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
namespace RGB.NET.Core; namespace RGB.NET.Core;
@ -9,14 +11,16 @@ namespace RGB.NET.Core;
/// <summary> /// <summary>
/// Represents a ledgroup containing arbitrary <see cref="T:RGB.NET.Core.Led" />. /// Represents a ledgroup containing arbitrary <see cref="T:RGB.NET.Core.Led" />.
/// </summary> /// </summary>
public class ListLedGroup : AbstractLedGroup public sealed class ListLedGroup : AbstractLedGroup
{ {
#region Properties & Fields #region Properties & Fields
private readonly ActionDisposable _unlockDisposable;
/// <summary> /// <summary>
/// Gets the list containing the <see cref="Led"/> of this <see cref="ListLedGroup"/>. /// Gets the list containing the <see cref="Led"/> of this <see cref="ListLedGroup"/>.
/// </summary> /// </summary>
protected IList<Led> GroupLeds { get; } = new List<Led>(); private readonly IList<Led> _groupLeds = new List<Led>();
#endregion #endregion
@ -29,7 +33,9 @@ public class ListLedGroup : AbstractLedGroup
/// <param name="surface">Specifies the surface to attach this group to or <c>null</c> if the group should not be attached on creation.</param> /// <param name="surface">Specifies the surface to attach this group to or <c>null</c> if the group should not be attached on creation.</param>
public ListLedGroup(RGBSurface? surface) public ListLedGroup(RGBSurface? surface)
: base(surface) : base(surface)
{ } {
_unlockDisposable = new ActionDisposable(Unlock);
}
/// <inheritdoc /> /// <inheritdoc />
/// <summary> /// <summary>
@ -40,6 +46,8 @@ public class ListLedGroup : AbstractLedGroup
public ListLedGroup(RGBSurface? surface, IEnumerable<Led> leds) public ListLedGroup(RGBSurface? surface, IEnumerable<Led> leds)
: base(surface) : base(surface)
{ {
_unlockDisposable = new ActionDisposable(Unlock);
AddLeds(leds); AddLeds(leds);
} }
@ -52,6 +60,8 @@ public class ListLedGroup : AbstractLedGroup
public ListLedGroup(RGBSurface? surface, params Led[] leds) public ListLedGroup(RGBSurface? surface, params Led[] leds)
: base(surface) : base(surface)
{ {
_unlockDisposable = new ActionDisposable(Unlock);
AddLeds(leds); AddLeds(leds);
} }
@ -71,10 +81,10 @@ public class ListLedGroup : AbstractLedGroup
/// <param name="leds">The <see cref="Led"/> to add.</param> /// <param name="leds">The <see cref="Led"/> to add.</param>
public void AddLeds(IEnumerable<Led> leds) public void AddLeds(IEnumerable<Led> leds)
{ {
lock (GroupLeds) lock (_groupLeds)
foreach (Led led in leds) foreach (Led led in leds)
if (!ContainsLed(led)) if (!ContainsLed(led))
GroupLeds.Add(led); _groupLeds.Add(led);
} }
/// <summary> /// <summary>
@ -89,9 +99,9 @@ public class ListLedGroup : AbstractLedGroup
/// <param name="leds">The <see cref="Led"/> to remove.</param> /// <param name="leds">The <see cref="Led"/> to remove.</param>
public void RemoveLeds(IEnumerable<Led> leds) public void RemoveLeds(IEnumerable<Led> leds)
{ {
lock (GroupLeds) lock (_groupLeds)
foreach (Led led in leds) foreach (Led led in leds)
GroupLeds.Remove(led); _groupLeds.Remove(led);
} }
/// <summary> /// <summary>
@ -101,8 +111,8 @@ public class ListLedGroup : AbstractLedGroup
/// <returns><c>true</c> if the LED is contained by this ledgroup; otherwise, <c>false</c>.</returns> /// <returns><c>true</c> if the LED is contained by this ledgroup; otherwise, <c>false</c>.</returns>
public bool ContainsLed(Led led) public bool ContainsLed(Led led)
{ {
lock (GroupLeds) lock (_groupLeds)
return GroupLeds.Contains(led); return _groupLeds.Contains(led);
} }
/// <summary> /// <summary>
@ -111,10 +121,10 @@ public class ListLedGroup : AbstractLedGroup
/// <param name="groupToMerge">The ledgroup to merge.</param> /// <param name="groupToMerge">The ledgroup to merge.</param>
public void MergeLeds(ILedGroup groupToMerge) public void MergeLeds(ILedGroup groupToMerge)
{ {
lock (GroupLeds) lock (_groupLeds)
foreach (Led led in groupToMerge) foreach (Led led in groupToMerge)
if (!GroupLeds.Contains(led)) if (!_groupLeds.Contains(led))
GroupLeds.Add(led); _groupLeds.Add(led);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -131,9 +141,18 @@ public class ListLedGroup : AbstractLedGroup
/// <returns>The list containing the <see cref="T:RGB.NET.Core.Led" />.</returns> /// <returns>The list containing the <see cref="T:RGB.NET.Core.Led" />.</returns>
public override IList<Led> ToList() public override IList<Led> ToList()
{ {
lock (GroupLeds) lock (_groupLeds)
return new List<Led>(GroupLeds); return new List<Led>(_groupLeds);
} }
protected override IDisposable ToListUnsafe(out IList<Led> leds)
{
Monitor.Enter(_groupLeds);
leds = _groupLeds;
return _unlockDisposable;
}
private void Unlock() => Monitor.Exit(_groupLeds);
#endregion #endregion
} }

View File

@ -50,8 +50,7 @@ public static class IdGenerator
idMapping.Add(id, mappedId); idMapping.Add(id, mappedId);
} }
if (!counterMapping.ContainsKey(mappedId)) counterMapping.TryAdd(mappedId, 0);
counterMapping.Add(mappedId, 0);
int counter = ++counterMapping[mappedId]; int counter = ++counterMapping[mappedId];
return counter <= 1 ? mappedId : $"{mappedId} ({counter})"; return counter <= 1 ? mappedId : $"{mappedId} ({counter})";

View File

@ -9,7 +9,7 @@ namespace RGB.NET.Core;
/// Represents a single LED of a RGB-device. /// Represents a single LED of a RGB-device.
/// </summary> /// </summary>
[DebuggerDisplay("{Id} {Color}")] [DebuggerDisplay("{Id} {Color}")]
public class Led : Placeable public sealed class Led : Placeable
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -8,7 +8,7 @@ namespace RGB.NET.Core;
/// Represents a mapping from <see cref="LedId"/> to a custom identifier. /// Represents a mapping from <see cref="LedId"/> to a custom identifier.
/// </summary> /// </summary>
/// <typeparam name="T">The identifier the <see cref="LedId"/> is mapped to.</typeparam> /// <typeparam name="T">The identifier the <see cref="LedId"/> is mapped to.</typeparam>
public class LedMapping<T> : IEnumerable<(LedId ledId, T mapping)> public sealed class LedMapping<T> : IEnumerable<(LedId ledId, T mapping)>
where T : notnull where T : notnull
{ {
#region Constants #region Constants

View File

@ -6,5 +6,4 @@ namespace RGB.NET.Core;
/// Represents a basic bindable class which notifies when a property value changes. /// Represents a basic bindable class which notifies when a property value changes.
/// </summary> /// </summary>
public interface IBindable : INotifyPropertyChanged public interface IBindable : INotifyPropertyChanged
{ { }
}

View File

@ -26,7 +26,6 @@ public abstract class AbstractReferenceCounting : IReferenceCounting
public void AddReferencingObject(object obj) public void AddReferencingObject(object obj)
{ {
lock (_referencingObjects) lock (_referencingObjects)
if (!_referencingObjects.Contains(obj))
_referencingObjects.Add(obj); _referencingObjects.Add(obj);
} }

View File

@ -0,0 +1,27 @@
using System;
namespace RGB.NET.Core;
public sealed class ActionDisposable : IDisposable
{
#region Properties & Fields
private readonly Action _onDispose;
#endregion
#region Constructors
public ActionDisposable(Action onDispose)
{
this._onDispose = onDispose;
}
#endregion
#region Methods
public void Dispose() => _onDispose();
#endregion
}

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0;net6.0;net5.0</TargetFrameworks> <TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -41,7 +41,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> <PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants> <DefineConstants>TRACE;DEBUG</DefineConstants>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize> <Optimize>false</Optimize>
</PropertyGroup> </PropertyGroup>
@ -49,7 +49,7 @@
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> <PropertyGroup Condition="'$(Configuration)' == 'Release'">
<Optimize>true</Optimize> <Optimize>true</Optimize>
<NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn> <NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn>
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants> <DefineConstants>RELEASE</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -208,8 +208,8 @@ public sealed class RGBSurface : AbstractBindable, IDisposable
if ((brush == null) || !brush.IsEnabled) return; if ((brush == null) || !brush.IsEnabled) return;
IList<Led> leds = ledGroup.ToList(); using (ledGroup.ToListUnsafe(out IList<Led> leds))
{
IEnumerable<(RenderTarget renderTarget, Color color)> render; IEnumerable<(RenderTarget renderTarget, Color color)> render;
switch (brush.CalculationMode) switch (brush.CalculationMode)
{ {
@ -229,6 +229,7 @@ public sealed class RGBSurface : AbstractBindable, IDisposable
foreach ((RenderTarget renderTarget, Color c) in render) foreach ((RenderTarget renderTarget, Color c) in render)
renderTarget.Led.Color = c; renderTarget.Led.Color = c;
} }
}
/// <summary> /// <summary>
/// Attaches the specified <see cref="ILedGroup"/>. /// Attaches the specified <see cref="ILedGroup"/>.

View File

@ -7,7 +7,7 @@ namespace RGB.NET.Core;
/// <summary> /// <summary>
/// Represents a brush drawing only a single color. /// Represents a brush drawing only a single color.
/// </summary> /// </summary>
public class SolidColorBrush : AbstractBrush public sealed class SolidColorBrush : AbstractBrush
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -4,7 +4,7 @@
/// <summary> /// <summary>
/// Represents a brush drawing a texture. /// Represents a brush drawing a texture.
/// </summary> /// </summary>
public class TextureBrush : AbstractBrush public sealed class TextureBrush : AbstractBrush
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -1,6 +1,6 @@
namespace RGB.NET.Core; namespace RGB.NET.Core;
internal class EmptyTexture : ITexture internal sealed class EmptyTexture : ITexture
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -48,7 +48,7 @@ public interface ICustomUpdateData
/// <summary> /// <summary>
/// Represents a set of custom data, each indexed by a string-key. /// Represents a set of custom data, each indexed by a string-key.
/// </summary> /// </summary>
public class CustomUpdateData : ICustomUpdateData public sealed class CustomUpdateData : ICustomUpdateData
{ {
#region Properties & Fields #region Properties & Fields
@ -92,7 +92,7 @@ public class CustomUpdateData : ICustomUpdateData
#endregion #endregion
} }
internal class DefaultCustomUpdateData : ICustomUpdateData internal sealed class DefaultCustomUpdateData : ICustomUpdateData
{ {
#region Constants #region Constants
@ -120,7 +120,7 @@ internal class DefaultCustomUpdateData : ICustomUpdateData
#region Constructors #region Constructors
public DefaultCustomUpdateData(bool flushLeds) private DefaultCustomUpdateData(bool flushLeds)
{ {
this._flushLeds = flushLeds; this._flushLeds = flushLeds;
} }

View File

@ -157,11 +157,13 @@ public class DeviceUpdateTrigger : AbstractUpdateTrigger, IDeviceUpdateTrigger
using (TimerHelper.RequestHighResolutionTimer()) using (TimerHelper.RequestHighResolutionTimer())
while (!UpdateToken.IsCancellationRequested) while (!UpdateToken.IsCancellationRequested)
if (HasDataEvent.WaitOne(Timeout)) if (HasDataEvent.WaitOne(Timeout))
LastUpdateTime = TimerHelper.Execute(() => OnUpdate(), UpdateFrequency * 1000); LastUpdateTime = TimerHelper.Execute(TimerExecute, UpdateFrequency * 1000);
else if ((HeartbeatTimer > 0) && (LastUpdateTimestamp > 0) && (TimerHelper.GetElapsedTime(LastUpdateTimestamp) > HeartbeatTimer)) else if ((HeartbeatTimer > 0) && (LastUpdateTimestamp > 0) && (TimerHelper.GetElapsedTime(LastUpdateTimestamp) > HeartbeatTimer))
OnUpdate(new CustomUpdateData().Heartbeat()); OnUpdate(new CustomUpdateData().Heartbeat());
} }
private void TimerExecute() => OnUpdate();
protected override void OnUpdate(CustomUpdateData? updateData = null) protected override void OnUpdate(CustomUpdateData? updateData = null)
{ {
base.OnUpdate(updateData); base.OnUpdate(updateData);

View File

@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
namespace RGB.NET.Core; namespace RGB.NET.Core;
@ -21,7 +20,7 @@ public interface IUpdateQueue<TIdentifier, TData> : IReferenceCounting, IDisposa
/// </summary> /// </summary>
/// <param name="dataSet">The set of data.</param> /// <param name="dataSet">The set of data.</param>
// ReSharper disable once MemberCanBeProtected.Global // ReSharper disable once MemberCanBeProtected.Global
void SetData(IEnumerable<(TIdentifier, TData)> dataSet); void SetData(ReadOnlySpan<(TIdentifier, TData)> dataSet);
/// <summary> /// <summary>
/// Resets the current data set. /// Resets the current data set.

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Buffers; using System.Buffers;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace RGB.NET.Core; namespace RGB.NET.Core;
@ -88,10 +87,9 @@ public abstract class UpdateQueue<TIdentifier, TData> : AbstractReferenceCountin
/// </summary> /// </summary>
/// <param name="dataSet">The set of data.</param> /// <param name="dataSet">The set of data.</param>
// ReSharper disable once MemberCanBeProtected.Global // ReSharper disable once MemberCanBeProtected.Global
public virtual void SetData(IEnumerable<(TIdentifier, TData)> dataSet) public virtual void SetData(ReadOnlySpan<(TIdentifier, TData)> data)
{ {
IList<(TIdentifier, TData)> data = dataSet.ToList(); if (data.Length == 0) return;
if (data.Count == 0) return;
lock (_dataLock) lock (_dataLock)
{ {

View File

@ -83,12 +83,12 @@ public sealed class ManualUpdateTrigger : AbstractUpdateTrigger
OnStartup(); OnStartup();
while (!UpdateToken.IsCancellationRequested) while (!UpdateToken.IsCancellationRequested)
{
if (_mutex.WaitOne(100)) if (_mutex.WaitOne(100))
LastUpdateTime = TimerHelper.Execute(() => OnUpdate(_customUpdateData)); LastUpdateTime = TimerHelper.Execute(TimerExecute);
}
} }
private void TimerExecute() => OnUpdate(_customUpdateData);
/// <inheritdoc /> /// <inheritdoc />
public override void Dispose() => Stop(); public override void Dispose() => Stop();

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Core;
/// <summary> /// <summary>
/// Represents an update trigger that triggers in a set interval. /// Represents an update trigger that triggers in a set interval.
/// </summary> /// </summary>
public class TimerUpdateTrigger : AbstractUpdateTrigger public sealed class TimerUpdateTrigger : AbstractUpdateTrigger
{ {
#region Properties & Fields #region Properties & Fields
@ -21,17 +21,17 @@ public class TimerUpdateTrigger : AbstractUpdateTrigger
/// <summary> /// <summary>
/// Gets or sets the update loop of this trigger. /// Gets or sets the update loop of this trigger.
/// </summary> /// </summary>
protected Task? UpdateTask { get; set; } private Task? _updateTask;
/// <summary> /// <summary>
/// Gets or sets the cancellation token source used to create the cancellation token checked by the <see cref="UpdateTask"/>. /// Gets or sets the cancellation token source used to create the cancellation token checked by the <see cref="_updateTask"/>.
/// </summary> /// </summary>
protected CancellationTokenSource? UpdateTokenSource { get; set; } private CancellationTokenSource? _updateTokenSource;
/// <summary> /// <summary>
/// Gets or sets the cancellation token checked by the <see cref="UpdateTask"/>. /// Gets or sets the cancellation token checked by the <see cref="_updateTask"/>.
/// </summary> /// </summary>
protected CancellationToken UpdateToken { get; set; } private CancellationToken _updateToken;
private double _updateFrequency = 1.0 / 30.0; private double _updateFrequency = 1.0 / 30.0;
/// <summary> /// <summary>
@ -88,11 +88,11 @@ public class TimerUpdateTrigger : AbstractUpdateTrigger
{ {
lock (_lock) lock (_lock)
{ {
if (UpdateTask == null) if (_updateTask == null)
{ {
UpdateTokenSource?.Dispose(); _updateTokenSource?.Dispose();
UpdateTokenSource = new CancellationTokenSource(); _updateTokenSource = new CancellationTokenSource();
UpdateTask = Task.Factory.StartNew(UpdateLoop, (UpdateToken = UpdateTokenSource.Token), TaskCreationOptions.LongRunning, TaskScheduler.Default); _updateTask = Task.Factory.StartNew(UpdateLoop, (_updateToken = _updateTokenSource.Token), TaskCreationOptions.LongRunning, TaskScheduler.Default);
} }
} }
} }
@ -104,13 +104,13 @@ public class TimerUpdateTrigger : AbstractUpdateTrigger
{ {
lock (_lock) lock (_lock)
{ {
if (UpdateTask != null) if (_updateTask != null)
{ {
UpdateTokenSource?.Cancel(); _updateTokenSource?.Cancel();
try try
{ {
// ReSharper disable once MethodSupportsCancellation // ReSharper disable once MethodSupportsCancellation
UpdateTask.Wait(); _updateTask.Wait();
} }
catch (AggregateException) catch (AggregateException)
{ {
@ -118,8 +118,8 @@ public class TimerUpdateTrigger : AbstractUpdateTrigger
} }
finally finally
{ {
UpdateTask.Dispose(); _updateTask.Dispose();
UpdateTask = null; _updateTask = null;
} }
} }
} }
@ -130,16 +130,16 @@ public class TimerUpdateTrigger : AbstractUpdateTrigger
OnStartup(); OnStartup();
using (TimerHelper.RequestHighResolutionTimer()) using (TimerHelper.RequestHighResolutionTimer())
while (!UpdateToken.IsCancellationRequested) while (!_updateToken.IsCancellationRequested)
LastUpdateTime = TimerHelper.Execute(() => OnUpdate(_customUpdateData), UpdateFrequency * 1000); LastUpdateTime = TimerHelper.Execute(TimerExecute, UpdateFrequency * 1000);
} }
private void TimerExecute() => OnUpdate(_customUpdateData);
/// <inheritdoc /> /// <inheritdoc />
public override void Dispose() public override void Dispose()
{ {
Stop(); Stop();
GC.SuppressFinalize(this);
} }
#endregion #endregion

View File

@ -12,7 +12,7 @@ namespace RGB.NET.Devices.Asus;
/// <summary> /// <summary>
/// Represents a device provider responsible for Cooler Master devices. /// Represents a device provider responsible for Cooler Master devices.
/// </summary> /// </summary>
public class AsusDeviceProvider : AbstractRGBDeviceProvider public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider
{ {
#region Properties & Fields #region Properties & Fields
@ -88,8 +88,6 @@ public class AsusDeviceProvider : AbstractRGBDeviceProvider
_devices = null; _devices = null;
_sdk = null; _sdk = null;
GC.SuppressFinalize(this);
} }
#endregion #endregion

View File

@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Asus;
/// <summary> /// <summary>
/// Represents a Asus headset. /// Represents a Asus headset.
/// </summary> /// </summary>
public class AsusUnspecifiedRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IUnknownDevice public sealed class AsusUnspecifiedRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IUnknownDevice
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -8,7 +8,7 @@ namespace RGB.NET.Devices.Asus;
/// <summary> /// <summary>
/// Represents the update-queue performing updates for asus devices. /// Represents the update-queue performing updates for asus devices.
/// </summary> /// </summary>
public class AsusUpdateQueue : UpdateQueue public sealed class AsusUpdateQueue : UpdateQueue
{ {
#region Properties & Fields #region Properties & Fields
@ -17,7 +17,7 @@ public class AsusUpdateQueue : UpdateQueue
/// <summary> /// <summary>
/// The device to be updated. /// The device to be updated.
/// </summary> /// </summary>
protected IAuraSyncDevice Device { get; } private readonly IAuraSyncDevice _device;
#endregion #endregion
@ -31,7 +31,7 @@ public class AsusUpdateQueue : UpdateQueue
public AsusUpdateQueue(IDeviceUpdateTrigger updateTrigger, IAuraSyncDevice device) public AsusUpdateQueue(IDeviceUpdateTrigger updateTrigger, IAuraSyncDevice device)
: base(updateTrigger) : base(updateTrigger)
{ {
this.Device = device; this._device = device;
this._lights = new IAuraRgbLight[device.Lights.Count]; this._lights = new IAuraRgbLight[device.Lights.Count];
for (int i = 0; i < device.Lights.Count; i++) for (int i = 0; i < device.Lights.Count; i++)
@ -47,9 +47,9 @@ public class AsusUpdateQueue : UpdateQueue
{ {
try try
{ {
if ((Device.Type == (uint)AsusDeviceType.KEYBOARD_RGB) || (Device.Type == (uint)AsusDeviceType.NB_KB_RGB)) if ((_device.Type == (uint)AsusDeviceType.KEYBOARD_RGB) || (_device.Type == (uint)AsusDeviceType.NB_KB_RGB))
{ {
if (Device is not IAuraSyncKeyboard keyboard) if (_device is not IAuraSyncKeyboard keyboard)
return true; return true;
foreach ((object customData, Color value) in dataSet) foreach ((object customData, Color value) in dataSet)
@ -87,7 +87,7 @@ public class AsusUpdateQueue : UpdateQueue
} }
} }
Device.Apply(); _device.Apply();
return true; return true;
} }

View File

@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Asus;
/// <summary> /// <summary>
/// Represents a Asus graphicsCard. /// Represents a Asus graphicsCard.
/// </summary> /// </summary>
public class AsusGraphicsCardRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IGraphicsCard public sealed class AsusGraphicsCardRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IGraphicsCard
{ {
#region Constructors #region Constructors

View File

@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Asus;
/// <summary> /// <summary>
/// Represents a Asus headset. /// Represents a Asus headset.
/// </summary> /// </summary>
public class AsusHeadsetRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IHeadset public sealed class AsusHeadsetRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IHeadset
{ {
#region Constructors #region Constructors

View File

@ -43,7 +43,7 @@ internal static class WMIHelper
if ((_systemModelInfo == null) && (_systemModelSearcher != null)) if ((_systemModelInfo == null) && (_systemModelSearcher != null))
foreach (ManagementBaseObject managementBaseObject in _systemModelSearcher.Get()) foreach (ManagementBaseObject managementBaseObject in _systemModelSearcher.Get())
{ {
_systemModelInfo = managementBaseObject["Model"]?.ToString(); _systemModelInfo = managementBaseObject["Model"].ToString();
break; break;
} }
@ -57,7 +57,7 @@ internal static class WMIHelper
if (!_mainboardInfo.HasValue && (_mainboardSearcher != null)) if (!_mainboardInfo.HasValue && (_mainboardSearcher != null))
foreach (ManagementBaseObject managementBaseObject in _mainboardSearcher.Get()) foreach (ManagementBaseObject managementBaseObject in _mainboardSearcher.Get())
{ {
_mainboardInfo = (managementBaseObject["Manufacturer"]?.ToString() ?? string.Empty, managementBaseObject["Product"]?.ToString() ?? string.Empty); _mainboardInfo = (managementBaseObject["Manufacturer"].ToString() ?? string.Empty, managementBaseObject["Product"].ToString() ?? string.Empty);
break; break;
} }
@ -71,7 +71,7 @@ internal static class WMIHelper
if ((_graphicsCardInfo == null) && (_graphicsCardSearcher != null)) if ((_graphicsCardInfo == null) && (_graphicsCardSearcher != null))
foreach (ManagementBaseObject managementBaseObject in _graphicsCardSearcher.Get()) foreach (ManagementBaseObject managementBaseObject in _graphicsCardSearcher.Get())
{ {
_graphicsCardInfo = managementBaseObject["Name"]?.ToString(); _graphicsCardInfo = managementBaseObject["Name"].ToString();
break; break;
} }

View File

@ -20,7 +20,7 @@ public record AsusKeyboardExtraMapping(Regex Regex, LedMapping<int> LedMapping);
/// <summary> /// <summary>
/// Represents a Asus keyboard. /// Represents a Asus keyboard.
/// </summary> /// </summary>
public class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceInfo>, IKeyboard public sealed class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceInfo>, IKeyboard
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Asus;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Asus.AsusKeyboardRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.Asus.AsusKeyboardRGBDevice" />.
/// </summary> /// </summary>
public class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDeviceInfo public sealed class AsusKeyboardRGBDeviceInfo : AsusRGBDeviceInfo, IKeyboardDeviceInfo
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Asus;
/// <summary> /// <summary>
/// Represents a Asus mainboard. /// Represents a Asus mainboard.
/// </summary> /// </summary>
public class AsusMainboardRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IMainboard public sealed class AsusMainboardRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IMainboard
{ {
#region Constructors #region Constructors

View File

@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Asus;
/// <summary> /// <summary>
/// Represents a Asus mouse. /// Represents a Asus mouse.
/// </summary> /// </summary>
public class AsusMouseRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IMouse public sealed class AsusMouseRGBDevice : AsusRGBDevice<AsusRGBDeviceInfo>, IMouse
{ {
#region Constructors #region Constructors

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0;net6.0;net5.0</TargetFrameworks> <TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -40,7 +40,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> <PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants> <DefineConstants>TRACE;DEBUG</DefineConstants>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize> <Optimize>false</Optimize>
</PropertyGroup> </PropertyGroup>
@ -48,7 +48,7 @@
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> <PropertyGroup Condition="'$(Configuration)' == 'Release'">
<Optimize>true</Optimize> <Optimize>true</Optimize>
<NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn> <NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn>
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants> <DefineConstants>RELEASE</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -57,21 +57,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="System.Management" Version="5.0.0" /> <PackageReference Include="System.Management" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<_PackageFiles Include="$(OutputPath)\net6.0\Interop.AuraServiceLib.dll">
<BuildAction>None</BuildAction>
<PackagePath>lib\net6.0\</PackagePath>
</_PackageFiles>
</ItemGroup>
<ItemGroup>
<_PackageFiles Include="$(OutputPath)\net5.0\Interop.AuraServiceLib.dll">
<BuildAction>None</BuildAction>
<PackagePath>lib\net5.0\</PackagePath>
</_PackageFiles>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -8,7 +8,7 @@ namespace RGB.NET.Devices.CoolerMaster;
/// Specifies the <see cref="T:RGB.NET.Core.RGBDeviceType" /> of a field. /// Specifies the <see cref="T:RGB.NET.Core.RGBDeviceType" /> of a field.
/// </summary> /// </summary>
[AttributeUsage(AttributeTargets.Field)] [AttributeUsage(AttributeTargets.Field)]
public class DeviceTypeAttribute : Attribute public sealed class DeviceTypeAttribute : Attribute
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -13,7 +13,7 @@ namespace RGB.NET.Devices.CoolerMaster;
/// <summary> /// <summary>
/// Represents a device provider responsible for Cooler Master devices. /// Represents a device provider responsible for Cooler Master devices.
/// </summary> /// </summary>
public class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider
{ {
#region Properties & Fields #region Properties & Fields
@ -100,8 +100,6 @@ public class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider
try { _CoolerMasterSDK.Reload(); } try { _CoolerMasterSDK.Reload(); }
catch { /* Unlucky.. */ } catch { /* Unlucky.. */ }
GC.SuppressFinalize(this);
} }
#endregion #endregion

View File

@ -4,8 +4,6 @@
using System.ComponentModel; using System.ComponentModel;
using RGB.NET.Core; using RGB.NET.Core;
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace RGB.NET.Devices.CoolerMaster; namespace RGB.NET.Devices.CoolerMaster;
/// <summary> /// <summary>

View File

@ -1,40 +0,0 @@
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
#pragma warning disable 1591 // Missing XML comment for publicly visible type or member
namespace RGB.NET.Devices.CoolerMaster;
/// <summary>
/// Contains a list of available effects.
/// </summary>
public enum CoolerMasterEffects
{
FullOn = 0,
Breath = 1,
BreathCycle = 2,
Single = 3,
Wave = 4,
Ripple = 5,
Cross = 6,
Rain = 7,
Star = 8,
Snake = 9,
Rec = 10,
Spectrum = 11,
RapidFire = 12,
Indicator = 13, //mouse Effect
FireBall = 14,
WaterRipple = 15,
ReactivePunch = 16,
Snowing = 17,
HeartBeat = 18,
ReactiveTornade = 19,
Multi1 = 0xE0,
Multi2 = 0xE1,
Multi3 = 0xE2,
Multi4 = 0xE3,
Off = 0xFE
}

View File

@ -8,7 +8,7 @@ namespace RGB.NET.Devices.CoolerMaster;
/// <summary> /// <summary>
/// Represents the update-queue performing updates for cooler master devices. /// Represents the update-queue performing updates for cooler master devices.
/// </summary> /// </summary>
public class CoolerMasterUpdateQueue : UpdateQueue public sealed class CoolerMasterUpdateQueue : UpdateQueue
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -7,7 +7,7 @@ namespace RGB.NET.Devices.CoolerMaster;
/// <summary> /// <summary>
/// Represents a CoolerMaster keyboard. /// Represents a CoolerMaster keyboard.
/// </summary> /// </summary>
public class CoolerMasterKeyboardRGBDevice : CoolerMasterRGBDevice<CoolerMasterKeyboardRGBDeviceInfo>, IKeyboard public sealed class CoolerMasterKeyboardRGBDevice : CoolerMasterRGBDevice<CoolerMasterKeyboardRGBDeviceInfo>, IKeyboard
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -5,7 +5,7 @@ namespace RGB.NET.Devices.CoolerMaster;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.CoolerMaster.CoolerMasterKeyboardRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.CoolerMaster.CoolerMasterKeyboardRGBDevice" />.
/// </summary> /// </summary>
public class CoolerMasterKeyboardRGBDeviceInfo : CoolerMasterRGBDeviceInfo, IKeyboardDeviceInfo public sealed class CoolerMasterKeyboardRGBDeviceInfo : CoolerMasterRGBDeviceInfo, IKeyboardDeviceInfo
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -7,7 +7,7 @@ namespace RGB.NET.Devices.CoolerMaster;
/// <summary> /// <summary>
/// Represents a CoolerMaster mouse. /// Represents a CoolerMaster mouse.
/// </summary> /// </summary>
public class CoolerMasterMouseRGBDevice : CoolerMasterRGBDevice<CoolerMasterMouseRGBDeviceInfo>, IMouse public sealed class CoolerMasterMouseRGBDevice : CoolerMasterRGBDevice<CoolerMasterMouseRGBDeviceInfo>, IMouse
{ {
#region Constructors #region Constructors

View File

@ -6,7 +6,7 @@ namespace RGB.NET.Devices.CoolerMaster;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.CoolerMaster.CoolerMasterMouseRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.CoolerMaster.CoolerMasterMouseRGBDevice" />.
/// </summary> /// </summary>
public class CoolerMasterMouseRGBDeviceInfo : CoolerMasterRGBDeviceInfo public sealed class CoolerMasterMouseRGBDeviceInfo : CoolerMasterRGBDeviceInfo
{ {
#region Constructors #region Constructors

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0;net6.0;net5.0</TargetFrameworks> <TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -40,7 +40,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> <PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants> <DefineConstants>TRACE;DEBUG</DefineConstants>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize> <Optimize>false</Optimize>
</PropertyGroup> </PropertyGroup>
@ -48,7 +48,7 @@
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> <PropertyGroup Condition="'$(Configuration)' == 'Release'">
<Optimize>true</Optimize> <Optimize>true</Optimize>
<NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn> <NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn>
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants> <DefineConstants>RELEASE</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a corsair cooler. /// Represents a corsair cooler.
/// </summary> /// </summary>
public class CorsairCoolerRGBDevice : CorsairRGBDevice<CorsairCoolerRGBDeviceInfo>, ICooler public sealed class CorsairCoolerRGBDevice : CorsairRGBDevice<CorsairCoolerRGBDeviceInfo>, ICooler
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairCoolerRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairCoolerRGBDevice" />.
/// </summary> /// </summary>
public class CorsairCoolerRGBDeviceInfo : CorsairRGBDeviceInfo public sealed class CorsairCoolerRGBDeviceInfo : CorsairRGBDeviceInfo
{ {
#region Constructors #region Constructors

View File

@ -13,7 +13,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a device provider responsible for corsair (CUE) devices. /// Represents a device provider responsible for corsair (CUE) devices.
/// </summary> /// </summary>
public class CorsairDeviceProvider : AbstractRGBDeviceProvider public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider
{ {
#region Properties & Fields #region Properties & Fields
@ -306,8 +306,6 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider
try { _CUESDK.CorsairDisconnect(); } catch { /* at least we tried */ } try { _CUESDK.CorsairDisconnect(); } catch { /* at least we tried */ }
try { _CUESDK.UnloadCUESDK(); } catch { /* at least we tried */ } try { _CUESDK.UnloadCUESDK(); } catch { /* at least we tried */ }
GC.SuppressFinalize(this);
} }
#endregion #endregion

View File

@ -1,4 +1,6 @@
namespace RGB.NET.Devices.Corsair; // ReSharper disable InconsistentNaming
namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// iCUE-SDK: contains a list of led groups. Led group is used as a part of led identifier /// iCUE-SDK: contains a list of led groups. Led group is used as a part of led identifier

View File

@ -9,7 +9,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents an exception thrown by the CUE. /// Represents an exception thrown by the CUE.
/// </summary> /// </summary>
public class CUEException : ApplicationException public sealed class CUEException : ApplicationException
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a corsair fan. /// Represents a corsair fan.
/// </summary> /// </summary>
public class CorsairFanRGBDevice : CorsairRGBDevice<CorsairFanRGBDeviceInfo>, IFan public sealed class CorsairFanRGBDevice : CorsairRGBDevice<CorsairFanRGBDeviceInfo>, IFan
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairFanRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairFanRGBDevice" />.
/// </summary> /// </summary>
public class CorsairFanRGBDeviceInfo : CorsairRGBDeviceInfo public sealed class CorsairFanRGBDeviceInfo : CorsairRGBDeviceInfo
{ {
#region Constructors #region Constructors

View File

@ -9,7 +9,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents the update-queue performing updates for corsair devices. /// Represents the update-queue performing updates for corsair devices.
/// </summary> /// </summary>
public class CorsairDeviceUpdateQueue : UpdateQueue public sealed class CorsairDeviceUpdateQueue : UpdateQueue
{ {
#region Properties & Fields #region Properties & Fields
@ -76,8 +76,6 @@ public class CorsairDeviceUpdateQueue : UpdateQueue
_isDisposed = true; _isDisposed = true;
Marshal.FreeHGlobal(_colorPtr); Marshal.FreeHGlobal(_colorPtr);
GC.SuppressFinalize(this);
} }
#endregion #endregion

View File

@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents version information for the Corsair-SDK /// Represents version information for the Corsair-SDK
/// </summary> /// </summary>
public class CorsairSessionDetails public sealed class CorsairSessionDetails
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -11,6 +11,7 @@ internal static class LedMappings
{ {
#region Constants #region Constants
// ReSharper disable once InconsistentNaming
private static LedMapping<CorsairLedId> KEYBOARD_MAPPING => new() private static LedMapping<CorsairLedId> KEYBOARD_MAPPING => new()
{ {
{ LedId.Invalid, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Invalid) }, { LedId.Invalid, new CorsairLedId(CorsairLedGroup.Keyboard, CorsairLedIdKeyboard.Invalid) },

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a corsair graphics card. /// Represents a corsair graphics card.
/// </summary> /// </summary>
public class CorsairGraphicsCardRGBDevice : CorsairRGBDevice<CorsairGraphicsCardRGBDeviceInfo>, IGraphicsCard public sealed class CorsairGraphicsCardRGBDevice : CorsairRGBDevice<CorsairGraphicsCardRGBDeviceInfo>, IGraphicsCard
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairGraphicsCardRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairGraphicsCardRGBDevice" />.
/// </summary> /// </summary>
public class CorsairGraphicsCardRGBDeviceInfo : CorsairRGBDeviceInfo public sealed class CorsairGraphicsCardRGBDeviceInfo : CorsairRGBDeviceInfo
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a corsair headset. /// Represents a corsair headset.
/// </summary> /// </summary>
public class CorsairHeadsetRGBDevice : CorsairRGBDevice<CorsairHeadsetRGBDeviceInfo>, IHeadset public sealed class CorsairHeadsetRGBDevice : CorsairRGBDevice<CorsairHeadsetRGBDeviceInfo>, IHeadset
{ {
#region Constructors #region Constructors

View File

@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetRGBDevice" />.
/// </summary> /// </summary>
public class CorsairHeadsetRGBDeviceInfo : CorsairRGBDeviceInfo public sealed class CorsairHeadsetRGBDeviceInfo : CorsairRGBDeviceInfo
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a corsair headset stand. /// Represents a corsair headset stand.
/// </summary> /// </summary>
public class CorsairHeadsetStandRGBDevice : CorsairRGBDevice<CorsairHeadsetStandRGBDeviceInfo>, IHeadsetStand public sealed class CorsairHeadsetStandRGBDevice : CorsairRGBDevice<CorsairHeadsetStandRGBDeviceInfo>, IHeadsetStand
{ {
#region Constructors #region Constructors

View File

@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetStandRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairHeadsetStandRGBDevice" />.
/// </summary> /// </summary>
public class CorsairHeadsetStandRGBDeviceInfo : CorsairRGBDeviceInfo public sealed class CorsairHeadsetStandRGBDeviceInfo : CorsairRGBDeviceInfo
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a corsair keyboard. /// Represents a corsair keyboard.
/// </summary> /// </summary>
public class CorsairKeyboardRGBDevice : CorsairRGBDevice<CorsairKeyboardRGBDeviceInfo>, IKeyboard public sealed class CorsairKeyboardRGBDevice : CorsairRGBDevice<CorsairKeyboardRGBDeviceInfo>, IKeyboard
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -9,7 +9,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairKeyboardRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairKeyboardRGBDevice" />.
/// </summary> /// </summary>
public class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo, IKeyboardDeviceInfo public sealed class CorsairKeyboardRGBDeviceInfo : CorsairRGBDeviceInfo, IKeyboardDeviceInfo
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a corsair ledStrip. /// Represents a corsair ledStrip.
/// </summary> /// </summary>
public class CorsairLedStripRGBDevice : CorsairRGBDevice<CorsairLedStripRGBDeviceInfo>, ILedStripe public sealed class CorsairLedStripRGBDevice : CorsairRGBDevice<CorsairLedStripRGBDeviceInfo>, ILedStripe
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairLedStripRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairLedStripRGBDevice" />.
/// </summary> /// </summary>
public class CorsairLedStripRGBDeviceInfo : CorsairRGBDeviceInfo public sealed class CorsairLedStripRGBDeviceInfo : CorsairRGBDeviceInfo
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a corsair memory. /// Represents a corsair memory.
/// </summary> /// </summary>
public class CorsairMainboardRGBDevice : CorsairRGBDevice<CorsairMainboardRGBDeviceInfo>, IMainboard public sealed class CorsairMainboardRGBDevice : CorsairRGBDevice<CorsairMainboardRGBDeviceInfo>, IMainboard
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMainboardRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMainboardRGBDevice" />.
/// </summary> /// </summary>
public class CorsairMainboardRGBDeviceInfo : CorsairRGBDeviceInfo public sealed class CorsairMainboardRGBDeviceInfo : CorsairRGBDeviceInfo
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a corsair memory. /// Represents a corsair memory.
/// </summary> /// </summary>
public class CorsairMemoryRGBDevice : CorsairRGBDevice<CorsairMemoryRGBDeviceInfo>, IDRAM public sealed class CorsairMemoryRGBDevice : CorsairRGBDevice<CorsairMemoryRGBDeviceInfo>, IDRAM
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMemoryRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMemoryRGBDevice" />.
/// </summary> /// </summary>
public class CorsairMemoryRGBDeviceInfo : CorsairRGBDeviceInfo public sealed class CorsairMemoryRGBDeviceInfo : CorsairRGBDeviceInfo
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a corsair mouse. /// Represents a corsair mouse.
/// </summary> /// </summary>
public class CorsairMouseRGBDevice : CorsairRGBDevice<CorsairMouseRGBDeviceInfo>, IMouse public sealed class CorsairMouseRGBDevice : CorsairRGBDevice<CorsairMouseRGBDeviceInfo>, IMouse
{ {
#region Constructors #region Constructors

View File

@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMouseRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMouseRGBDevice" />.
/// </summary> /// </summary>
public class CorsairMouseRGBDeviceInfo : CorsairRGBDeviceInfo public sealed class CorsairMouseRGBDeviceInfo : CorsairRGBDeviceInfo
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a corsair mousepad. /// Represents a corsair mousepad.
/// </summary> /// </summary>
public class CorsairMousepadRGBDevice : CorsairRGBDevice<CorsairMousepadRGBDeviceInfo>, IMousepad public sealed class CorsairMousepadRGBDevice : CorsairRGBDevice<CorsairMousepadRGBDeviceInfo>, IMousepad
{ {
#region Constructors #region Constructors

View File

@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMousepadRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairMousepadRGBDevice" />.
/// </summary> /// </summary>
public class CorsairMousepadRGBDeviceInfo : CorsairRGBDeviceInfo public sealed class CorsairMousepadRGBDeviceInfo : CorsairRGBDeviceInfo
{ {
#region Constructors #region Constructors

View File

@ -91,11 +91,7 @@ internal static unsafe class _CUESDK
if (dllPath == null) throw new RGBDeviceException($"Can't find the CUE-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'"); if (dllPath == null) throw new RGBDeviceException($"Can't find the CUE-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'");
if (!NativeLibrary.TryLoad(dllPath, out _handle)) if (!NativeLibrary.TryLoad(dllPath, out _handle))
#if NET6_0_OR_GREATER
throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}"); throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastPInvokeError()}");
#else
throw new RGBDeviceException($"Corsair LoadLibrary failed with error code {Marshal.GetLastWin32Error()}");
#endif
_corsairConnectPtr = (delegate* unmanaged[Cdecl]<CorsairSessionStateChangedHandler, nint, CorsairError>)LoadFunction("CorsairConnect"); _corsairConnectPtr = (delegate* unmanaged[Cdecl]<CorsairSessionStateChangedHandler, nint, CorsairError>)LoadFunction("CorsairConnect");
_corsairGetSessionDetails = (delegate* unmanaged[Cdecl]<nint, CorsairError>)LoadFunction("CorsairGetSessionDetails"); _corsairGetSessionDetails = (delegate* unmanaged[Cdecl]<nint, CorsairError>)LoadFunction("CorsairGetSessionDetails");

View File

@ -12,7 +12,7 @@ namespace RGB.NET.Devices.Corsair.Native;
/// iCUE-SDK: contains device search filter /// iCUE-SDK: contains device search filter
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal class _CorsairDeviceFilter internal sealed class _CorsairDeviceFilter
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -12,7 +12,7 @@ namespace RGB.NET.Devices.Corsair.Native;
/// iCUE-SDK: contains information about device /// iCUE-SDK: contains information about device
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal class _CorsairDeviceInfo internal sealed class _CorsairDeviceInfo
{ {
/// <summary> /// <summary>
/// iCUE-SDK: enum describing device type /// iCUE-SDK: enum describing device type

View File

@ -13,7 +13,7 @@ namespace RGB.NET.Devices.Corsair.Native;
/// iCUE-SDK: contains led id and position of led /// iCUE-SDK: contains led id and position of led
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal class _CorsairLedPosition internal sealed class _CorsairLedPosition
{ {
/// <summary> /// <summary>
/// iCUE-SDK: unique identifier of led /// iCUE-SDK: unique identifier of led

View File

@ -13,7 +13,7 @@ namespace RGB.NET.Devices.Corsair.Native;
/// iCUE-SDK: contains information about SDK and iCUE versions /// iCUE-SDK: contains information about SDK and iCUE versions
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal class _CorsairSessionDetails internal sealed class _CorsairSessionDetails
{ {
/// <summary> /// <summary>
/// iCUE-SDK: version of SDK client (like {4,0,1}). Always contains valid value even if there was no iCUE found. Must comply with the semantic versioning rules. /// iCUE-SDK: version of SDK client (like {4,0,1}). Always contains valid value even if there was no iCUE found. Must comply with the semantic versioning rules.

View File

@ -13,7 +13,7 @@ namespace RGB.NET.Devices.Corsair.Native;
/// iCUE-SDK: contains information about session state and client/server versions /// iCUE-SDK: contains information about session state and client/server versions
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal class _CorsairSessionStateChanged internal sealed class _CorsairSessionStateChanged
{ {
/// <summary> /// <summary>
/// iCUE-SDK: new session state which SDK client has been transitioned to /// iCUE-SDK: new session state which SDK client has been transitioned to

View File

@ -13,7 +13,7 @@ namespace RGB.NET.Devices.Corsair.Native;
/// iCUE-SDK: contains information about version that consists of three components /// iCUE-SDK: contains information about version that consists of three components
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal class _CorsairVersion internal sealed class _CorsairVersion
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0;net6.0;net5.0</TargetFrameworks> <TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -41,7 +41,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> <PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants> <DefineConstants>TRACE;DEBUG</DefineConstants>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize> <Optimize>false</Optimize>
</PropertyGroup> </PropertyGroup>
@ -49,7 +49,7 @@
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> <PropertyGroup Condition="'$(Configuration)' == 'Release'">
<Optimize>true</Optimize> <Optimize>true</Optimize>
<NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn> <NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn>
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants> <DefineConstants>RELEASE</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a corsair touchbar. /// Represents a corsair touchbar.
/// </summary> /// </summary>
public class CorsairTouchbarRGBDevice : CorsairRGBDevice<CorsairTouchbarRGBDeviceInfo>, ILedStripe public sealed class CorsairTouchbarRGBDevice : CorsairRGBDevice<CorsairTouchbarRGBDeviceInfo>, ILedStripe
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairTouchbarRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairTouchbarRGBDevice" />.
/// </summary> /// </summary>
public class CorsairTouchbarRGBDeviceInfo : CorsairRGBDeviceInfo public sealed class CorsairTouchbarRGBDeviceInfo : CorsairRGBDeviceInfo
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a unknown corsair device. /// Represents a unknown corsair device.
/// </summary> /// </summary>
public class CorsairUnknownRGBDevice : CorsairRGBDevice<CorsairUnknownRGBDeviceInfo>, IUnknownDevice public sealed class CorsairUnknownRGBDevice : CorsairRGBDevice<CorsairUnknownRGBDeviceInfo>, IUnknownDevice
{ {
#region Constructors #region Constructors

View File

@ -10,7 +10,7 @@ namespace RGB.NET.Devices.Corsair;
/// <summary> /// <summary>
/// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairUnknownRGBDevice" />. /// Represents a generic information for a <see cref="T:RGB.NET.Devices.Corsair.CorsairUnknownRGBDevice" />.
/// </summary> /// </summary>
public class CorsairUnknownRGBDeviceInfo : CorsairRGBDeviceInfo public sealed class CorsairUnknownRGBDeviceInfo : CorsairRGBDeviceInfo
{ {
#region Constructors #region Constructors

View File

@ -12,7 +12,7 @@ namespace RGB.NET.Devices.DMX;
/// <summary> /// <summary>
/// Represents a device provider responsible for DMX devices. /// Represents a device provider responsible for DMX devices.
/// </summary> /// </summary>
public class DMXDeviceProvider : AbstractRGBDeviceProvider public sealed class DMXDeviceProvider : AbstractRGBDeviceProvider
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -12,7 +12,7 @@ namespace RGB.NET.Devices.DMX.E131;
/// <summary> /// <summary>
/// Represents the data used to create a E1.31 DMX-device. /// Represents the data used to create a E1.31 DMX-device.
/// </summary> /// </summary>
public class E131DMXDeviceDefinition : IDMXDeviceDefinition public sealed class E131DMXDeviceDefinition : IDMXDeviceDefinition
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -7,7 +7,7 @@ namespace RGB.NET.Devices.DMX.E131;
/// <summary> /// <summary>
/// Represents a E1.31-DXM-device. /// Represents a E1.31-DXM-device.
/// </summary> /// </summary>
public class E131Device : AbstractRGBDevice<E131DeviceInfo>, IUnknownDevice public sealed class E131Device : AbstractRGBDevice<E131DeviceInfo>, IUnknownDevice
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -7,7 +7,7 @@ namespace RGB.NET.Devices.DMX.E131;
/// <summary> /// <summary>
/// Represents device information for a <see cref="E131Device"/> />. /// Represents device information for a <see cref="E131Device"/> />.
/// </summary> /// </summary>
public class E131DeviceInfo : IRGBDeviceInfo public sealed class E131DeviceInfo : IRGBDeviceInfo
{ {
#region Constants #region Constants

View File

@ -8,7 +8,7 @@ namespace RGB.NET.Devices.DMX.E131;
/// <summary> /// <summary>
/// Represents the update-queue performing updates for E131-DMX devices. /// Represents the update-queue performing updates for E131-DMX devices.
/// </summary> /// </summary>
public class E131UpdateQueue : UpdateQueue public sealed class E131UpdateQueue : UpdateQueue
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -5,7 +5,7 @@ using RGB.NET.Core;
namespace RGB.NET.Devices.DMX; namespace RGB.NET.Devices.DMX;
internal class LedChannelMapping : IEnumerable<(int channel, Func<Color, byte> getValue)> internal sealed class LedChannelMapping : IEnumerable<(int channel, Func<Color, byte> getValue)>
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0;net6.0;net5.0</TargetFrameworks> <TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -40,7 +40,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> <PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants> <DefineConstants>TRACE;DEBUG</DefineConstants>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize> <Optimize>false</Optimize>
</PropertyGroup> </PropertyGroup>
@ -48,7 +48,7 @@
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> <PropertyGroup Condition="'$(Configuration)' == 'Release'">
<Optimize>true</Optimize> <Optimize>true</Optimize>
<NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn> <NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn>
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants> <DefineConstants>RELEASE</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -12,7 +12,7 @@ namespace RGB.NET.Devices.Debug;
/// <summary> /// <summary>
/// Represents a device provider responsible for debug devices. /// Represents a device provider responsible for debug devices.
/// </summary> /// </summary>
public class DebugDeviceProvider : AbstractRGBDeviceProvider public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider
{ {
#region Properties & Fields #region Properties & Fields
@ -71,8 +71,6 @@ public class DebugDeviceProvider : AbstractRGBDeviceProvider
base.Dispose(); base.Dispose();
_fakeDeviceDefinitions.Clear(); _fakeDeviceDefinitions.Clear();
GC.SuppressFinalize(this);
} }
#endregion #endregion

View File

@ -3,7 +3,7 @@ using RGB.NET.Core;
namespace RGB.NET.Devices.Debug; namespace RGB.NET.Devices.Debug;
internal class DebugDeviceUpdateQueue : UpdateQueue internal sealed class DebugDeviceUpdateQueue : UpdateQueue
{ {
#region Constructors #region Constructors

View File

@ -9,7 +9,7 @@ namespace RGB.NET.Devices.Debug;
/// <summary> /// <summary>
/// Represents a debug device. /// Represents a debug device.
/// </summary> /// </summary>
public class DebugRGBDevice : AbstractRGBDevice<DebugRGBDeviceInfo>, IUnknownDevice public sealed class DebugRGBDevice : AbstractRGBDevice<DebugRGBDeviceInfo>, IUnknownDevice
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Debug;
/// <summary> /// <summary>
/// Represents device information for a <see cref="DebugRGBDevice"/> />. /// Represents device information for a <see cref="DebugRGBDevice"/> />.
/// </summary> /// </summary>
public class DebugRGBDeviceInfo : IRGBDeviceInfo public sealed class DebugRGBDeviceInfo : IRGBDeviceInfo
{ {
#region Properties & Fields #region Properties & Fields

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0;net6.0;net5.0</TargetFrameworks> <TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -40,7 +40,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> <PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants> <DefineConstants>TRACE;DEBUG</DefineConstants>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize> <Optimize>false</Optimize>
</PropertyGroup> </PropertyGroup>
@ -48,7 +48,7 @@
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> <PropertyGroup Condition="'$(Configuration)' == 'Release'">
<Optimize>true</Optimize> <Optimize>true</Optimize>
<NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn> <NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn>
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants> <DefineConstants>RELEASE</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -14,7 +14,7 @@ namespace RGB.NET.Devices.Logitech.HID;
/// </summary> /// </summary>
/// <typeparam name="TLed">The type of the identifier leds are mapped to.</typeparam> /// <typeparam name="TLed">The type of the identifier leds are mapped to.</typeparam>
/// <typeparam name="TData">The type of the custom data added to the HID-device.</typeparam> /// <typeparam name="TData">The type of the custom data added to the HID-device.</typeparam>
public class LightspeedHIDLoader<TLed, TData> : IEnumerable<HIDDeviceDefinition<TLed, TData>> public sealed class LightspeedHIDLoader<TLed, TData> : IEnumerable<HIDDeviceDefinition<TLed, TData>>
where TLed : notnull where TLed : notnull
{ {
#region Constants #region Constants

View File

@ -1,6 +1,4 @@
using System.Collections.Generic; using RGB.NET.Core;
using System.Linq;
using RGB.NET.Core;
namespace RGB.NET.Devices.Logitech; namespace RGB.NET.Devices.Logitech;
@ -8,7 +6,7 @@ namespace RGB.NET.Devices.Logitech;
/// <summary> /// <summary>
/// Represents a logitech per-device-lightable device. /// Represents a logitech per-device-lightable device.
/// </summary> /// </summary>
public class LogitechPerDeviceRGBDevice : LogitechRGBDevice<LogitechRGBDeviceInfo>, IUnknownDevice //TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated public sealed class LogitechPerDeviceRGBDevice : LogitechRGBDevice<LogitechRGBDeviceInfo>, IUnknownDevice //TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated
{ {
#region Properties & Fields #region Properties & Fields
@ -42,8 +40,5 @@ public class LogitechPerDeviceRGBDevice : LogitechRGBDevice<LogitechRGBDeviceInf
/// <inheritdoc /> /// <inheritdoc />
protected override object GetLedCustomData(LedId ledId) => _ledMapping[ledId]; protected override object GetLedCustomData(LedId ledId) => _ledMapping[ledId];
/// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate.Take(1)));
#endregion #endregion
} }

View File

@ -8,7 +8,7 @@ namespace RGB.NET.Devices.Logitech;
/// <summary> /// <summary>
/// Represents the update-queue performing updates for logitech per-device devices. /// Represents the update-queue performing updates for logitech per-device devices.
/// </summary> /// </summary>
public class LogitechPerDeviceUpdateQueue : UpdateQueue public sealed class LogitechPerDeviceUpdateQueue : UpdateQueue
{ {
#region Constructors #region Constructors

View File

@ -1,5 +1,4 @@
using System.Collections.Generic; using RGB.NET.Core;
using RGB.NET.Core;
namespace RGB.NET.Devices.Logitech; namespace RGB.NET.Devices.Logitech;
@ -7,7 +6,7 @@ namespace RGB.NET.Devices.Logitech;
/// <summary> /// <summary>
/// Represents a logitech per-key-lightable device. /// Represents a logitech per-key-lightable device.
/// </summary> /// </summary>
public class LogitechPerKeyRGBDevice : LogitechRGBDevice<LogitechRGBDeviceInfo>, IUnknownDevice //TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated public sealed class LogitechPerKeyRGBDevice : LogitechRGBDevice<LogitechRGBDeviceInfo>, IUnknownDevice //TODO DarthAffe 18.04.2020: It's know which kind of device this is, but they would need to be separated
{ {
#region Properties & Fields #region Properties & Fields
@ -34,8 +33,5 @@ public class LogitechPerKeyRGBDevice : LogitechRGBDevice<LogitechRGBDeviceInfo>,
/// <inheritdoc /> /// <inheritdoc />
protected override object GetLedCustomData(LedId ledId) => _ledMapping.TryGetValue(ledId, out LogitechLedId logitechLedId) ? logitechLedId : -1; protected override object GetLedCustomData(LedId ledId) => _ledMapping.TryGetValue(ledId, out LogitechLedId logitechLedId) ? logitechLedId : -1;
/// <inheritdoc />
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(GetUpdateData(ledsToUpdate));
#endregion #endregion
} }

View File

@ -7,7 +7,7 @@ namespace RGB.NET.Devices.Logitech;
/// <summary> /// <summary>
/// Represents the update-queue performing updates for logitech per-key devices. /// Represents the update-queue performing updates for logitech per-key devices.
/// </summary> /// </summary>
public class LogitechPerKeyUpdateQueue : UpdateQueue public sealed class LogitechPerKeyUpdateQueue : UpdateQueue
{ {
#region Constructors #region Constructors
@ -17,8 +17,7 @@ public class LogitechPerKeyUpdateQueue : UpdateQueue
/// <param name="updateTrigger">The update trigger used by this queue.</param> /// <param name="updateTrigger">The update trigger used by this queue.</param>
public LogitechPerKeyUpdateQueue(IDeviceUpdateTrigger updateTrigger) public LogitechPerKeyUpdateQueue(IDeviceUpdateTrigger updateTrigger)
: base(updateTrigger) : base(updateTrigger)
{ { }
}
#endregion #endregion

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0;net6.0;net5.0</TargetFrameworks> <TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@ -41,7 +41,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> <PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants> <DefineConstants>TRACE;DEBUG</DefineConstants>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize> <Optimize>false</Optimize>
</PropertyGroup> </PropertyGroup>
@ -49,7 +49,7 @@
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> <PropertyGroup Condition="'$(Configuration)' == 'Release'">
<Optimize>true</Optimize> <Optimize>true</Optimize>
<NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn> <NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn>
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants> <DefineConstants>RELEASE</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

Some files were not shown because too many files have changed in this diff Show More