Skip to content

Commit aae509b

Browse files
committed
More code issues fixed
1 parent 5633f82 commit aae509b

13 files changed

Lines changed: 26 additions & 22 deletions

File tree

RGB.NET.Core/Compatibility/Lock.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#if NET8_0
22

3+
// ReSharper disable once CheckNamespace
34
namespace RGB.NET.Core.Compatibility.Net8;
45

56
public sealed class Lock;

RGB.NET.Core/Extensions/RectangleExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ public static bool Contains(this Rectangle rect, Rectangle rect2) => (rect.Locat
154154
Point[] points =
155155
[
156156
rect.Location, // top left
157-
new Point(rect.Location.X + rect.Size.Width, rect.Location.Y), // top right
158-
new Point(rect.Location.X + rect.Size.Width, rect.Location.Y + rect.Size.Height), // bottom right
159-
new Point(rect.Location.X, rect.Location.Y + rect.Size.Height), // bottom right
157+
new(rect.Location.X + rect.Size.Width, rect.Location.Y), // top right
158+
new(rect.Location.X + rect.Size.Width, rect.Location.Y + rect.Size.Height), // bottom right
159+
new(rect.Location.X, rect.Location.Y + rect.Size.Height), // bottom right
160160
];
161161

162162
float sin = MathF.Sin(rotation.Radians);

RGB.NET.Core/Helper/ConversionHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static string ToHex(params byte[] bytes)
4040
public static byte[] HexToBytes(ReadOnlySpan<char> hexString)
4141
{
4242
if ((hexString.Length == 0) || ((hexString.Length % 2) != 0))
43-
return Array.Empty<byte>();
43+
return [];
4444

4545
byte[] buffer = new byte[hexString.Length / 2];
4646
for (int bx = 0, sx = 0; bx < buffer.Length; ++bx, ++sx)

RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public sealed class AsusKeyboardRGBDevice : AsusRGBDevice<AsusKeyboardRGBDeviceI
3737
// ReSharper disable once InconsistentNaming
3838
public static readonly List<AsusKeyboardExtraMapping> ExtraLedMappings =
3939
[
40-
new AsusKeyboardExtraMapping(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15),
41-
new AsusKeyboardExtraMapping(new Regex("(ROG Strix G513QM).*?"), LedMappings.ROGStrixG15)
40+
new(new Regex("(ROG Zephyrus Duo 15).*?"), LedMappings.ROGZephyrusDuo15),
41+
new(new Regex("(ROG Strix G513QM).*?"), LedMappings.ROGStrixG15)
4242
];
4343

4444
#endregion

RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDeviceInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal AsusKeyboardRGBDeviceInfo(IAuraSyncDevice device)
3636

3737
#region Methods
3838

39-
private static string? GetKeyboardModel(string deviceName) => GENERIC_DEVICE_NAMES.Contains(deviceName) ? "Asus Keyboard" : deviceName;
39+
private static string GetKeyboardModel(string deviceName) => GENERIC_DEVICE_NAMES.Contains(deviceName) ? "Asus Keyboard" : deviceName;
4040

4141
#endregion
4242
}

RGB.NET.Devices.Corsair/Native/_CUESDK.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private static IEnumerable<string> GetPossibleLibraryPaths()
133133
if (OperatingSystem.IsWindows())
134134
possibleLibraryPaths = Environment.Is64BitProcess ? CorsairDeviceProvider.PossibleX64NativePaths : CorsairDeviceProvider.PossibleX86NativePaths;
135135
else
136-
possibleLibraryPaths = Enumerable.Empty<string>();
136+
possibleLibraryPaths = [];
137137

138138
return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables);
139139
}

RGB.NET.Devices.Corsair_Legacy/Custom/CorsairCustomRGBDeviceInfo.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,19 @@ private static string GetModelName(string model, _CorsairChannelDeviceInfo chann
124124
// LS100 Led Strips are reported as one big strip if configured in monitor mode in iCUE, 138 LEDs for dual monitor, 84 for single
125125
if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 138))
126126
return "LS100 LED Strip (dual monitor)";
127-
else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 84))
127+
128+
if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 84))
128129
return "LS100 LED Strip (single monitor)";
130+
129131
// Any other value means an "External LED Strip" in iCUE, these are reported per-strip, 15 for short strips, 27 for long
130-
else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 15))
132+
if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 15))
131133
return "LS100 LED Strip (short)";
132-
else if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 27))
134+
135+
if ((model == "LS100 Starter Kit") && (channelDeviceInfo.deviceLedCount == 27))
133136
return "LS100 LED Strip (long)";
137+
134138
// Device model is "Commander Pro" for regular LED strips
135-
else
136-
return "LED Strip";
139+
return "LED Strip";
137140

138141
case CorsairChannelDeviceType.DAP:
139142
return "DAP Fan";

RGB.NET.Devices.Corsair_Legacy/Native/_CUESDK.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private static IEnumerable<string> GetPossibleLibraryPaths()
6464
if (OperatingSystem.IsWindows())
6565
possibleLibraryPaths = Environment.Is64BitProcess ? CorsairLegacyDeviceProvider.PossibleX64NativePaths : CorsairLegacyDeviceProvider.PossibleX86NativePaths;
6666
else
67-
possibleLibraryPaths = Enumerable.Empty<string>();
67+
possibleLibraryPaths = [];
6868

6969
return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables);
7070
}

RGB.NET.Devices.Logitech/HID/LightspeedHidLoader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private Dictionary<int, byte> GetWirelessDevices(IReadOnlyDictionary<byte, HidDe
139139
getConnectedDevices.Init(LOGITECH_RECEIVER_ADDRESS, LOGITECH_GET_REGISTER_REQUEST);
140140

141141
stream.Write(getConnectedDevices.AsSpan());
142-
stream.Read(response.AsSpan());
142+
stream.ReadExactly(response.AsSpan());
143143

144144
bool wirelessNotifications = (response.Data01 & 1) == 1;
145145
if (!wirelessNotifications)
@@ -150,7 +150,7 @@ private Dictionary<int, byte> GetWirelessDevices(IReadOnlyDictionary<byte, HidDe
150150
getConnectedDevices.Data1 = 1;
151151

152152
stream.Write(getConnectedDevices.AsSpan());
153-
stream.Read(response.AsSpan());
153+
stream.ReadExactly(response.AsSpan());
154154

155155
if (getConnectedDevices.FeatureIndex == 0x8f)
156156
{
@@ -164,7 +164,7 @@ private Dictionary<int, byte> GetWirelessDevices(IReadOnlyDictionary<byte, HidDe
164164
getConnectedDevices.FeatureCommand = 0x02;
165165

166166
stream.Write(getConnectedDevices.AsSpan());
167-
stream.Read(response.AsSpan());
167+
stream.ReadExactly(response.AsSpan());
168168
int deviceCount = response.Data01;
169169
if (deviceCount <= 0)
170170
return map;
@@ -180,7 +180,7 @@ private Dictionary<int, byte> GetWirelessDevices(IReadOnlyDictionary<byte, HidDe
180180
for (int i = 0; i < deviceCount; i++)
181181
{
182182
FapResponse devices = new();
183-
stream.Read(devices.AsSpan());
183+
stream.ReadExactly(devices.AsSpan());
184184
int wirelessPid = (devices.Data02 << 8) | devices.Data01;
185185
if (devices.DeviceIndex != 0xff)
186186
map.Add(wirelessPid, devices.DeviceIndex);

RGB.NET.Devices.Logitech/Native/_LogitechGSDK.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private static IEnumerable<string> GetPossibleLibraryPaths()
6363
if (OperatingSystem.IsWindows())
6464
possibleLibraryPaths = Environment.Is64BitProcess ? LogitechDeviceProvider.PossibleX64NativePaths : LogitechDeviceProvider.PossibleX86NativePaths;
6565
else
66-
possibleLibraryPaths = Enumerable.Empty<string>();
66+
possibleLibraryPaths = [];
6767

6868
return possibleLibraryPaths.Select(Environment.ExpandEnvironmentVariables);
6969
}

0 commit comments

Comments
 (0)