Merge pull request #227 from DarthAffe/CodeIssues

Preparing for first major release
This commit is contained in:
DarthAffe authored and GitHub committed 2021-08-07 17:52:20 +02:00
commit 1bae7fd3de
241 files changed
+2168 -794

No files matched your search

@@ -21,6 +21,7 @@ namespace RGB.NET.Devices.Corsair
/// Initializes a new instance of the <see cref="T:RGB.NET.Devices.Corsair.CorsairCustomRGBDevice" /> class.
/// </summary>
/// <param name="info">The specific information provided by CUE for the custom-device.</param>
/// <param name="updateQueue">The queue used to update this device.</param>
internal CorsairCustomRGBDevice(CorsairCustomRGBDeviceInfo info, CorsairDeviceUpdateQueue updateQueue)
: base(info, new LedMapping<CorsairLedId>(), updateQueue)
{ }
@@ -17,8 +17,19 @@ namespace RGB.NET.Devices.Corsair
{
#region Properties & Fields
/// <summary>
/// Gets the corsair-id of the first LED of this device.
/// </summary>
public CorsairLedId ReferenceCorsairLed { get; }
/// <summary>
/// Gets the amount of LEDs this device contains.
/// </summary>
public int LedCount { get; }
/// <summary>
/// Gets the offset used to access the LEDs of this device.
/// </summary>
internal int LedOffset { get; }
#endregion
@@ -33,7 +44,8 @@ namespace RGB.NET.Devices.Corsair
/// <param name="deviceIndex">The index of the <see cref="T:RGB.NET.Devices.Corsair._CorsairChannelDeviceInfo" />.</param>
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
/// <param name="channelDeviceInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairChannelDeviceInfo"/> representing this device.</param>
/// <param name="referenceCorsairLed">The id of the first led of this device.</param>
/// <param name="referenceCorsairLed">The id of the first LED of this device.</param>
/// <param name="ledOffset">The offset used to find the LEDs of this device.</param>
internal CorsairCustomRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo, _CorsairChannelDeviceInfo channelDeviceInfo, CorsairLedId referenceCorsairLed, int ledOffset)
: base(deviceIndex, GetDeviceType(channelDeviceInfo.type), nativeInfo,
GetModelName(nativeInfo.model == IntPtr.Zero ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase), channelDeviceInfo))
@@ -49,32 +61,21 @@ namespace RGB.NET.Devices.Corsair
#region Methods
private static RGBDeviceType GetDeviceType(CorsairChannelDeviceType deviceType)
{
switch (deviceType)
=> deviceType switch
{
case CorsairChannelDeviceType.Invalid:
return RGBDeviceType.Unknown;
case CorsairChannelDeviceType.FanHD:
case CorsairChannelDeviceType.FanSP:
case CorsairChannelDeviceType.FanLL:
case CorsairChannelDeviceType.FanML:
case CorsairChannelDeviceType.DAP:
case CorsairChannelDeviceType.FanQL:
case CorsairChannelDeviceType.FanSPPRO:
return RGBDeviceType.Fan;
case CorsairChannelDeviceType.Strip:
return RGBDeviceType.LedStripe;
case CorsairChannelDeviceType.Pump:
case CorsairChannelDeviceType.WaterBlock:
return RGBDeviceType.Cooler;
default:
throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null);
}
}
CorsairChannelDeviceType.Invalid => RGBDeviceType.Unknown,
CorsairChannelDeviceType.FanHD => RGBDeviceType.Fan,
CorsairChannelDeviceType.FanSP => RGBDeviceType.Fan,
CorsairChannelDeviceType.FanLL => RGBDeviceType.Fan,
CorsairChannelDeviceType.FanML => RGBDeviceType.Fan,
CorsairChannelDeviceType.DAP => RGBDeviceType.Fan,
CorsairChannelDeviceType.FanQL => RGBDeviceType.Fan,
CorsairChannelDeviceType.FanSPPRO => RGBDeviceType.Fan,
CorsairChannelDeviceType.Strip => RGBDeviceType.LedStripe,
CorsairChannelDeviceType.Pump => RGBDeviceType.Cooler,
CorsairChannelDeviceType.WaterBlock => RGBDeviceType.Cooler,
_ => throw new ArgumentOutOfRangeException(nameof(deviceType), deviceType, null)
};
private static string GetModelName(string model, _CorsairChannelDeviceInfo channelDeviceInfo)
{
@@ -126,7 +127,9 @@ namespace RGB.NET.Devices.Corsair
return "Pump";
default:
throw new ArgumentOutOfRangeException(nameof(channelDeviceInfo.type), channelDeviceInfo.type, null);
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
throw new ArgumentOutOfRangeException($"{nameof(channelDeviceInfo)}.{nameof(channelDeviceInfo.type)}", channelDeviceInfo.type, null);
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
}
}