Fix IDE0028: Use collection initializers or expressions

This commit is contained in:
Haselnussbomber 2025-10-24 02:41:16 +02:00
parent d060db3ca4
commit a8b8bce628
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
89 changed files with 186 additions and 191 deletions

View file

@ -21,7 +21,7 @@ internal class AssertHandler : IDisposable
private const int HidePrintEvery = 500;
private readonly HashSet<string> ignoredAsserts = [];
private readonly Dictionary<string, uint> assertCounts = new();
private readonly Dictionary<string, uint> assertCounts = [];
// Store callback to avoid it from being GC'd
private readonly AssertCallbackDelegate callback;

View file

@ -208,7 +208,7 @@ internal class DalamudCommands : IServiceType
var chatGui = Service<ChatGui>.Get();
var configuration = Service<DalamudConfiguration>.Get();
configuration.BadWords ??= new List<string>();
configuration.BadWords ??= [];
if (configuration.BadWords.Count == 0)
{
@ -227,7 +227,7 @@ internal class DalamudCommands : IServiceType
var chatGui = Service<ChatGui>.Get();
var configuration = Service<DalamudConfiguration>.Get();
configuration.BadWords ??= new List<string>();
configuration.BadWords ??= [];
configuration.BadWords.RemoveAll(x => x == arguments);

View file

@ -74,7 +74,7 @@ internal sealed unsafe class DalamudIme : IInternalDisposableService
private readonly ImGuiSetPlatformImeDataDelegate setPlatformImeDataDelegate;
/// <summary>The candidates.</summary>
private readonly List<(string String, bool Supported)> candidateStrings = new();
private readonly List<(string String, bool Supported)> candidateStrings = [];
/// <summary>The selected imm component.</summary>
private string compositionString = string.Empty;

View file

@ -78,8 +78,8 @@ internal partial class InterfaceManager : IInternalDisposableService
private static readonly ModuleLog Log = new("INTERFACE");
private readonly ConcurrentBag<IDeferredDisposable> deferredDisposeTextures = new();
private readonly ConcurrentBag<IDisposable> deferredDisposeDisposables = new();
private readonly ConcurrentBag<IDeferredDisposable> deferredDisposeTextures = [];
private readonly ConcurrentBag<IDisposable> deferredDisposeDisposables = [];
[ServiceManager.ServiceDependency]
private readonly DalamudConfiguration dalamudConfiguration = Service<DalamudConfiguration>.Get();
@ -678,8 +678,7 @@ internal partial class InterfaceManager : IInternalDisposableService
if (configuration.SavedStyles == null ||
configuration.SavedStyles.All(x => x.Name != StyleModelV1.DalamudStandard.Name))
{
configuration.SavedStyles = new List<StyleModel>
{ StyleModelV1.DalamudStandard, StyleModelV1.DalamudClassic };
configuration.SavedStyles = [StyleModelV1.DalamudStandard, StyleModelV1.DalamudClassic];
configuration.ChosenStyle = StyleModelV1.DalamudStandard.Name;
}
else if (configuration.SavedStyles.Count == 1)

View file

@ -58,8 +58,8 @@ internal class PluginCategoryManager
private CategoryKind currentCategoryKind = CategoryKind.All;
private bool isContentDirty;
private Dictionary<PluginManifest, CategoryKind[]> mapPluginCategories = new();
private List<CategoryKind> highlightedCategoryKinds = new();
private Dictionary<PluginManifest, CategoryKind[]> mapPluginCategories = [];
private List<CategoryKind> highlightedCategoryKinds = [];
/// <summary>
/// Type of category group.
@ -513,8 +513,7 @@ internal class PluginCategoryManager
this.GroupKind = groupKind;
this.nameFunc = nameFunc;
this.Categories = new();
this.Categories.AddRange(categories);
this.Categories = [.. categories];
}
/// <summary>

View file

@ -85,7 +85,7 @@ internal sealed class ChangelogWindow : Window, IDisposable
private AutoUpdateBehavior? chosenAutoUpdateBehavior;
private Dictionary<string, int> currentFtueLevels = new();
private Dictionary<string, int> currentFtueLevels = [];
private DateTime? isEligibleSince;
private bool openedThroughEligibility;

View file

@ -42,14 +42,14 @@ internal sealed class ComponentDemoWindow : Window
this.RespectCloseHotkey = false;
this.componentDemos = new()
{
this.componentDemos =
[
("Test", ImGuiComponents.Test),
("HelpMarker", HelpMarkerDemo),
("IconButton", IconButtonDemo),
("TextWithLabel", TextWithLabelDemo),
("ColorPickerWithPalette", this.ColorPickerWithPaletteDemo),
};
];
}
/// <inheritdoc/>

View file

@ -40,7 +40,7 @@ internal class ConsoleWindow : Window, IDisposable
private readonly RollingList<LogEntry> logText;
private readonly RollingList<LogEntry> filteredLogEntries;
private readonly List<PluginFilterEntry> pluginFilters = new();
private readonly List<PluginFilterEntry> pluginFilters = [];
private readonly DalamudConfiguration configuration;

View file

@ -28,7 +28,7 @@ internal class DataShareWidget : IDataWindowWidget
{
private const ImGuiTabItemFlags NoCloseButton = (ImGuiTabItemFlags)(1 << 20);
private readonly List<(string Name, byte[]? Data)> dataView = new();
private readonly List<(string Name, byte[]? Data)> dataView = [];
private int nextTab = -1;
private IReadOnlyDictionary<string, CallGateChannel>? gates;
private List<CallGateChannel>? gatesSorted;

View file

@ -269,7 +269,7 @@ public class IconBrowserWidget : IDataWindowWidget
if (this.valueRange is not null)
return;
this.valueRange = new();
this.valueRange = [];
foreach (var (id, _) in this.iconIdsTask!.Result)
{
if (this.startRange <= id && id < this.stopRange)

View file

@ -19,7 +19,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
/// </summary>
internal class ImGuiWidget : IDataWindowWidget
{
private readonly HashSet<IActiveNotification> notifications = new();
private readonly HashSet<IActiveNotification> notifications = [];
private NotificationTemplate notificationTemplate;
/// <inheritdoc/>

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Reflection;
@ -16,9 +16,9 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
/// </summary>
internal class ServicesWidget : IDataWindowWidget
{
private readonly Dictionary<ServiceDependencyNode, Vector4> nodeRects = new();
private readonly HashSet<Type> selectedNodes = new();
private readonly HashSet<Type> tempRelatedNodes = new();
private readonly Dictionary<ServiceDependencyNode, Vector4> nodeRects = [];
private readonly HashSet<Type> selectedNodes = [];
private readonly HashSet<Type> tempRelatedNodes = [];
private bool includeUnloadDependencies;
private List<List<ServiceDependencyNode>>? dependencyNodes;
@ -280,9 +280,9 @@ internal class ServicesWidget : IDataWindowWidget
private class ServiceDependencyNode
{
private readonly List<ServiceDependencyNode> parents = new();
private readonly List<ServiceDependencyNode> children = new();
private readonly List<ServiceDependencyNode> invalidParents = new();
private readonly List<ServiceDependencyNode> parents = [];
private readonly List<ServiceDependencyNode> children = [];
private readonly List<ServiceDependencyNode> invalidParents = [];
private ServiceDependencyNode(Type t)
{
@ -370,7 +370,7 @@ internal class ServicesWidget : IDataWindowWidget
foreach (var n in CreateTree(includeUnloadDependencies))
{
while (res.Count <= n.Level)
res.Add(new());
res.Add([]);
res[n.Level].Add(n);
}

View file

@ -43,7 +43,7 @@ internal class TexWidget : IDataWindowWidget
[DrawBlameTableColumnUserId.NativeAddress] = static x => x.ResourceAddress,
};
private readonly List<TextureEntry> addedTextures = new();
private readonly List<TextureEntry> addedTextures = [];
private string allLoadedTexturesTableName = "##table";
private string iconId = "18";

View file

@ -51,8 +51,8 @@ internal class PluginImageCache : IInternalDisposableService
[ServiceManager.ServiceDependency]
private readonly HappyHttpClient happyHttpClient = Service<HappyHttpClient>.Get();
private readonly BlockingCollection<Tuple<ulong, Func<Task>>> downloadQueue = new();
private readonly BlockingCollection<Func<Task>> loadQueue = new();
private readonly BlockingCollection<Tuple<ulong, Func<Task>>> downloadQueue = [];
private readonly BlockingCollection<Func<Task>> loadQueue = [];
private readonly CancellationTokenSource cancelToken = new();
private readonly Task downloadTask;
private readonly Task loadTask;

View file

@ -49,7 +49,7 @@ internal class PluginInstallerWindow : Window, IDisposable
private readonly PluginImageCache imageCache;
private readonly PluginCategoryManager categoryManager = new();
private readonly List<int> openPluginCollapsibles = new();
private readonly List<int> openPluginCollapsibles = [];
private readonly DateTime timeLoaded;
@ -113,9 +113,9 @@ internal class PluginInstallerWindow : Window, IDisposable
private List<PluginUpdateStatus>? updatedPlugins;
[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements should appear in the correct order", Justification = "Makes sense like this")]
private List<RemotePluginManifest> pluginListAvailable = new();
private List<LocalPlugin> pluginListInstalled = new();
private List<AvailablePluginUpdate> pluginListUpdatable = new();
private List<RemotePluginManifest> pluginListAvailable = [];
private List<LocalPlugin> pluginListInstalled = [];
private List<AvailablePluginUpdate> pluginListUpdatable = [];
private bool hasDevPlugins = false;
private bool hasHiddenPlugins = false;

View file

@ -19,7 +19,7 @@ public class ProfilerWindow : Window
{
private double min;
private double max;
private List<List<Tuple<double, double>>> occupied = new();
private List<List<Tuple<double, double>>> occupied = [];
/// <summary>
/// Initializes a new instance of the <see cref="ProfilerWindow"/> class.
@ -109,7 +109,7 @@ public class ProfilerWindow : Window
}
if (depth == this.occupied.Count)
this.occupied.Add(new());
this.occupied.Add([]);
this.occupied[depth].Add(Tuple.Create(timingHandle.StartTime, timingHandle.EndTime));
parentDepthDict[timingHandle.Id] = depth;

View file

@ -25,7 +25,7 @@ internal class SelfTestWindow : Window
private readonly SelfTestRegistry selfTestRegistry;
private List<SelfTestWithResults> visibleSteps = new();
private List<SelfTestWithResults> visibleSteps = [];
private bool selfTestRunning = false;
private SelfTestGroup? currentTestGroup = null;
@ -138,7 +138,7 @@ internal class SelfTestWindow : Window
ImGui.SameLine();
var stepNumber = this.currentStep != null ? this.visibleSteps.IndexOf(this.currentStep) : 0;
ImGui.Text($"Step: {stepNumber} / {this.visibleSteps.Count}");
ImGui.Text($"Step: {stepNumber} / {this.visibleSteps.Count}");
ImGui.Spacing();

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.Addon.Lifecycle;
@ -23,15 +23,15 @@ internal class AddonLifecycleSelfTestStep : ISelfTestStep
/// </summary>
public AddonLifecycleSelfTestStep()
{
this.listeners = new List<AddonLifecycleEventListener>
{
this.listeners =
[
new(AddonEvent.PostSetup, "Character", this.PostSetup),
new(AddonEvent.PostUpdate, "Character", this.PostUpdate),
new(AddonEvent.PostDraw, "Character", this.PostDraw),
new(AddonEvent.PostRefresh, "Character", this.PostRefresh),
new(AddonEvent.PostRequestedUpdate, "Character", this.PostRequestedUpdate),
new(AddonEvent.PreFinalize, "Character", this.PreFinalize),
};
];
}
private enum TestStep

View file

@ -36,7 +36,7 @@ internal class NamePlateSelfTestStep : ISelfTestStep
namePlateGui.OnNamePlateUpdate += this.OnNamePlateUpdate;
namePlateGui.OnDataUpdate += this.OnDataUpdate;
namePlateGui.RequestRedraw();
this.updateCount = new Dictionary<ulong, int>();
this.updateCount = [];
this.currentSubStep++;
break;

View file

@ -50,7 +50,7 @@ public class StyleEditorWindow : Window
this.didSave = false;
var config = Service<DalamudConfiguration>.Get();
config.SavedStyles ??= new List<StyleModel>();
config.SavedStyles ??= [];
this.currentSel = config.SavedStyles.FindIndex(x => x.Name == config.ChosenStyle);
this.initialStyle = config.ChosenStyle;

View file

@ -49,9 +49,9 @@ internal class TitleScreenMenuWindow : Window, IDisposable
private readonly Lazy<IDalamudTextureWrap> shadeTexture;
private readonly AddonLifecycleEventListener versionStringListener;
private readonly Dictionary<Guid, InOutCubic> shadeEasings = new();
private readonly Dictionary<Guid, InOutQuint> moveEasings = new();
private readonly Dictionary<Guid, InOutCubic> logoEasings = new();
private readonly Dictionary<Guid, InOutCubic> shadeEasings = [];
private readonly Dictionary<Guid, InOutQuint> moveEasings = [];
private readonly Dictionary<Guid, InOutCubic> logoEasings = [];
private readonly IConsoleVariable<bool> showTsm;