Skip to content

Commit 79f71ba

Browse files
authored
Merge pull request #362 from DarthAffe/Core/CodeStyling
Applied some C#12 stuff
2 parents 2796acd + aeab930 commit 79f71ba

109 files changed

Lines changed: 357 additions & 448 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

RGB.NET.Core/Decorators/AbstractDecorateable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public abstract class AbstractDecoratable<T> : AbstractBindable, IDecoratable<T>
1111
{
1212
#region Properties & Fields
1313

14-
private readonly List<T> _decorators = new();
14+
private readonly List<T> _decorators = [];
1515

1616
/// <inheritdoc />
1717
public IReadOnlyList<T> Decorators { get; }

RGB.NET.Core/Decorators/AbstractDecorator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public int Order
2929
/// <summary>
3030
/// Gets a readonly-list of all <see cref="IDecoratable"/> this decorator is attached to.
3131
/// </summary>
32-
protected List<IDecoratable> DecoratedObjects { get; } = new();
32+
protected List<IDecoratable> DecoratedObjects { get; } = [];
3333

3434
#endregion
3535

@@ -46,14 +46,14 @@ public int Order
4646
/// </summary>
4747
protected virtual void Detach()
4848
{
49-
List<IDecoratable> decoratables = new(DecoratedObjects);
49+
List<IDecoratable> decoratables = [..DecoratedObjects];
5050
foreach (IDecoratable decoratable in decoratables)
5151
{
5252
IEnumerable<Type> types = decoratable.GetType().GetInterfaces().Where(t => t.IsGenericType
5353
&& (t.Name == typeof(IDecoratable<>).Name)
5454
&& t.GenericTypeArguments[0].IsInstanceOfType(this));
5555
foreach (Type decoratableType in types)
56-
decoratableType.GetMethod(nameof(IDecoratable<IDecorator>.RemoveDecorator))?.Invoke(decoratable, new object[] { this });
56+
decoratableType.GetMethod(nameof(IDecoratable<IDecorator>.RemoveDecorator))?.Invoke(decoratable, [this]);
5757
}
5858
}
5959

RGB.NET.Core/Decorators/IDecoratable.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ namespace RGB.NET.Core;
66
/// <summary>
77
/// Represents a basic decoratable.
88
/// </summary>
9-
public interface IDecoratable : INotifyPropertyChanged
10-
{ }
9+
public interface IDecoratable : INotifyPropertyChanged;
1110

1211
/// <inheritdoc />
1312
/// <summary>

RGB.NET.Core/Decorators/ILedGroupDecorator.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
/// <summary>
55
/// Represents a basic decorator decorating a <see cref="T:RGB.NET.Core.ILedGroup" />.
66
/// </summary>
7-
public interface ILedGroupDecorator : IDecorator
8-
{ }
7+
public interface ILedGroupDecorator : IDecorator;

RGB.NET.Core/Devices/AbstractRGBDevice.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
5353
/// <summary>
5454
/// Gets a dictionary containing all <see cref="Led"/> of the <see cref="IRGBDevice"/>.
5555
/// </summary>
56-
protected Dictionary<LedId, Led> LedMapping { get; } = new();
56+
protected Dictionary<LedId, Led> LedMapping { get; } = [];
5757

5858
/// <summary>
5959
/// Gets the update queue used to update this device.

RGB.NET.Core/Devices/AbstractRGBDeviceProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
2525
/// <summary>
2626
/// The list of devices managed by this device-provider.
2727
/// </summary>
28-
protected List<IRGBDevice> InternalDevices { get; } = new();
28+
protected List<IRGBDevice> InternalDevices { get; } = [];
2929

3030
/// <inheritdoc />
3131
public virtual IReadOnlyList<IRGBDevice> Devices => new ReadOnlyCollection<IRGBDevice>(InternalDevices);
@@ -34,7 +34,7 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
3434
/// Gets the dictionary containing the registered update triggers.
3535
/// Normally <see cref="UpdateTriggers"/> should be used to access them.
3636
/// </summary>
37-
protected Dictionary<int, IDeviceUpdateTrigger> UpdateTriggerMapping { get; } = new();
37+
protected Dictionary<int, IDeviceUpdateTrigger> UpdateTriggerMapping { get; } = [];
3838

3939
/// <inheritdoc />
4040
public IReadOnlyList<(int id, IDeviceUpdateTrigger trigger)> UpdateTriggers => new ReadOnlyCollection<(int id, IDeviceUpdateTrigger trigger)>(UpdateTriggerMapping.Select(x => (x.Key, x.Value)).ToList());
@@ -116,7 +116,7 @@ protected virtual IEnumerable<IRGBDevice> GetLoadedDevices(RGBDeviceType loadFil
116116
{
117117
if (_isDisposed) throw new ObjectDisposedException(GetType().FullName);
118118

119-
List<IRGBDevice> devices = new();
119+
List<IRGBDevice> devices = [];
120120
foreach (IRGBDevice device in LoadDevices())
121121
{
122122
try
@@ -189,7 +189,7 @@ protected virtual void Reset()
189189
foreach (IRGBDevice device in Devices)
190190
device.Dispose();
191191

192-
List<IRGBDevice> devices = new(InternalDevices);
192+
List<IRGBDevice> devices = [..InternalDevices];
193193
foreach (IRGBDevice device in devices)
194194
RemoveDevice(device);
195195

RGB.NET.Core/Devices/TypeInterfaces/ICooler.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
/// <summary>
44
/// Represents a cooler-device
55
/// </summary>
6-
public interface ICooler : IRGBDevice
7-
{ }
6+
public interface ICooler : IRGBDevice;

RGB.NET.Core/Devices/TypeInterfaces/IDRAM.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
/// <summary>
44
/// Represents a DRAM-device
55
/// </summary>
6-
public interface IDRAM : IRGBDevice
7-
{ }
6+
public interface IDRAM : IRGBDevice;

RGB.NET.Core/Devices/TypeInterfaces/IFan.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
/// <summary>
44
/// represents a fan-device
55
/// </summary>
6-
public interface IFan : IRGBDevice
7-
{ }
6+
public interface IFan : IRGBDevice;

RGB.NET.Core/Devices/TypeInterfaces/IGameController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
/// <summary>
44
/// Represents a gamecontroller-device
55
/// </summary>
6-
public interface IGameController: IRGBDevice
7-
{ }
6+
public interface IGameController: IRGBDevice;

0 commit comments

Comments
 (0)