Fix IDE0300: Use collection expression for array

This commit is contained in:
Haselnussbomber 2025-10-24 04:34:40 +02:00
parent 53914e06d5
commit 4895ee2efc
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
78 changed files with 159 additions and 163 deletions

View file

@ -37,7 +37,7 @@ internal class JobGauges : IServiceType, IJobGauges
// Since the gauge itself reads from live memory, there isn't much downside to doing this.
if (!this.cache.TryGetValue(typeof(T), out var gauge))
{
gauge = this.cache[typeof(T)] = (T)Activator.CreateInstance(typeof(T), BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { this.Address }, null);
gauge = this.cache[typeof(T)] = (T)Activator.CreateInstance(typeof(T), BindingFlags.NonPublic | BindingFlags.Instance, null, [this.Address], null);
}
return (T)gauge;

View file

@ -82,12 +82,12 @@ public unsafe class BRDGauge : JobGaugeBase<FFXIVClientStructs.FFXIV.Client.Game
{
get
{
return new[]
{
return
[
this.Struct->SongFlags.HasFlag(SongFlags.MagesBalladCoda) ? Song.Mage : Song.None,
this.Struct->SongFlags.HasFlag(SongFlags.ArmysPaeonCoda) ? Song.Army : Song.None,
this.Struct->SongFlags.HasFlag(SongFlags.WanderersMinuetCoda) ? Song.Wanderer : Song.None,
};
];
}
}
}

View file

@ -212,11 +212,10 @@ internal sealed class Framework : IInternalDisposableService, IFramework
if (cancellationToken == default)
cancellationToken = this.FrameworkThreadTaskFactory.CancellationToken;
return this.FrameworkThreadTaskFactory.ContinueWhenAll(
new[]
{
[
Task.Delay(delay, cancellationToken),
this.DelayTicks(delayTicks, cancellationToken),
},
],
_ => func(),
cancellationToken,
TaskContinuationOptions.HideScheduler,
@ -239,11 +238,10 @@ internal sealed class Framework : IInternalDisposableService, IFramework
if (cancellationToken == default)
cancellationToken = this.FrameworkThreadTaskFactory.CancellationToken;
return this.FrameworkThreadTaskFactory.ContinueWhenAll(
new[]
{
[
Task.Delay(delay, cancellationToken),
this.DelayTicks(delayTicks, cancellationToken),
},
],
_ => action(),
cancellationToken,
TaskContinuationOptions.HideScheduler,
@ -266,11 +264,10 @@ internal sealed class Framework : IInternalDisposableService, IFramework
if (cancellationToken == default)
cancellationToken = this.FrameworkThreadTaskFactory.CancellationToken;
return this.FrameworkThreadTaskFactory.ContinueWhenAll(
new[]
{
[
Task.Delay(delay, cancellationToken),
this.DelayTicks(delayTicks, cancellationToken),
},
],
_ => func(),
cancellationToken,
TaskContinuationOptions.HideScheduler,
@ -293,11 +290,10 @@ internal sealed class Framework : IInternalDisposableService, IFramework
if (cancellationToken == default)
cancellationToken = this.FrameworkThreadTaskFactory.CancellationToken;
return this.FrameworkThreadTaskFactory.ContinueWhenAll(
new[]
{
[
Task.Delay(delay, cancellationToken),
this.DelayTicks(delayTicks, cancellationToken),
},
],
_ => func(),
cancellationToken,
TaskContinuationOptions.HideScheduler,

View file

@ -381,7 +381,7 @@ public abstract partial class Payload
{
if (value < 0xCF)
{
return new byte[] { (byte)(value + 1) };
return [(byte)(value + 1)];
}
var bytes = BitConverter.GetBytes(value);

View file

@ -45,10 +45,10 @@ public class IconPayload : Payload
{
var indexBytes = MakeInteger((uint)this.Icon);
var chunkLen = indexBytes.Length + 1;
var bytes = new List<byte>(new byte[]
{
var bytes = new List<byte>(
[
START_BYTE, (byte)SeStringChunkType.Icon, (byte)chunkLen,
});
]);
bytes.AddRange(indexBytes);
bytes.Add(END_BYTE);
return bytes.ToArray();

View file

@ -172,7 +172,7 @@ public class ItemPayload : Payload
};
bytes.AddRange(idBytes);
// unk
bytes.AddRange(new byte[] { 0x02, 0x01 });
bytes.AddRange([0x02, 0x01]);
// Links don't have to include the name, but if they do, it requires additional work
if (hasName)
@ -183,17 +183,17 @@ public class ItemPayload : Payload
nameLen += 4; // space plus 3 bytes for HQ symbol
}
bytes.AddRange(new byte[]
{
bytes.AddRange(
[
0xFF, // unk
(byte)nameLen,
});
]);
bytes.AddRange(Encoding.UTF8.GetBytes(this.displayName));
if (this.IsHQ)
{
// space and HQ symbol
bytes.AddRange(new byte[] { 0x20, 0xEE, 0x80, 0xBC });
bytes.AddRange([0x20, 0xEE, 0x80, 0xBC]);
}
}

View file

@ -174,7 +174,7 @@ public class MapLinkPayload : Payload
bytes.AddRange(yBytes);
// unk
bytes.AddRange(new byte[] { 0xFF, 0x01, END_BYTE });
bytes.AddRange([0xFF, 0x01, END_BYTE]);
return bytes.ToArray();
}

View file

@ -7,7 +7,7 @@ namespace Dalamud.Game.Text.SeStringHandling.Payloads;
/// </summary>
public class NewLinePayload : Payload, ITextProvider
{
private readonly byte[] bytes = { START_BYTE, (byte)SeStringChunkType.NewLine, 0x01, END_BYTE };
private readonly byte[] bytes = [START_BYTE, (byte)SeStringChunkType.NewLine, 0x01, END_BYTE];
/// <summary>
/// Gets an instance of NewLinePayload.

View file

@ -121,7 +121,7 @@ namespace Dalamud.Game.Text.SeStringHandling.Payloads
// if the link type is notification, just use premade payload data since it's always the same.
// i have no idea why it is formatted like this, but it is how it is.
// note it is identical to the link terminator payload except the embedded info type is 0x08
if (this.LinkType == PartyFinderLinkType.PartyFinderNotification) return new byte[] { 0x02, 0x27, 0x07, 0x08, 0x01, 0x01, 0x01, 0xFF, 0x01, 0x03, };
if (this.LinkType == PartyFinderLinkType.PartyFinderNotification) return [0x02, 0x27, 0x07, 0x08, 0x01, 0x01, 0x01, 0xFF, 0x01, 0x03,];
// back to our regularly scheduled programming...
var listingIDBytes = MakeInteger(this.ListingId);

View file

@ -62,7 +62,7 @@ public class QuestPayload : Payload
};
bytes.AddRange(idBytes);
bytes.AddRange(new byte[] { 0x01, 0x01, END_BYTE });
bytes.AddRange([0x01, 0x01, END_BYTE]);
return bytes.ToArray();
}

View file

@ -45,7 +45,7 @@ public class RawPayload : Payload
/// <summary>
/// Gets a fixed Payload representing a common link-termination sequence, found in many payload chains.
/// </summary>
public static RawPayload LinkTerminator => new(new byte[] { 0x02, 0x27, 0x07, 0xCF, 0x01, 0x01, 0x01, 0xFF, 0x01, 0x03 });
public static RawPayload LinkTerminator => new([0x02, 0x27, 0x07, 0xCF, 0x01, 0x01, 0x01, 0xFF, 0x01, 0x03]);
/// <inheritdoc/>
public override PayloadType Type => PayloadType.Unknown;

View file

@ -7,7 +7,7 @@ namespace Dalamud.Game.Text.SeStringHandling.Payloads;
/// </summary>
public class SeHyphenPayload : Payload, ITextProvider
{
private readonly byte[] bytes = { START_BYTE, (byte)SeStringChunkType.SeHyphen, 0x01, END_BYTE };
private readonly byte[] bytes = [START_BYTE, (byte)SeStringChunkType.SeHyphen, 0x01, END_BYTE];
/// <summary>
/// Gets an instance of SeHyphenPayload.

View file

@ -63,7 +63,7 @@ public class StatusPayload : Payload
bytes.AddRange(idBytes);
// unk
bytes.AddRange(new byte[] { 0x01, 0x01, 0xFF, 0x02, 0x20, END_BYTE });
bytes.AddRange([0x01, 0x01, 0xFF, 0x02, 0x20, END_BYTE]);
return bytes.ToArray();
}

View file

@ -95,10 +95,10 @@ public class UIForegroundPayload : Payload
var colorBytes = MakeInteger(this.colorKey);
var chunkLen = colorBytes.Length + 1;
var bytes = new List<byte>(new byte[]
{
var bytes = new List<byte>(
[
START_BYTE, (byte)SeStringChunkType.UIForeground, (byte)chunkLen,
});
]);
bytes.AddRange(colorBytes);
bytes.Add(END_BYTE);

View file

@ -98,10 +98,10 @@ public class UIGlowPayload : Payload
var colorBytes = MakeInteger(this.colorKey);
var chunkLen = colorBytes.Length + 1;
var bytes = new List<byte>(new byte[]
{
var bytes = new List<byte>(
[
START_BYTE, (byte)SeStringChunkType.UIGlow, (byte)chunkLen,
});
]);
bytes.AddRange(colorBytes);
bytes.Add(END_BYTE);

View file

@ -258,13 +258,13 @@ public class SeString
var mapPayload = new MapLinkPayload(territoryId, mapId, rawX, rawY);
var nameString = GetMapLinkNameString(mapPayload.PlaceName, instance, mapPayload.CoordinateString);
var payloads = new List<Payload>(new Payload[]
{
var payloads = new List<Payload>(
[
mapPayload,
// arrow goes here
new TextPayload(nameString),
RawPayload.LinkTerminator,
});
]);
payloads.InsertRange(1, TextArrowPayloads);
return new SeString(payloads);
@ -298,13 +298,13 @@ public class SeString
var mapPayload = new MapLinkPayload(territoryId, mapId, xCoord, yCoord, fudgeFactor);
var nameString = GetMapLinkNameString(mapPayload.PlaceName, instance, mapPayload.CoordinateString);
var payloads = new List<Payload>(new Payload[]
{
var payloads = new List<Payload>(
[
mapPayload,
// arrow goes here
new TextPayload(nameString),
RawPayload.LinkTerminator,
});
]);
payloads.InsertRange(1, TextArrowPayloads);
return new SeString(payloads);

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Dalamud.Utility;
@ -37,7 +37,7 @@ public static class FontAwesomeExtensions
public static IEnumerable<string> GetSearchTerms(this FontAwesomeIcon icon)
{
var searchTermsAttribute = icon.GetAttribute<FontAwesomeSearchTermsAttribute>();
return searchTermsAttribute == null ? new string[] { } : searchTermsAttribute.SearchTerms;
return searchTermsAttribute == null ? [] : searchTermsAttribute.SearchTerms;
}
/// <summary>
@ -48,6 +48,6 @@ public static class FontAwesomeExtensions
public static IEnumerable<string> GetCategories(this FontAwesomeIcon icon)
{
var categoriesAttribute = icon.GetAttribute<FontAwesomeCategoriesAttribute>();
return categoriesAttribute == null ? new string[] { } : categoriesAttribute.Categories;
return categoriesAttribute == null ? [] : categoriesAttribute.Categories;
}
}

View file

@ -269,7 +269,7 @@ public class FdtReader
/// <summary>
/// Mapping of texture channel index to byte index.
/// </summary>
public static readonly int[] TextureChannelOrder = { 2, 1, 0, 3 };
public static readonly int[] TextureChannelOrder = [2, 1, 0, 3];
/// <summary>
/// Integer representation of a Unicode character in UTF-8 in reverse order, read in little endian.

View file

@ -8,8 +8,8 @@ public static class GlyphRangesJapanese
/// <summary>
/// Gets the unicode glyph ranges for the Japanese language.
/// </summary>
public static ushort[] GlyphRanges => new ushort[]
{
public static ushort[] GlyphRanges =>
[
0x0020, 0x00FF, 0x0391, 0x03A1, 0x03A3, 0x03A9, 0x03B1, 0x03C1, 0x03C3, 0x03C9, 0x0401, 0x0401, 0x0410, 0x044F, 0x0451, 0x0451,
0x2000, 0x206F, 0x2103, 0x2103, 0x212B, 0x212B, 0x2190, 0x2193, 0x21D2, 0x21D2, 0x21D4, 0x21D4, 0x2200, 0x2200, 0x2202, 0x2203,
0x2207, 0x2208, 0x220B, 0x220B, 0x2212, 0x2212, 0x221A, 0x221A, 0x221D, 0x221E, 0x2220, 0x2220, 0x2227, 0x222C, 0x2234, 0x2235,
@ -524,5 +524,5 @@ public static class GlyphRangesJapanese
0x9F4E, 0x9F4F, 0x9F52, 0x9F52, 0x9F54, 0x9F54, 0x9F5F, 0x9F63, 0x9F66, 0x9F67, 0x9F6A, 0x9F6A, 0x9F6C, 0x9F6C, 0x9F72, 0x9F72,
0x9F76, 0x9F77, 0x9F8D, 0x9F8D, 0x9F95, 0x9F95, 0x9F9C, 0x9F9D, 0x9FA0, 0x9FA0, 0xFF01, 0xFF01, 0xFF03, 0xFF06, 0xFF08, 0xFF0C,
0xFF0E, 0xFF3B, 0xFF3D, 0xFF5D, 0xFF61, 0xFF9F, 0xFFE3, 0xFFE3, 0xFFE5, 0xFFE5, 0xFFFF, 0xFFFF, 0,
};
];
}

View file

@ -12,7 +12,7 @@ public partial class FileDialog
private static string BytesToString(long byteCount)
{
string[] suf = { " B", " KB", " MB", " GB", " TB" };
string[] suf = [" B", " KB", " MB", " GB", " TB"];
if (byteCount == 0)
return "0" + suf[0];
var bytes = Math.Abs(byteCount);

View file

@ -123,14 +123,14 @@ public partial class FileDialog
if (iconMap == null)
{
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);
AddToIconMap(new[] { "cs", "json", "cpp", "h", "py", "xml", "yaml", "js", "html", "css", "ts", "java" }, FontAwesomeIcon.FileCode, codeTextColor);
AddToIconMap(new[] { "txt", "md" }, FontAwesomeIcon.FileAlt, standardTextColor);
AddToIconMap(new[] { "zip", "7z", "gz", "tar" }, FontAwesomeIcon.FileArchive, miscTextColor);
AddToIconMap(new[] { "mp3", "m4a", "ogg", "wav" }, FontAwesomeIcon.FileAudio, miscTextColor);
AddToIconMap(new[] { "csv" }, FontAwesomeIcon.FileCsv, miscTextColor);
AddToIconMap(["mp4", "gif", "mov", "avi"], FontAwesomeIcon.FileVideo, miscTextColor);
AddToIconMap(["pdf"], FontAwesomeIcon.FilePdf, miscTextColor);
AddToIconMap(["png", "jpg", "jpeg", "tiff"], FontAwesomeIcon.FileImage, imageTextColor);
AddToIconMap(["cs", "json", "cpp", "h", "py", "xml", "yaml", "js", "html", "css", "ts", "java"], FontAwesomeIcon.FileCode, codeTextColor);
AddToIconMap(["txt", "md"], FontAwesomeIcon.FileAlt, standardTextColor);
AddToIconMap(["zip", "7z", "gz", "tar"], FontAwesomeIcon.FileArchive, miscTextColor);
AddToIconMap(["mp3", "m4a", "ogg", "wav"], FontAwesomeIcon.FileAudio, miscTextColor);
AddToIconMap(["csv"], FontAwesomeIcon.FileCsv, miscTextColor);
}
return iconMap.TryGetValue(ext.ToLowerInvariant(), out var icon) ? icon : new IconColorItem

View file

@ -34,7 +34,7 @@ public sealed class SingleFontChooserDialog : IDisposable
private static readonly List<IFontId> EmptyIFontList = [];
private static readonly (string Name, float Value)[] FontSizeList =
{
[
("9.6", 9.6f),
("10", 10f),
("12", 12f),
@ -51,7 +51,7 @@ public sealed class SingleFontChooserDialog : IDisposable
("46", 46),
("68", 68),
("90", 90),
};
];
private static int counterStatic;

View file

@ -25,8 +25,8 @@ internal unsafe class UiDebug
private const int UnitListCount = 18;
private readonly bool[] selectedInList = new bool[UnitListCount];
private readonly string[] listNames = new string[UnitListCount]
{
private readonly string[] listNames =
[
"Depth Layer 1",
"Depth Layer 2",
"Depth Layer 3",
@ -45,7 +45,7 @@ internal unsafe class UiDebug
"Units 16",
"Units 17",
"Units 18",
};
];
private bool doingSearch;
private string searchInput = string.Empty;

View file

@ -19,14 +19,14 @@ internal sealed class ComponentDemoWindow : Window
private static readonly TimeSpan DefaultEasingTime = new(0, 0, 0, 1700);
private readonly List<(string Name, Action Demo)> componentDemos;
private readonly IReadOnlyList<Easing> easings = new Easing[]
{
private readonly IReadOnlyList<Easing> easings =
[
new InSine(DefaultEasingTime), new OutSine(DefaultEasingTime), new InOutSine(DefaultEasingTime),
new InCubic(DefaultEasingTime), new OutCubic(DefaultEasingTime), new InOutCubic(DefaultEasingTime),
new InQuint(DefaultEasingTime), new OutQuint(DefaultEasingTime), new InOutQuint(DefaultEasingTime),
new InCirc(DefaultEasingTime), new OutCirc(DefaultEasingTime), new InOutCirc(DefaultEasingTime),
new InElastic(DefaultEasingTime), new OutElastic(DefaultEasingTime), new InOutElastic(DefaultEasingTime),
};
];
private int animationTimeMs = (int)DefaultEasingTime.TotalMilliseconds;
private Vector4 defaultColor = ImGuiColors.DalamudOrange;

View file

@ -18,7 +18,7 @@ namespace Dalamud.Interface.Internal.Windows.Data;
internal class DataWindow : Window, IDisposable
{
private readonly IDataWindowWidget[] modules =
{
[
new AddonInspectorWidget(),
new AddonInspectorWidget2(),
new AddonLifecycleWidget(),
@ -62,7 +62,7 @@ internal class DataWindow : Window, IDisposable
new UiColorWidget(),
new UldWidget(),
new VfsWidget(),
};
];
private readonly IOrderedEnumerable<IDataWindowWidget> orderedModules;

View file

@ -24,7 +24,7 @@ internal class GameInventoryTestWidget : IDataWindowWidget
private bool rawEnabled;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "gameinventorytest" };
public string[]? CommandShortcuts { get; init; } = ["gameinventorytest"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "GameInventory Test";

View file

@ -8,7 +8,7 @@ internal class AddonInspectorWidget : IDataWindowWidget
private UiDebug? addonInspector;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "ai", "addoninspector" };
public string[]? CommandShortcuts { get; init; } = ["ai", "addoninspector"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Addon Inspector";

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Dalamud.Bindings.ImGui;
using Dalamud.Game;
@ -15,7 +15,7 @@ internal class AddressesWidget : IDataWindowWidget
private nint sigResult = nint.Zero;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "address" };
public string[]? CommandShortcuts { get; init; } = ["address"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Addresses";

View file

@ -12,7 +12,7 @@ internal class AetherytesWidget : IDataWindowWidget
public bool Ready { get; set; }
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "aetherytes" };
public string[]? CommandShortcuts { get; init; } = ["aetherytes"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Aetherytes";

View file

@ -32,7 +32,7 @@ internal unsafe class AtkArrayDataBrowserWidget : IDataWindowWidget
public bool Ready { get; set; }
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "atkarray" };
public string[]? CommandShortcuts { get; init; } = ["atkarray"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Atk Array Data";

View file

@ -15,7 +15,7 @@ internal class BuddyListWidget : IDataWindowWidget
public bool Ready { get; set; }
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "buddy", "buddylist" };
public string[]? CommandShortcuts { get; init; } = ["buddy", "buddylist"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Buddy List";

View file

@ -13,7 +13,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
internal class CommandWidget : IDataWindowWidget
{
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "command" };
public string[]? CommandShortcuts { get; init; } = ["command"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Command";

View file

@ -1,4 +1,4 @@
using Dalamud.Bindings.ImGui;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Utility;
@ -13,7 +13,7 @@ internal class ConditionWidget : IDataWindowWidget
public bool Ready { get; set; }
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "condition" };
public string[]? CommandShortcuts { get; init; } = ["condition"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Condition";

View file

@ -1,4 +1,4 @@
using Dalamud.Configuration.Internal;
using Dalamud.Configuration.Internal;
using Dalamud.Utility;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
@ -9,7 +9,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
internal class ConfigurationWidget : IDataWindowWidget
{
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "config", "configuration" };
public string[]? CommandShortcuts { get; init; } = ["config", "configuration"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Configuration";

View file

@ -34,7 +34,7 @@ internal class DataShareWidget : IDataWindowWidget
private List<CallGateChannel>? gatesSorted;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "datashare" };
public string[]? CommandShortcuts { get; init; } = ["datashare"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Data Share & Call Gate";

View file

@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using System.Threading;
using Dalamud.Bindings.ImGui;
@ -21,7 +21,7 @@ internal class DtrBarWidget : IDataWindowWidget, IDisposable
private CancellationTokenSource? loadTestThreadCt;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "dtr", "dtrbar" };
public string[]? CommandShortcuts { get; init; } = ["dtr", "dtrbar"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "DTR Bar";

View file

@ -12,7 +12,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
internal class FateTableWidget : IDataWindowWidget
{
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "fate", "fatetable" };
public string[]? CommandShortcuts { get; init; } = ["fate", "fatetable"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Fate Table";

View file

@ -22,7 +22,7 @@ internal class FlyTextWidget : IDataWindowWidget
private Vector4 flyColor = new(1, 0, 0, 1);
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "flytext" };
public string[]? CommandShortcuts { get; init; } = ["flytext"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Fly Text";

View file

@ -21,7 +21,7 @@ internal class FontAwesomeTestWidget : IDataWindowWidget
private bool useFixedWidth = false;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "fa", "fatest", "fontawesome" };
public string[]? CommandShortcuts { get; init; } = ["fa", "fatest", "fontawesome"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Font Awesome Test";

View file

@ -25,11 +25,11 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
internal class GamePrebakedFontsTestWidget : IDataWindowWidget, IDisposable
{
private static readonly string[] FontScaleModes =
{
[
nameof(FontScaleMode.Default),
nameof(FontScaleMode.SkipHandling),
nameof(FontScaleMode.UndoGlobalScale),
};
];
private ImVectorWrapper<byte> testStringBuffer;
private IFontAtlas? privateAtlas;

View file

@ -1,4 +1,4 @@
using Dalamud.Bindings.ImGui;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.ClientState.GamePad;
using Dalamud.Utility;
@ -10,7 +10,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
internal class GamepadWidget : IDataWindowWidget
{
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "gamepad", "controller" };
public string[]? CommandShortcuts { get; init; } = ["gamepad", "controller"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Gamepad";

View file

@ -12,7 +12,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
internal class GaugeWidget : IDataWindowWidget
{
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "gauge", "jobgauge", "job" };
public string[]? CommandShortcuts { get; init; } = ["gauge", "jobgauge", "job"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Job Gauge";

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
@ -55,7 +55,7 @@ internal unsafe class HookWidget : IDataWindowWidget
public string DisplayName { get; init; } = "Hook";
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "hook" };
public string[]? CommandShortcuts { get; init; } = ["hook"];
/// <inheritdoc/>
public bool Ready { get; set; }

View file

@ -33,7 +33,7 @@ public class IconBrowserWidget : IDataWindowWidget
private Vector2 lastWindowSize = Vector2.Zero;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "icon", "icons" };
public string[]? CommandShortcuts { get; init; } = ["icon", "icons"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Icon Browser";

View file

@ -23,7 +23,7 @@ internal class ImGuiWidget : IDataWindowWidget
private NotificationTemplate notificationTemplate;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "imgui" };
public string[]? CommandShortcuts { get; init; } = ["imgui"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "ImGui";
@ -334,7 +334,7 @@ internal class ImGuiWidget : IDataWindowWidget
private struct NotificationTemplate
{
public static readonly string[] IconTitles =
{
[
"None (use Type)",
"SeIconChar",
"FontAwesomeIcon",
@ -344,7 +344,7 @@ internal class ImGuiWidget : IDataWindowWidget
"TextureWrap from DalamudAssets(Async)",
"TextureWrap from GamePath",
"TextureWrap from FilePath",
};
];
public static readonly string[] AssetSources =
Enum.GetValues<DalamudAsset>()
@ -353,46 +353,46 @@ internal class ImGuiWidget : IDataWindowWidget
.ToArray();
public static readonly string[] ProgressModeTitles =
{
[
"Default",
"Random",
"Increasing",
"Increasing & Auto Dismiss",
"Indeterminate",
};
];
public static readonly string[] TypeTitles =
{
[
nameof(NotificationType.None),
nameof(NotificationType.Success),
nameof(NotificationType.Warning),
nameof(NotificationType.Error),
nameof(NotificationType.Info),
};
];
public static readonly string[] InitialDurationTitles =
{
[
"Infinite",
"1 seconds",
"3 seconds (default)",
"10 seconds",
};
];
public static readonly string[] HoverExtendDurationTitles =
{
[
"Disable",
"1 seconds",
"3 seconds (default)",
"10 seconds",
};
];
public static readonly TimeSpan[] Durations =
{
[
TimeSpan.Zero,
TimeSpan.FromSeconds(1),
NotificationConstants.DefaultDuration,
TimeSpan.FromSeconds(10),
};
];
public bool ManualContent;
public string Content;

View file

@ -1,4 +1,4 @@
using Dalamud.Bindings.ImGui;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.ClientState.Keys;
using Dalamud.Interface.Colors;
@ -10,7 +10,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
internal class KeyStateWidget : IDataWindowWidget
{
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "keystate" };
public string[]? CommandShortcuts { get; init; } = ["keystate"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "KeyState";

View file

@ -1,4 +1,4 @@
using System.Collections.Concurrent;
using System.Collections.Concurrent;
using System.Globalization;
using Dalamud.Bindings.ImGui;
@ -44,7 +44,7 @@ internal class MarketBoardWidget : IDataWindowWidget
}
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "marketboard" };
public string[]? CommandShortcuts { get; init; } = ["marketboard"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Market Board";

View file

@ -42,7 +42,7 @@ internal class NetworkMonitorWidget : IDataWindowWidget
}
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "network", "netmon", "networkmonitor" };
public string[]? CommandShortcuts { get; init; } = ["network", "netmon", "networkmonitor"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Network Monitor";

View file

@ -60,7 +60,7 @@ internal class NounProcessorWidget : IDataWindowWidget
private int amount = 1;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "noun" };
public string[]? CommandShortcuts { get; init; } = ["noun"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Noun Processor";

View file

@ -19,7 +19,7 @@ internal class ObjectTableWidget : IDataWindowWidget
private float maxCharaDrawDistance = 20.0f;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "ot", "objecttable" };
public string[]? CommandShortcuts { get; init; } = ["ot", "objecttable"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Object Table";

View file

@ -1,4 +1,4 @@
using Dalamud.Bindings.ImGui;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.ClientState.Party;
using Dalamud.Utility;
@ -12,7 +12,7 @@ internal class PartyListWidget : IDataWindowWidget
private bool resolveGameData;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "partylist", "party" };
public string[]? CommandShortcuts { get; init; } = ["partylist", "party"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Party List";

View file

@ -25,7 +25,7 @@ internal class PluginIpcWidget : IDataWindowWidget
private string callGateResponse = string.Empty;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "ipc" };
public string[]? CommandShortcuts { get; init; } = ["ipc"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Plugin IPC";

View file

@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.Text;
@ -11,7 +11,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
internal class SeFontTestWidget : IDataWindowWidget
{
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "sefont", "sefonttest" };
public string[]? CommandShortcuts { get; init; } = ["sefont", "sefonttest"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "SeFont Test";

View file

@ -24,7 +24,7 @@ internal class ServicesWidget : IDataWindowWidget
private List<List<ServiceDependencyNode>>? dependencyNodes;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "services" };
public string[]? CommandShortcuts { get; init; } = ["services"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Service Container";

View file

@ -1,4 +1,4 @@
using Dalamud.Bindings.ImGui;
using Dalamud.Bindings.ImGui;
using Newtonsoft.Json;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
@ -9,7 +9,7 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
internal class StartInfoWidget : IDataWindowWidget
{
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "startinfo" };
public string[]? CommandShortcuts { get; init; } = ["startinfo"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Start Info";

View file

@ -14,7 +14,7 @@ internal class TargetWidget : IDataWindowWidget
private bool resolveGameData;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "target" };
public string[]? CommandShortcuts { get; init; } = ["target"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Target";

View file

@ -35,7 +35,7 @@ internal class TaskSchedulerWidget : IDataWindowWidget
private CancellationTokenSource taskSchedulerCancelSource = new();
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "tasksched", "taskscheduler" };
public string[]? CommandShortcuts { get; init; } = ["tasksched", "taskscheduler"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Task Scheduler";

View file

@ -83,7 +83,7 @@ internal class TexWidget : IDataWindowWidget
}
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "tex", "texture" };
public string[]? CommandShortcuts { get; init; } = ["tex", "texture"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Tex";
@ -605,7 +605,7 @@ internal class TexWidget : IDataWindowWidget
ImGui.SameLine();
if (ImGuiComponents.IconButton(FontAwesomeIcon.Sync))
this.textureManager.InvalidatePaths(new[] { texture.SourcePathForDebug });
this.textureManager.InvalidatePaths([texture.SourcePathForDebug]);
if (ImGui.IsItemHovered())
ImGui.SetTooltip($"Call {nameof(ITextureSubstitutionProvider.InvalidatePaths)}.");

View file

@ -20,7 +20,7 @@ internal class ToastWidget : IDataWindowWidget
private bool questToastCheckmark;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "toast" };
public string[]? CommandShortcuts { get; init; } = ["toast"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "Toast";

View file

@ -17,7 +17,7 @@ internal class VfsWidget : IDataWindowWidget
private int reps = 1;
/// <inheritdoc/>
public string[]? CommandShortcuts { get; init; } = { "vfs" };
public string[]? CommandShortcuts { get; init; } = ["vfs"];
/// <inheritdoc/>
public string DisplayName { get; init; } = "VFS Performance";

View file

@ -144,7 +144,7 @@ internal class PluginImageCache : IInternalDisposableService
this.downloadQueue.CompleteAdding();
this.loadQueue.CompleteAdding();
if (!Task.WaitAll(new[] { this.loadTask, this.downloadTask }, 4000))
if (!Task.WaitAll([this.loadTask, this.downloadTask], 4000))
{
Log.Error("Plugin Image download/load thread has not cancelled in time");
}

View file

@ -2361,7 +2361,7 @@ internal class PluginInstallerWindow : Window, IDisposable
else if (!string.IsNullOrWhiteSpace(manifest.Description))
{
const int punchlineLen = 200;
var firstLine = manifest.Description.Split(new[] { '\r', '\n' })[0];
var firstLine = manifest.Description.Split(['\r', '\n'])[0];
ImGui.TextWrapped(firstLine.Length < punchlineLen
? firstLine

View file

@ -170,7 +170,7 @@ internal sealed partial class FontAtlasFactory
};
if (fontConfig.GlyphRanges is not { Length: > 0 } ranges)
ranges = new ushort[] { 1, 0xFFFE, 0 };
ranges = [1, 0xFFFE, 0];
raw.GlyphRanges = (ushort*)this.DisposeAfterBuild(
GCHandle.Alloc(ranges, GCHandleType.Pinned)).AddrOfPinnedObject();
@ -382,7 +382,7 @@ internal sealed partial class FontAtlasFactory
DalamudAsset.FontAwesomeFreeSolid,
fontConfig with
{
GlyphRanges = new ushort[] { FontAwesomeIconMin, FontAwesomeIconMax, 0 },
GlyphRanges = [FontAwesomeIconMin, FontAwesomeIconMax, 0],
});
/// <inheritdoc/>
@ -391,12 +391,12 @@ internal sealed partial class FontAtlasFactory
DalamudAsset.LodestoneGameSymbol,
fontConfig with
{
GlyphRanges = new ushort[]
{
GlyphRanges =
[
GamePrebakedFontHandle.SeIconCharMin,
GamePrebakedFontHandle.SeIconCharMax,
0,
},
],
});
/// <inheritdoc/>
@ -629,7 +629,7 @@ internal sealed partial class FontAtlasFactory
{
this.AddDalamudAssetFont(
DalamudAsset.NotoSansJpMedium,
new() { GlyphRanges = new ushort[] { ' ', ' ', '\0' }, SizePx = 1 });
new() { GlyphRanges = [' ', ' ', '\0'], SizePx = 1 });
}
if (!this.NewImAtlas.Build())

View file

@ -290,13 +290,13 @@ internal sealed partial class FontAtlasFactory
this.factory.InterfaceManager.AfterBuildFonts += this.OnRebuildRecommend;
this.disposables.Add(() => this.factory.InterfaceManager.AfterBuildFonts -= this.OnRebuildRecommend);
this.fontHandleManagers = new IFontHandleManager[]
{
this.fontHandleManagers =
[
this.delegateFontHandleManager = this.disposables.Add(
new DelegateFontHandle.HandleManager(atlasName)),
this.gameFontHandleManager = this.disposables.Add(
new GamePrebakedFontHandle.HandleManager(atlasName, factory)),
};
];
foreach (var fhm in this.fontHandleManagers)
fhm.RebuildRecommend += this.OnRebuildRecommend;
}

View file

@ -417,7 +417,7 @@ internal class GamePrebakedFontHandle : FontHandle
DalamudAsset.NotoSansJpMedium,
new()
{
GlyphRanges = new ushort[] { ' ', ' ', '\0' },
GlyphRanges = [' ', ' ', '\0'],
SizePx = sizePx,
});
this.templatedFonts.Add(font);

View file

@ -381,10 +381,10 @@ internal sealed partial class TextureManager
var tf = new TexFile();
typeof(TexFile).GetProperty(nameof(tf.Data))!.GetSetMethod(true)!.Invoke(
tf,
new object?[] { bytesArray });
[bytesArray]);
typeof(TexFile).GetProperty(nameof(tf.Reader))!.GetSetMethod(true)!.Invoke(
tf,
new object?[] { new LuminaBinaryReader(bytesArray) });
[new LuminaBinaryReader(bytesArray)]);
// Note: FileInfo and FilePath are not used from TexFile; skip it.
var wrap = this.NoThrottleCreateFromTexFile(tf);

View file

@ -18,7 +18,7 @@ public class Localization : IServiceType
/// <summary>
/// Array of language codes which have a valid translation in Dalamud.
/// </summary>
public static readonly string[] ApplicableLangCodes = { "de", "ja", "fr", "it", "es", "ko", "no", "ru", "zh", "tw" };
public static readonly string[] ApplicableLangCodes = ["de", "ja", "fr", "it", "es", "ko", "no", "ru", "zh", "tw"];
private const string FallbackLangCode = "en";

View file

@ -347,7 +347,7 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa
{
var mi = this.configs.GetType().GetMethod("LoadForType");
var fn = mi.MakeGenericMethod(type);
return (IPluginConfiguration)fn.Invoke(this.configs, new object[] { this.plugin.InternalName });
return (IPluginConfiguration)fn.Invoke(this.configs, [this.plugin.InternalName]);
}
}

View file

@ -140,7 +140,7 @@ internal class AssemblyLoadContextBuilder
return this;
}
var names = new Queue<AssemblyName>(new[] { assemblyName });
var names = new Queue<AssemblyName>([assemblyName]);
while (names.TryDequeue(out var name))
{

View file

@ -11,21 +11,21 @@ internal class PlatformInformation
/// <summary>
/// Gets a list of native OS specific library extensions.
/// </summary>
public static string[] NativeLibraryExtensions => new[] { ".dll" };
public static string[] NativeLibraryExtensions => [".dll"];
/// <summary>
/// Gets a list of native OS specific library prefixes.
/// </summary>
public static string[] NativeLibraryPrefixes => new[] { string.Empty };
public static string[] NativeLibraryPrefixes => [string.Empty];
/// <summary>
/// Gets a list of native OS specific managed assembly extensions.
/// </summary>
public static string[] ManagedAssemblyExtensions => new[]
{
public static string[] ManagedAssemblyExtensions =>
[
".dll",
".ni.dll",
".exe",
".ni.exe",
};
];
}

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Game.Command;
@ -11,7 +11,7 @@ namespace Dalamud.Plugin.Internal;
/// </summary>
internal static class PluginValidator
{
private static readonly char[] LineSeparator = new[] { ' ', '\n', '\r' };
private static readonly char[] LineSeparator = [' ', '\n', '\r'];
/// <summary>
/// Represents the severity of a validation problem.

View file

@ -55,7 +55,7 @@ public abstract class ProfileModel
// HACK: Just filter the ID for now, we should split the sharing + saving model
var serialized = JsonConvert.SerializeObject(this, new JsonSerializerSettings()
{ ContractResolver = new IgnorePropertiesResolver(new[] { "WorkingPluginId" }) });
{ ContractResolver = new IgnorePropertiesResolver(["WorkingPluginId"]) });
return prefix + Convert.ToBase64String(Util.CompressString(serialized));
}

View file

@ -367,7 +367,7 @@ internal static class ServiceManager
BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic,
null,
null,
new object[] { startLoaderArgs }));
[startLoaderArgs]));
servicesToLoad.Remove(serviceType);
#if DEBUG

View file

@ -457,7 +457,7 @@ internal static class ServiceHelpers
BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public,
null,
null,
new object?[] { includeUnloadDependencies }) ?? new List<Type>();
[includeUnloadDependencies]) ?? new List<Type>();
}
/// <summary>

View file

@ -32,7 +32,7 @@ public static class Troubleshooting
{
LastException = exception;
var fixedContext = context?.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
var fixedContext = context?.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
try
{

View file

@ -92,7 +92,7 @@ public static class DisposeSafety
new AggregateException(
new[] { e }.Concat(
(IEnumerable<Exception>)r.Exception?.InnerExceptions
?? new[] { new OperationCanceledException() })));
?? [new OperationCanceledException()])));
}
}

View file

@ -159,7 +159,7 @@ internal static class SignatureHelper
continue;
}
var hook = creator.Invoke(null, new object?[] { ptr, detour, false }) as IDalamudHook;
var hook = creator.Invoke(null, [ptr, detour, false]) as IDalamudHook;
info.SetValue(self, hook);
createdHooks.Add(hook);

View file

@ -453,7 +453,7 @@ public static partial class Util
/// <returns>Human readable version.</returns>
public static string FormatBytes(long bytes)
{
string[] suffix = { "B", "KB", "MB", "GB", "TB" };
string[] suffix = ["B", "KB", "MB", "GB", "TB"];
int i;
double dblSByte = bytes;
for (i = 0; i < suffix.Length && bytes >= 1024; i++, bytes /= 1024)
@ -910,7 +910,7 @@ public static partial class Util
MethodAttributes.Public | MethodAttributes.Static,
CallingConventions.Standard,
null,
new[] { typeof(object), typeof(IList<string>), typeof(ulong) },
[typeof(object), typeof(IList<string>), typeof(ulong)],
obj.GetType(),
true);
@ -937,7 +937,7 @@ public static partial class Util
ilg.Emit(OpCodes.Call, mm);
ilg.Emit(OpCodes.Ret);
dm.Invoke(null, new[] { obj, path, addr });
dm.Invoke(null, [obj, path, addr]);
}
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type