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

@ -91,7 +91,7 @@ internal sealed class DalamudConfiguration : IInternalDisposableService
/// <summary>
/// Gets or sets a dictionary of seen FTUE levels.
/// </summary>
public Dictionary<string, int> SeenFtueLevels { get; set; } = new();
public Dictionary<string, int> SeenFtueLevels { get; set; } = [];
/// <summary>
/// Gets or sets the last loaded Dalamud version.
@ -116,7 +116,7 @@ internal sealed class DalamudConfiguration : IInternalDisposableService
/// <summary>
/// Gets or sets a list of custom repos.
/// </summary>
public List<ThirdPartyRepoSettings> ThirdRepoList { get; set; } = new();
public List<ThirdPartyRepoSettings> ThirdRepoList { get; set; } = [];
/// <summary>
/// Gets or sets a value indicating whether a disclaimer regarding third-party repos has been dismissed.
@ -126,12 +126,12 @@ internal sealed class DalamudConfiguration : IInternalDisposableService
/// <summary>
/// Gets or sets a list of hidden plugins.
/// </summary>
public List<string> HiddenPluginInternalName { get; set; } = new();
public List<string> HiddenPluginInternalName { get; set; } = [];
/// <summary>
/// Gets or sets a list of seen plugins.
/// </summary>
public List<string> SeenPluginInternalName { get; set; } = new();
public List<string> SeenPluginInternalName { get; set; } = [];
/// <summary>
/// Gets or sets a list of additional settings for devPlugins. The key is the absolute path
@ -139,14 +139,14 @@ internal sealed class DalamudConfiguration : IInternalDisposableService
/// However by specifiying this value manually, you can add arbitrary files outside the normal
/// file paths.
/// </summary>
public Dictionary<string, DevPluginSettings> DevPluginSettings { get; set; } = new();
public Dictionary<string, DevPluginSettings> DevPluginSettings { get; set; } = [];
/// <summary>
/// Gets or sets a list of additional locations that dev plugins should be loaded from. This can
/// be either a DLL or folder, but should be the absolute path, or a path relative to the currently
/// injected Dalamud instance.
/// </summary>
public List<DevPluginLocationSettings> DevPluginLoadLocations { get; set; } = new();
public List<DevPluginLocationSettings> DevPluginLoadLocations { get; set; } = [];
/// <summary>
/// Gets or sets the global UI scale.
@ -228,7 +228,7 @@ internal sealed class DalamudConfiguration : IInternalDisposableService
/// <summary>
/// Gets or sets a list representing the command history for the Dalamud Console.
/// </summary>
public List<string> LogCommandHistory { get; set; } = new();
public List<string> LogCommandHistory { get; set; } = [];
/// <summary>
/// Gets or sets a value indicating whether the dev bar should open at startup.

View file

@ -31,5 +31,5 @@ internal sealed class DevPluginSettings
/// <summary>
/// Gets or sets a list of validation problems that have been dismissed by the user.
/// </summary>
public List<string> DismissedValidationProblems { get; set; } = new();
public List<string> DismissedValidationProblems { get; set; } = [];
}

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
@ -19,7 +19,7 @@ internal partial class ConsoleManager : IServiceType
{
private static readonly ModuleLog Log = new("CON");
private Dictionary<string, IConsoleEntry> entries = new();
private Dictionary<string, IConsoleEntry> entries = [];
/// <summary>
/// Initializes a new instance of the <see cref="ConsoleManager"/> class.

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
@ -65,7 +65,7 @@ internal class ConsoleManagerPluginScoped : IConsole, IInternalDisposableService
[ServiceManager.ServiceDependency]
private readonly ConsoleManager console = Service<ConsoleManager>.Get();
private readonly List<IConsoleEntry> trackedEntries = new();
private readonly List<IConsoleEntry> trackedEntries = [];
/// <summary>
/// Initializes a new instance of the <see cref="ConsoleManagerPluginScoped"/> class.

View file

@ -28,7 +28,7 @@ internal unsafe class PluginEventController : IDisposable
private AddonEventListener EventListener { get; init; }
private List<AddonEventEntry> Events { get; } = new();
private List<AddonEventEntry> Events { get; } = [];
/// <summary>
/// Adds a tracked event.

View file

@ -69,12 +69,12 @@ internal unsafe class AddonLifecycle : IInternalDisposableService
/// <summary>
/// Gets a list of all AddonLifecycle ReceiveEvent Listener Hooks.
/// </summary>
internal List<AddonLifecycleReceiveEventListener> ReceiveEventListeners { get; } = new();
internal List<AddonLifecycleReceiveEventListener> ReceiveEventListeners { get; } = [];
/// <summary>
/// Gets a list of all AddonLifecycle Event Listeners.
/// </summary>
internal List<AddonLifecycleEventListener> EventListeners { get; } = new();
internal List<AddonLifecycleEventListener> EventListeners { get; } = [];
/// <inheritdoc/>
void IInternalDisposableService.DisposeService()
@ -387,7 +387,7 @@ internal class AddonLifecyclePluginScoped : IInternalDisposableService, IAddonLi
[ServiceManager.ServiceDependency]
private readonly AddonLifecycle addonLifecycleService = Service<AddonLifecycle>.Get();
private readonly List<AddonLifecycleEventListener> eventListeners = new();
private readonly List<AddonLifecycleEventListener> eventListeners = [];
/// <inheritdoc/>
void IInternalDisposableService.DisposeService()

View file

@ -12,7 +12,7 @@ public abstract class BaseAddressResolver
/// <summary>
/// Gets a list of memory addresses that were found, to list in /xldata.
/// </summary>
public static Dictionary<string, List<(string ClassName, IntPtr Address)>> DebugScannedValues { get; } = new();
public static Dictionary<string, List<(string ClassName, IntPtr Address)>> DebugScannedValues { get; } = [];
/// <summary>
/// Gets or sets a value indicating whether the resolver has successfully run <see cref="Setup32Bit(ISigScanner)"/> or <see cref="Setup64Bit(ISigScanner)"/>.

View file

@ -267,7 +267,7 @@ internal class CommandManagerPluginScoped : IInternalDisposableService, ICommand
[ServiceManager.ServiceDependency]
private readonly CommandManager commandManagerService = Service<CommandManager>.Get();
private readonly List<string> pluginRegisteredCommands = new();
private readonly List<string> pluginRegisteredCommands = [];
private readonly LocalPlugin pluginInfo;
/// <summary>

View file

@ -86,7 +86,7 @@ internal sealed class Framework : IInternalDisposableService, IFramework
/// <summary>
/// Gets the stats history mapping.
/// </summary>
public static Dictionary<string, List<double>> StatsHistory { get; } = new();
public static Dictionary<string, List<double>> StatsHistory { get; } = [];
/// <inheritdoc/>
public DateTime LastUpdate { get; private set; } = DateTime.MinValue;
@ -106,7 +106,7 @@ internal sealed class Framework : IInternalDisposableService, IFramework
/// <summary>
/// Gets the list of update sub-delegates that didn't get updated this frame.
/// </summary>
internal List<string> NonUpdatedSubDelegates { get; private set; } = new();
internal List<string> NonUpdatedSubDelegates { get; private set; } = [];
/// <summary>
/// Gets or sets a value indicating whether to dispatch update events.
@ -333,7 +333,7 @@ internal sealed class Framework : IInternalDisposableService, IFramework
internal static void AddToStats(string key, double ms)
{
if (!StatsHistory.ContainsKey(key))
StatsHistory.Add(key, new List<double>());
StatsHistory.Add(key, []);
StatsHistory[key].Add(ms);

View file

@ -41,7 +41,7 @@ internal sealed unsafe class ChatGui : IInternalDisposableService, IChatGui
private static readonly ModuleLog Log = new("ChatGui");
private readonly Queue<XivChatEntry> chatQueue = new();
private readonly Dictionary<(string PluginName, uint CommandId), Action<uint, SeString>> dalamudLinkHandlers = new();
private readonly Dictionary<(string PluginName, uint CommandId), Action<uint, SeString>> dalamudLinkHandlers = [];
private readonly Hook<PrintMessageDelegate> printMessageHook;
private readonly Hook<InventoryItem.Delegates.Copy> inventoryItemCopyHook;

View file

@ -54,7 +54,7 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
private readonly ReaderWriterLockSlim entriesLock = new();
private readonly List<DtrBarEntry> entries = [];
private readonly Dictionary<uint, List<IAddonEventHandle>> eventHandles = new();
private readonly Dictionary<uint, List<IAddonEventHandle>> eventHandles = [];
private ImmutableList<IReadOnlyDtrBarEntry>? entriesReadOnlyCopy;
@ -516,7 +516,7 @@ internal sealed unsafe class DtrBar : IInternalDisposableService, IDtrBar
var node = data.TextNode = this.MakeNode(++this.runningNodeIds);
this.eventHandles.TryAdd(node->NodeId, new List<IAddonEventHandle>());
this.eventHandles.TryAdd(node->NodeId, []);
this.eventHandles[node->NodeId].AddRange(new List<IAddonEventHandle>
{
this.uiEventManager.AddEvent(AddonEventManager.DalamudInternalKey, (nint)dtr, (nint)node, AddonEventType.MouseOver, this.DtrEventHandler),

View file

@ -18,15 +18,15 @@ namespace Dalamud.Game.Inventory;
[ServiceManager.EarlyLoadedService]
internal class GameInventory : IInternalDisposableService
{
private readonly List<GameInventoryPluginScoped> subscribersPendingChange = new();
private readonly List<GameInventoryPluginScoped> subscribers = new();
private readonly List<GameInventoryPluginScoped> subscribersPendingChange = [];
private readonly List<GameInventoryPluginScoped> subscribers = [];
private readonly List<InventoryItemAddedArgs> addedEvents = new();
private readonly List<InventoryItemRemovedArgs> removedEvents = new();
private readonly List<InventoryItemChangedArgs> changedEvents = new();
private readonly List<InventoryItemMovedArgs> movedEvents = new();
private readonly List<InventoryItemSplitArgs> splitEvents = new();
private readonly List<InventoryItemMergedArgs> mergedEvents = new();
private readonly List<InventoryItemAddedArgs> addedEvents = [];
private readonly List<InventoryItemRemovedArgs> removedEvents = [];
private readonly List<InventoryItemChangedArgs> changedEvents = [];
private readonly List<InventoryItemMovedArgs> movedEvents = [];
private readonly List<InventoryItemSplitArgs> splitEvents = [];
private readonly List<InventoryItemMergedArgs> mergedEvents = [];
[ServiceManager.ServiceDependency]
private readonly Framework framework = Service<Framework>.Get();

View file

@ -64,7 +64,7 @@ internal class UniversalisMarketBoardUploader : IMarketBoardUploader
PricePerUnit = marketBoardItemListing.PricePerUnit,
Quantity = marketBoardItemListing.ItemQuantity,
RetainerCity = marketBoardItemListing.RetainerCityId,
Materia = new List<UniversalisItemMateria>(),
Materia = [],
};
#pragma warning restore CS0618 // Type or member is obsolete

View file

@ -28,7 +28,7 @@ public class SeString
/// </summary>
public SeString()
{
this.Payloads = new List<Payload>();
this.Payloads = [];
}
/// <summary>

View file

@ -45,7 +45,7 @@ internal unsafe class FunctionPointerVariableHook<T> : Hook<T>
if (!HookManager.MultiHookTracker.TryGetValue(this.Address, out var indexList))
{
indexList = HookManager.MultiHookTracker[this.Address] = new List<IDalamudHook>();
indexList = HookManager.MultiHookTracker[this.Address] = [];
}
this.detourDelegate = detour;

View file

@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using System.Linq;
using Dalamud.Game;
@ -25,7 +25,7 @@ internal class GameInteropProviderPluginScoped : IGameInteropProvider, IInternal
private readonly LocalPlugin plugin;
private readonly SigScanner scanner;
private readonly WeakConcurrentCollection<IDalamudHook> trackedHooks = new();
private readonly WeakConcurrentCollection<IDalamudHook> trackedHooks = [];
/// <summary>
/// Initializes a new instance of the <see cref="GameInteropProviderPluginScoped"/> class.

View file

@ -24,7 +24,7 @@ internal class MinHookHook<T> : Hook<T> where T : Delegate
var unhooker = HookManager.RegisterUnhooker(this.Address);
if (!HookManager.MultiHookTracker.TryGetValue(this.Address, out var indexList))
indexList = HookManager.MultiHookTracker[this.Address] = new();
indexList = HookManager.MultiHookTracker[this.Address] = [];
var index = (ulong)indexList.Count;

View file

@ -20,7 +20,7 @@ internal sealed class WndProcHookManager : IInternalDisposableService
private static readonly ModuleLog Log = new(nameof(WndProcHookManager));
private readonly Hook<DispatchMessageWDelegate> dispatchMessageWHook;
private readonly Dictionary<HWND, WndProcEventArgs> wndProcOverrides = new();
private readonly Dictionary<HWND, WndProcEventArgs> wndProcOverrides = [];
private HWND mainWindowHwnd;

View file

@ -36,26 +36,25 @@ public interface IFontFamilyId : IObjectWithLocalizableName
/// </summary>
/// <returns>The list of fonts.</returns>
public static List<IFontFamilyId> ListDalamudFonts() =>
new()
{
[
new DalamudAssetFontAndFamilyId(DalamudAsset.NotoSansJpMedium),
new DalamudAssetFontAndFamilyId(DalamudAsset.InconsolataRegular),
new DalamudAssetFontAndFamilyId(DalamudAsset.FontAwesomeFreeSolid),
};
];
/// <summary>
/// Gets the list of Game-provided fonts.
/// </summary>
/// <returns>The list of fonts.</returns>
public static List<IFontFamilyId> ListGameFonts() => new()
{
public static List<IFontFamilyId> ListGameFonts() =>
[
new GameFontAndFamilyId(GameFontFamily.Axis),
new GameFontAndFamilyId(GameFontFamily.Jupiter),
new GameFontAndFamilyId(GameFontFamily.JupiterNumeric),
new GameFontAndFamilyId(GameFontFamily.Meidinger),
new GameFontAndFamilyId(GameFontFamily.MiedingerMid),
new GameFontAndFamilyId(GameFontFamily.TrumpGothic),
};
];
/// <summary>
/// Gets the list of System-provided fonts.

View file

@ -43,12 +43,12 @@ public class FdtReader
/// <summary>
/// Gets all the glyphs defined in this file.
/// </summary>
public List<FontTableEntry> Glyphs { get; init; } = new();
public List<FontTableEntry> Glyphs { get; init; } = [];
/// <summary>
/// Gets all the kerning entries defined in this file.
/// </summary>
public List<KerningTableEntry> Distances { get; init; } = new();
public List<KerningTableEntry> Distances { get; init; } = [];
/// <summary>
/// Finds the glyph index for the corresponding codepoint.

View file

@ -300,7 +300,7 @@ public class GameFontLayoutPlan
elements.Add(new() { Codepoint = c, Glyph = this.fdt.GetGlyph(c), });
var lastBreakIndex = 0;
List<int> lineBreakIndices = new() { 0 };
List<int> lineBreakIndices = [0];
for (var i = 1; i < elements.Count; i++)
{
var prev = elements[i - 1];

View file

@ -30,7 +30,7 @@ namespace Dalamud.Interface.ImGuiBackend.Renderers;
Justification = "Multiple fixed/using scopes")]
internal unsafe partial class Dx11Renderer : IImGuiRenderer
{
private readonly List<IDalamudTextureWrap> fontTextures = new();
private readonly List<IDalamudTextureWrap> fontTextures = [];
private readonly D3D_FEATURE_LEVEL featureLevel;
private readonly ViewportHandler viewportHandler;
private readonly nint renderNamePtr;

View file

@ -10,7 +10,7 @@ public partial class FileDialog
{
private static Regex filterRegex = new(@"[^,{}]+(\{([^{}]*?)\})?", RegexOptions.Compiled);
private List<FilterStruct> filters = new();
private List<FilterStruct> filters = [];
private FilterStruct selectedFilter;
private void ParseFilters(string filters)
@ -42,7 +42,7 @@ public partial class FileDialog
filter = new FilterStruct
{
Filter = match,
CollectionFilters = new(),
CollectionFilters = [],
};
}

View file

@ -122,7 +122,7 @@ public partial class FileDialog
{
if (iconMap == null)
{
iconMap = new();
iconMap = [];
AddToIconMap(new[] { "mp4", "gif", "mov", "avi" }, FontAwesomeIcon.FileVideo, miscTextColor);
AddToIconMap(new[] { "pdf" }, FontAwesomeIcon.FilePdf, miscTextColor);
AddToIconMap(new[] { "png", "jpg", "jpeg", "tiff" }, FontAwesomeIcon.FileImage, imageTextColor);

View file

@ -30,7 +30,7 @@ public partial class FileDialog
private string currentPath;
private string fileNameBuffer = string.Empty;
private List<string> pathDecomposition = new();
private List<string> pathDecomposition = [];
private bool pathClicked = true;
private bool pathInputActivated = false;
private string pathInputBuffer = string.Empty;
@ -46,12 +46,12 @@ public partial class FileDialog
private string searchBuffer = string.Empty;
private string lastSelectedFileName = string.Empty;
private List<string> selectedFileNames = new();
private List<string> selectedFileNames = [];
private float footerHeight = 0;
private string selectedSideBar = string.Empty;
private List<SideBarItem> quickAccess = new();
private List<SideBarItem> quickAccess = [];
/// <summary>
/// Initializes a new instance of the <see cref="FileDialog"/> class.
@ -130,12 +130,12 @@ public partial class FileDialog
{
if (!this.flags.HasFlag(ImGuiFileDialogFlags.SelectOnly))
{
return new List<string> { this.GetFilePathName() };
return [this.GetFilePathName()];
}
if (this.IsDirectoryMode() && this.selectedFileNames.Count == 0)
{
return new List<string> { this.GetFilePathName() }; // current directory
return [this.GetFilePathName()]; // current directory
}
var fullPaths = this.selectedFileNames.Where(x => !string.IsNullOrEmpty(x)).Select(x => Path.Combine(this.currentPath, x));

View file

@ -31,7 +31,7 @@ public sealed class SingleFontChooserDialog : IDisposable
private const float MaxFontSizePt = 127;
private static readonly List<IFontId> EmptyIFontList = new();
private static readonly List<IFontId> EmptyIFontList = [];
private static readonly (string Name, float Value)[] FontSizeList =
{

View file

@ -26,8 +26,8 @@ internal class NotificationManager : INotificationManager, IInternalDisposableSe
[ServiceManager.ServiceDependency]
private readonly DalamudConfiguration configuration = Service<DalamudConfiguration>.Get();
private readonly List<ActiveNotification> notifications = new();
private readonly ConcurrentBag<ActiveNotification> pendingNotifications = new();
private readonly List<ActiveNotification> notifications = [];
private readonly ConcurrentBag<ActiveNotification> pendingNotifications = [];
private NotificationPositionChooser? positionChooser;

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;

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;

View file

@ -35,7 +35,7 @@ internal sealed class DelegateFontHandle : FontHandle
/// </summary>
internal sealed class HandleManager : IFontHandleManager
{
private readonly HashSet<DelegateFontHandle> handles = new();
private readonly HashSet<DelegateFontHandle> handles = [];
private readonly Lock syncRoot = new();
/// <summary>
@ -96,8 +96,8 @@ internal sealed class DelegateFontHandle : FontHandle
private static readonly ModuleLog Log = new($"{nameof(DelegateFontHandle)}.{nameof(HandleSubstance)}");
// Owned by this class, but ImFontPtr values still do not belong to this.
private readonly Dictionary<DelegateFontHandle, ImFontPtr> fonts = new();
private readonly Dictionary<DelegateFontHandle, Exception?> buildExceptions = new();
private readonly Dictionary<DelegateFontHandle, ImFontPtr> fonts = [];
private readonly Dictionary<DelegateFontHandle, Exception?> buildExceptions = [];
/// <summary>
/// Initializes a new instance of the <see cref="HandleSubstance"/> class.

View file

@ -25,8 +25,7 @@ namespace Dalamud.Interface.ManagedFontAtlas.Internals;
/// </summary>
internal sealed partial class FontAtlasFactory
{
private static readonly Dictionary<ulong, List<(char Left, char Right, float Distance)>> PairAdjustmentsCache =
new();
private static readonly Dictionary<ulong, List<(char Left, char Right, float Distance)>> PairAdjustmentsCache = [];
/// <summary>
/// Implementations for <see cref="IFontAtlasBuildToolkitPreBuild"/> and
@ -44,7 +43,7 @@ internal sealed partial class FontAtlasFactory
private readonly GamePrebakedFontHandle.HandleSubstance gameFontHandleSubstance;
private readonly FontAtlasFactory factory;
private readonly FontAtlasBuiltData data;
private readonly List<Action> registeredPostBuildActions = new();
private readonly List<Action> registeredPostBuildActions = [];
/// <summary>
/// Initializes a new instance of the <see cref="BuildToolkit"/> class.
@ -86,7 +85,7 @@ internal sealed partial class FontAtlasFactory
/// <summary>
/// Gets the font scale modes.
/// </summary>
private Dictionary<ImFontPtr, FontScaleMode> FontScaleModes { get; } = new();
private Dictionary<ImFontPtr, FontScaleMode> FontScaleModes { get; } = [];
/// <inheritdoc/>
public void Dispose() => this.disposeAfterBuild.Dispose();
@ -189,7 +188,7 @@ internal sealed partial class FontAtlasFactory
{
if (!PairAdjustmentsCache.TryGetValue(hashIdent, out pairAdjustments))
{
PairAdjustmentsCache.Add(hashIdent, pairAdjustments = new());
PairAdjustmentsCache.Add(hashIdent, pairAdjustments = []);
try
{
pairAdjustments.AddRange(TrueTypeUtils.ExtractHorizontalPairAdjustments(raw).ToArray());

View file

@ -66,10 +66,10 @@ internal sealed partial class FontAtlasFactory
try
{
var substancesList = this.substances = new();
var substancesList = this.substances = [];
this.Garbage.Add(() => substancesList.Clear());
var wrapsCopy = this.wraps = new();
var wrapsCopy = this.wraps = [];
this.Garbage.Add(() => wrapsCopy.Clear());
var atlasPtr = ImGui.ImFontAtlas();

View file

@ -20,7 +20,7 @@ namespace Dalamud.Interface.ManagedFontAtlas.Internals;
internal abstract class FontHandle : IFontHandle
{
private const int NonMainThreadFontAccessWarningCheckInterval = 10000;
private static readonly ConditionalWeakTable<LocalPlugin, object> NonMainThreadFontAccessWarning = new();
private static readonly ConditionalWeakTable<LocalPlugin, object> NonMainThreadFontAccessWarning = [];
private static long nextNonMainThreadFontAccessWarningCheck;
private readonly List<IDisposable> pushedFonts = new(8);

View file

@ -103,8 +103,8 @@ internal class GamePrebakedFontHandle : FontHandle
/// </summary>
internal sealed class HandleManager : IFontHandleManager
{
private readonly Dictionary<GameFontStyle, int> gameFontsRc = new();
private readonly HashSet<GamePrebakedFontHandle> handles = new();
private readonly Dictionary<GameFontStyle, int> gameFontsRc = [];
private readonly HashSet<GamePrebakedFontHandle> handles = [];
private readonly Lock syncRoot = new();
/// <summary>
@ -190,11 +190,11 @@ internal class GamePrebakedFontHandle : FontHandle
private readonly HashSet<GameFontStyle> gameFontStyles;
// Owned by this class, but ImFontPtr values still do not belong to this.
private readonly Dictionary<GameFontStyle, FontDrawPlan> fonts = new();
private readonly Dictionary<GameFontStyle, Exception?> buildExceptions = new();
private readonly List<(ImFontPtr Font, GameFontStyle Style, ushort[]? Ranges)> attachments = new();
private readonly Dictionary<GameFontStyle, FontDrawPlan> fonts = [];
private readonly Dictionary<GameFontStyle, Exception?> buildExceptions = [];
private readonly List<(ImFontPtr Font, GameFontStyle Style, ushort[]? Ranges)> attachments = [];
private readonly HashSet<ImFontPtr> templatedFonts = new();
private readonly HashSet<ImFontPtr> templatedFonts = [];
/// <summary>
/// Initializes a new instance of the <see cref="HandleSubstance"/> class.
@ -451,8 +451,8 @@ internal class GamePrebakedFontHandle : FontHandle
public readonly GameFontStyle BaseStyle;
public readonly GameFontFamilyAndSizeAttribute BaseAttr;
public readonly int TexCount;
public readonly Dictionary<ImFontPtr, BitArray> Ranges = new();
public readonly List<(int RectId, int FdtGlyphIndex)> Rects = new();
public readonly Dictionary<ImFontPtr, BitArray> Ranges = [];
public readonly List<(int RectId, int FdtGlyphIndex)> Rects = [];
public readonly ushort[] RectLookup = new ushort[0x10000];
public readonly FdtFileView Fdt;
public readonly ImFontPtr FullRangeFont;

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
@ -86,8 +86,7 @@ public abstract class StyleModel
if (configuration.SavedStylesOld == null)
return;
configuration.SavedStyles = new List<StyleModel>();
configuration.SavedStyles.AddRange(configuration.SavedStylesOld);
configuration.SavedStyles = [.. configuration.SavedStylesOld];
Log.Information("Transferred {NumStyles} styles", configuration.SavedStyles.Count);

View file

@ -17,7 +17,7 @@ public class StyleModelV1 : StyleModel
/// </summary>
private StyleModelV1()
{
this.Colors = new Dictionary<string, Vector4>();
this.Colors = [];
this.Name = "Unknown";
}
@ -396,7 +396,7 @@ public class StyleModelV1 : StyleModel
model.SelectableTextAlign = style.SelectableTextAlign;
model.DisplaySafeAreaPadding = style.DisplaySafeAreaPadding;
model.Colors = new Dictionary<string, Vector4>();
model.Colors = [];
foreach (var imGuiCol in Enum.GetValues<ImGuiCol>())
{

View file

@ -24,7 +24,7 @@ internal abstract class SharedImmediateTexture
private static long instanceCounter;
private readonly Lock reviveLock = new();
private readonly List<LocalPlugin> ownerPlugins = new();
private readonly List<LocalPlugin> ownerPlugins = [];
private bool resourceReleased;
private int refCount;

View file

@ -44,7 +44,7 @@ internal sealed partial class TextureManager
/// <summary>Gets the list containing all the loaded textures from plugins.</summary>
/// <remarks>Returned value must be used inside a lock.</remarks>
public List<IBlameableDalamudTextureWrap> BlameTracker { get; } = new();
public List<IBlameableDalamudTextureWrap> BlameTracker { get; } = [];
/// <summary>Gets the blame for a texture wrap.</summary>
/// <param name="textureWrap">The texture wrap.</param>
@ -234,7 +234,7 @@ internal sealed partial class TextureManager
public static Guid* NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in MyGuid));
/// <inheritdoc/>
public List<LocalPlugin> OwnerPlugins { get; } = new();
public List<LocalPlugin> OwnerPlugins { get; } = [];
/// <inheritdoc/>
public nint ResourceAddress => (nint)this.tex2D;

View file

@ -65,7 +65,7 @@ internal sealed partial class TextureManager
private readonly ConcurrentDictionary<string, SharedImmediateTexture> gameDict = new();
private readonly ConcurrentDictionary<string, SharedImmediateTexture> fileDict = new();
private readonly ConcurrentDictionary<(Assembly, string), SharedImmediateTexture> manifestResourceDict = new();
private readonly HashSet<SharedImmediateTexture> invalidatedTextures = new();
private readonly HashSet<SharedImmediateTexture> invalidatedTextures = [];
private readonly Thread sharedTextureReleaseThread;

View file

@ -22,7 +22,7 @@ internal class TitleScreenMenu : IServiceType, ITitleScreenMenu
/// </summary>
internal const uint TextureSize = 64;
private readonly List<TitleScreenMenuEntry> entries = new();
private readonly List<TitleScreenMenuEntry> entries = [];
private TitleScreenMenuEntry[]? entriesView;
[ServiceManager.ServiceConstructor]
@ -220,7 +220,7 @@ internal class TitleScreenMenuPluginScoped : IInternalDisposableService, ITitleS
[ServiceManager.ServiceDependency]
private readonly TitleScreenMenu titleScreenMenuService = Service<TitleScreenMenu>.Get();
private readonly List<IReadOnlyTitleScreenMenuEntry> pluginEntries = new();
private readonly List<IReadOnlyTitleScreenMenuEntry> pluginEntries = [];
/// <inheritdoc/>
public IReadOnlyList<IReadOnlyTitleScreenMenuEntry>? Entries => this.titleScreenMenuService.Entries;

View file

@ -607,7 +607,7 @@ public sealed class UiBuilder : IDisposable, IUiBuilder
/// <summary>
/// Gets or sets a history of the last draw times, used to calculate an average.
/// </summary>
internal List<long> DrawTimeHistory { get; set; } = new List<long>();
internal List<long> DrawTimeHistory { get; set; } = [];
private InterfaceManager? InterfaceManagerWithScene =>
Service<InterfaceManager.InterfaceManagerWithScene>.GetNullable()?.Manager;

View file

@ -17,7 +17,7 @@ public class UldWrapper : IDisposable
{
private readonly DataManager data;
private readonly TextureManager textureManager;
private readonly Dictionary<string, (uint Id, int Width, int Height, bool HD, byte[] RgbaData)> textures = new();
private readonly Dictionary<string, (uint Id, int Width, int Height, bool HD, byte[] RgbaData)> textures = [];
/// <summary> Initializes a new instance of the <see cref="UldWrapper"/> class, wrapping an ULD file. </summary>
/// <param name="uiBuilder">The UiBuilder used to load textures.</param>

View file

@ -29,7 +29,7 @@ public static partial class ImRaii
public sealed class Color : IDisposable
{
internal static readonly List<(ImGuiCol, uint)> Stack = new();
internal static readonly List<(ImGuiCol, uint)> Stack = [];
private int count;
public Color Push(ImGuiCol idx, uint color, bool condition = true)

View file

@ -96,7 +96,7 @@ public static partial class ImRaii
public sealed class PlotStyle : IDisposable
{
internal static readonly List<(ImPlotStyleVar, Vector2)> Stack = new();
internal static readonly List<(ImPlotStyleVar, Vector2)> Stack = [];
private int count;
@ -249,7 +249,7 @@ public static partial class ImRaii
public sealed class PlotColor : IDisposable
{
internal static readonly List<(ImPlotCol, uint)> Stack = new();
internal static readonly List<(ImPlotCol, uint)> Stack = [];
private int count;
// Reimplementation of https://github.com/ocornut/imgui/blob/868facff9ded2d61425c67deeba354eb24275bd1/imgui.cpp#L3035

View file

@ -35,7 +35,7 @@ public static partial class ImRaii
public sealed class Style : IDisposable
{
internal static readonly List<(ImGuiStyleVar, Vector2)> Stack = new();
internal static readonly List<(ImGuiStyleVar, Vector2)> Stack = [];
private int count;

View file

@ -25,7 +25,7 @@ internal class PresetModel
/// Gets or sets a dictionary containing the windows in the preset, mapping their ID to the preset.
/// </summary>
[JsonProperty("w")]
public Dictionary<uint, PresetWindow> Windows { get; set; } = new();
public Dictionary<uint, PresetWindow> Windows { get; set; } = [];
/// <summary>
/// Class representing a window in a preset.

View file

@ -230,7 +230,7 @@ public abstract class Window
/// disabled globally by the user, an internal title bar button to manage these is added when drawing, but it will
/// not appear in this collection. If you wish to remove this button, set both of these values to false.
/// </summary>
public List<TitleBarButton> TitleBarButtons { get; set; } = new();
public List<TitleBarButton> TitleBarButtons { get; set; } = [];
/// <summary>
/// Gets or sets a value indicating whether this window will stay open.

View file

@ -15,7 +15,7 @@ public class WindowSystem
{
private static DateTimeOffset lastAnyFocus;
private readonly List<Window> windows = new();
private readonly List<Window> windows = [];
private string lastFocusedWindowName = string.Empty;

View file

@ -22,8 +22,8 @@ internal class ServiceContainer : IServiceType
{
private static readonly ModuleLog Log = new("SERVICECONTAINER");
private readonly Dictionary<Type, ObjectInstance> instances = new();
private readonly Dictionary<Type, Type> interfaceToTypeMap = new();
private readonly Dictionary<Type, ObjectInstance> instances = [];
private readonly Dictionary<Type, Type> interfaceToTypeMap = [];
/// <summary>
/// Initializes a new instance of the <see cref="ServiceContainer"/> class.

View file

@ -16,7 +16,7 @@ namespace Dalamud.Logging.Internal;
internal class TaskTracker : IInternalDisposableService
{
private static readonly ModuleLog Log = new("TT");
private static readonly List<TaskInfo> TrackedTasksInternal = new();
private static readonly List<TaskInfo> TrackedTasksInternal = [];
private static readonly ConcurrentQueue<TaskInfo> NewlyCreatedTasks = new();
private static bool clearRequested = false;

View file

@ -15,9 +15,9 @@ namespace Dalamud.Plugin.Internal.Loader;
/// </summary>
internal class AssemblyLoadContextBuilder
{
private readonly List<string> additionalProbingPaths = new();
private readonly List<string> resourceProbingPaths = new();
private readonly List<string> resourceProbingSubpaths = new();
private readonly List<string> additionalProbingPaths = [];
private readonly List<string> resourceProbingPaths = [];
private readonly List<string> resourceProbingSubpaths = [];
private readonly Dictionary<string, ManagedLibrary> managedLibraries = new(StringComparer.Ordinal);
private readonly Dictionary<string, NativeLibrary> nativeLibraries = new(StringComparer.Ordinal);
private readonly HashSet<string> privateAssemblies = new(StringComparer.Ordinal);

View file

@ -39,13 +39,13 @@ internal class LoaderConfig
/// <summary>
/// Gets a list of assemblies which should be treated as private.
/// </summary>
public ICollection<AssemblyName> PrivateAssemblies { get; } = new List<AssemblyName>();
public ICollection<AssemblyName> PrivateAssemblies { get; } = [];
/// <summary>
/// Gets a list of assemblies which should be unified between the host and the plugin.
/// </summary>
/// <seealso href="https://github.com/natemcmaster/DotNetCorePlugins/blob/main/docs/what-are-shared-types.md">what-are-shared-types</seealso>
public ICollection<(AssemblyName Name, bool Recursive)> SharedAssemblies { get; } = new List<(AssemblyName Name, bool Recursive)>();
public ICollection<(AssemblyName Name, bool Recursive)> SharedAssemblies { get; } = [];
/// <summary>
/// Gets or sets a value indicating whether attempt to unify all types from a plugin with the host.

View file

@ -22,7 +22,7 @@ internal class PluginErrorHandler : IServiceType
private readonly NotificationManager notificationManager;
private readonly DalamudInterface di;
private readonly Dictionary<Type, Delegate> invokerCache = new();
private readonly Dictionary<Type, Delegate> invokerCache = [];
private DateTime lastErrorTime = DateTime.MinValue;
private IActiveNotification? activeNotification;

View file

@ -56,9 +56,9 @@ internal class PluginManager : IInternalDisposableService
private readonly DirectoryInfo pluginDirectory;
private readonly BannedPlugin[]? bannedPlugins;
private readonly List<LocalPlugin> installedPluginsList = new();
private readonly List<RemotePluginManifest> availablePluginsList = new();
private readonly List<AvailablePluginUpdate> updatablePluginsList = new();
private readonly List<LocalPlugin> installedPluginsList = [];
private readonly List<RemotePluginManifest> availablePluginsList = [];
private readonly List<AvailablePluginUpdate> updatablePluginsList = [];
private readonly Task<DalamudLinkPayload> openInstallerWindowPluginChangelogsLink;
@ -131,7 +131,7 @@ internal class PluginManager : IInternalDisposableService
PluginInstallerOpenKind.Changelogs);
}));
this.configuration.PluginTestingOptIns ??= new();
this.configuration.PluginTestingOptIns ??= [];
this.MainRepo = PluginRepository.CreateMainRepo(this.happyHttpClient);
registerStartupBlocker(
@ -230,7 +230,7 @@ internal class PluginManager : IInternalDisposableService
/// <summary>
/// Gets a list of all plugin repositories. The main repo should always be first.
/// </summary>
public List<PluginRepository> Repos { get; private set; } = new();
public List<PluginRepository> Repos { get; private set; } = [];
/// <summary>
/// Gets a value indicating whether plugins are not still loading from boot.
@ -1894,9 +1894,9 @@ internal class PluginManager : IInternalDisposableService
/// </summary>
public class StartupLoadTracker
{
private readonly Dictionary<string, string> internalToPublic = new();
private readonly ConcurrentBag<string> allInternalNames = new();
private readonly ConcurrentBag<string> finishedInternalNames = new();
private readonly Dictionary<string, string> internalToPublic = [];
private readonly ConcurrentBag<string> allInternalNames = [];
private readonly ConcurrentBag<string> finishedInternalNames = [];
/// <summary>
/// Gets a value indicating the total load progress.

View file

@ -39,7 +39,7 @@ internal class PluginManagementCommandHandler : IInternalDisposableService
private readonly ChatGui chat;
private readonly Framework framework;
private List<(Target Target, PluginCommandOperation Operation)> commandQueue = new();
private List<(Target Target, PluginCommandOperation Operation)> commandQueue = [];
/// <summary>
/// Initializes a new instance of the <see cref="PluginManagementCommandHandler"/> class.

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
@ -20,7 +20,7 @@ internal class ProfileManager : IServiceType
private static readonly ModuleLog Log = new("PROFMAN");
private readonly DalamudConfiguration config;
private readonly List<Profile> profiles = new();
private readonly List<Profile> profiles = [];
private volatile bool isBusy = false;
@ -359,7 +359,7 @@ internal class ProfileManager : IServiceType
this.config.DefaultProfile ??= new ProfileModelV1();
this.profiles.Add(new Profile(this, this.config.DefaultProfile, true, true));
this.config.SavedProfiles ??= new List<ProfileModel>();
this.config.SavedProfiles ??= [];
foreach (var profileModel in this.config.SavedProfiles)
{
this.profiles.Add(new Profile(this, profileModel, false, true));

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Newtonsoft.Json;
@ -63,7 +63,7 @@ public class ProfileModelV1 : ProfileModel
/// <summary>
/// Gets or sets the list of plugins in this profile.
/// </summary>
public List<ProfileModelV1Plugin> Plugins { get; set; } = new();
public List<ProfileModelV1Plugin> Plugins { get; set; } = [];
/// <summary>
/// Class representing a single plugin in a profile.

View file

@ -9,7 +9,7 @@ namespace Dalamud.Plugin.Ipc.Internal;
[ServiceManager.EarlyLoadedService]
internal class CallGate : IServiceType
{
private readonly Dictionary<string, CallGateChannel> gates = new();
private readonly Dictionary<string, CallGateChannel> gates = [];
private ImmutableDictionary<string, CallGateChannel>? gatesCopy;

View file

@ -19,7 +19,7 @@ internal class CallGateChannel
/// <summary>
/// The actual storage.
/// </summary>
private readonly HashSet<Delegate> subscriptions = new();
private readonly HashSet<Delegate> subscriptions = [];
/// <summary>
/// A copy of the actual storage, that will be cleared and populated depending on changes made to

View file

@ -40,7 +40,7 @@ internal readonly struct DataCache
{
this.Tag = tag;
this.CreatorAssemblyName = creatorAssemblyName;
this.UserAssemblyNames = new();
this.UserAssemblyNames = [];
this.Data = data;
this.Type = type;
}

View file

@ -19,7 +19,7 @@ internal class DataShare : IServiceType
/// Dictionary of cached values. Note that <see cref="Lazy{T}"/> is being used, as it does its own locking,
/// effectively preventing calling the data generator multiple times concurrently.
/// </summary>
private readonly Dictionary<string, Lazy<DataCache>> caches = new();
private readonly Dictionary<string, Lazy<DataCache>> caches = [];
[ServiceManager.ServiceConstructor]
private DataShare()

View file

@ -44,7 +44,7 @@ internal static class ServiceManager
internal static readonly ThreadLocal<Type?> CurrentConstructorServiceType = new();
[SuppressMessage("ReSharper", "CollectionNeverQueried.Local", Justification = "Debugging purposes")]
private static readonly List<Type> LoadedServices = new();
private static readonly List<Type> LoadedServices = [];
#endif
private static readonly TaskCompletionSource BlockingServicesLoadedTaskCompletionSource =

View file

@ -286,13 +286,13 @@ internal static class Service<T> where T : IServiceType
{
if (method.Invoke(instance, args) is Task task)
{
tasks ??= new();
tasks ??= [];
tasks.Add(task);
}
}
catch (Exception e)
{
tasks ??= new();
tasks ??= [];
tasks.Add(Task.FromException(e));
}
}

View file

@ -127,7 +127,7 @@ public static class Troubleshooting
public bool ForcedMinHook { get; set; }
public List<ThirdPartyRepoSettings> ThirdRepo => new();
public List<ThirdPartyRepoSettings> ThirdRepo => [];
public bool HasThirdRepo { get; set; }
}

View file

@ -100,7 +100,7 @@ public static class DateTimeSpanExtensions
private sealed class ParsedRelativeFormatStrings
{
private readonly List<(float MinSeconds, string FormatString)> formatStrings = new();
private readonly List<(float MinSeconds, string FormatString)> formatStrings = [];
public ParsedRelativeFormatStrings(string value)
{

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reactive.Disposables;
@ -125,7 +125,7 @@ public static class DisposeSafety
}
catch (Exception de)
{
exceptions ??= new();
exceptions ??= [];
exceptions.Add(de);
}
}
@ -140,7 +140,7 @@ public static class DisposeSafety
/// </summary>
public class ScopedFinalizer : IDisposeCallback, IAsyncDisposable
{
private readonly List<object> objects = new();
private readonly List<object> objects = [];
/// <inheritdoc/>
public event Action<IDisposeCallback>? BeforeDispose;
@ -338,7 +338,7 @@ public static class DisposeSafety
}
catch (Exception ex)
{
exceptions ??= new();
exceptions ??= [];
exceptions.Add(ex);
}
}
@ -402,7 +402,7 @@ public static class DisposeSafety
}
catch (Exception ex)
{
exceptions ??= new();
exceptions ??= [];
exceptions.Add(ex);
}
}

View file

@ -15,7 +15,7 @@ internal class DynamicPriorityQueueLoader : IDisposable
private readonly Channel<WorkItem> newItemChannel;
private readonly Channel<object?> workTokenChannel;
private readonly List<WorkItem> workItemPending = new();
private readonly List<WorkItem> workItemPending = [];
private bool disposing;

View file

@ -40,7 +40,7 @@ namespace Dalamud.Utility
{
ThrowHelper.ThrowArgumentOutOfRangeExceptionIfLessThan(nameof(size), size, 0);
this.size = size;
this.items = new();
this.items = [];
}
/// <summary>Initializes a new instance of the <see cref="RollingList{T}"/> class.</summary>

View file

@ -19,12 +19,12 @@ public static class Timings
/// <summary>
/// All concluded timings.
/// </summary>
internal static readonly SortedList<TimingHandle, TimingHandle> AllTimings = new();
internal static readonly SortedList<TimingHandle, TimingHandle> AllTimings = [];
/// <summary>
/// List of all timing events.
/// </summary>
internal static readonly List<TimingEvent> Events = new();
internal static readonly List<TimingEvent> Events = [];
private static readonly AsyncLocal<Tuple<int?, List<TimingHandle>>> TaskTimingHandleStorage = new();
@ -36,7 +36,7 @@ public static class Timings
get
{
if (TaskTimingHandleStorage.Value == null || TaskTimingHandleStorage.Value.Item1 != Task.CurrentId)
TaskTimingHandleStorage.Value = Tuple.Create<int?, List<TimingHandle>>(Task.CurrentId, new());
TaskTimingHandleStorage.Value = Tuple.Create<int?, List<TimingHandle>>(Task.CurrentId, []);
return TaskTimingHandleStorage.Value!.Item2!;
}
set => TaskTimingHandleStorage.Value = Tuple.Create(Task.CurrentId, value);

View file

@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
@ -11,7 +11,7 @@ namespace Dalamud.Utility;
/// <typeparam name="T">The type of object that we're tracking.</typeparam>
public class WeakConcurrentCollection<T> : ICollection<T> where T : class
{
private readonly ConditionalWeakTable<T, object> cwt = new();
private readonly ConditionalWeakTable<T, object> cwt = [];
/// <inheritdoc/>
public int Count => this.cwt.Count();