misc: chore: Use collection expressions

This commit is contained in:
KeatonTheBot
2025-03-06 20:46:29 -06:00
parent 4d5757417e
commit e2973a875a
236 changed files with 9843 additions and 7561 deletions
@@ -822,8 +822,8 @@ namespace Ryujinx.UI.Common.Configuration
EnableKeyboard = Hid.EnableKeyboard,
EnableMouse = Hid.EnableMouse,
Hotkeys = Hid.Hotkeys,
KeyboardConfig = new List<JsonObject>(),
ControllerConfig = new List<JsonObject>(),
KeyboardConfig = [],
ControllerConfig = [],
InputConfig = Hid.InputConfig,
GraphicsBackend = Graphics.GraphicsBackend,
PreferredGpu = Graphics.PreferredGpu,
@@ -856,7 +856,7 @@ namespace Ryujinx.UI.Common.Configuration
Logger.EnableTrace.Value = false;
Logger.EnableGuest.Value = true;
Logger.EnableFsAccessLog.Value = false;
Logger.FilteredClasses.Value = Array.Empty<LogClass>();
Logger.FilteredClasses.Value = [];
Logger.GraphicsDebugLevel.Value = GraphicsDebugLevel.None;
System.Language.Value = Language.AmericanEnglish;
System.Region.Value = Region.USA;
@@ -907,8 +907,8 @@ namespace Ryujinx.UI.Common.Configuration
UI.GuiColumns.PathColumn.Value = true;
UI.ColumnSort.SortColumnId.Value = 0;
UI.ColumnSort.SortAscending.Value = false;
UI.GameDirs.Value = new List<string>();
UI.AutoloadDirs.Value = new List<string>();
UI.GameDirs.Value = [];
UI.AutoloadDirs.Value = [];
UI.ShownFileTypes.NSP.Value = true;
UI.ShownFileTypes.PFS0.Value = true;
UI.ShownFileTypes.XCI.Value = true;
@@ -945,8 +945,8 @@ namespace Ryujinx.UI.Common.Configuration
VolumeUp = Key.Unbound,
VolumeDown = Key.Unbound,
};
Hid.InputConfig.Value = new List<InputConfig>
{
Hid.InputConfig.Value =
[
new StandardKeyboardInputConfig
{
Version = InputConfig.CurrentVersion,
@@ -994,8 +994,9 @@ namespace Ryujinx.UI.Common.Configuration
StickRight = Key.L,
StickButton = Key.H,
},
},
};
}
];
}
public void Load(ConfigurationFileFormat configurationFileFormat, string configurationFilePath)
@@ -1174,8 +1175,8 @@ namespace Ryujinx.UI.Common.Configuration
{
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 24.");
configurationFileFormat.InputConfig = new List<InputConfig>
{
configurationFileFormat.InputConfig =
[
new StandardKeyboardInputConfig
{
Version = InputConfig.CurrentVersion,
@@ -1223,8 +1224,9 @@ namespace Ryujinx.UI.Common.Configuration
StickRight = Key.L,
StickButton = Key.H,
},
},
};
}
];
configurationFileUpdated = true;
}
@@ -1554,7 +1556,7 @@ namespace Ryujinx.UI.Common.Configuration
{
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 52.");
configurationFileFormat.AutoloadDirs = new();
configurationFileFormat.AutoloadDirs = [];
configurationFileUpdated = true;
}
@@ -1708,7 +1710,7 @@ namespace Ryujinx.UI.Common.Configuration
if (Hid.InputConfig.Value == null)
{
Hid.InputConfig.Value = new List<InputConfig>();
Hid.InputConfig.Value = [];
}
Multiplayer.LanInterfaceId.Value = configurationFileFormat.MultiplayerLanInterfaceId;
@@ -12,7 +12,7 @@ namespace Ryujinx.UI.Common.Helper
{
public static partial class FileAssociationHelper
{
private static readonly string[] _fileExtensions = { ".nca", ".nro", ".nso", ".nsp", ".xci" };
private static readonly string[] _fileExtensions = [".nca", ".nro", ".nso", ".nsp", ".xci"];
[SupportedOSPlatform("linux")]
private static readonly string _mimeDbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share", "mime");
@@ -152,7 +152,7 @@ namespace Ryujinx.UI.Common.Helper
private static void SaveBitmapAsIcon(SKBitmap source, string filePath)
{
// Code Modified From https://stackoverflow.com/a/11448060/368354 by Benlitz
byte[] header = { 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 32, 0, 0, 0, 0, 0, 22, 0, 0, 0 };
byte[] header = [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 32, 0, 0, 0, 0, 0, 22, 0, 0, 0];
using FileStream fs = new(filePath, FileMode.Create);
fs.Write(header);
@@ -7,10 +7,10 @@ namespace Ryujinx.UI.Common.Helper
public static class ValueFormatUtils
{
private static readonly string[] _fileSizeUnitStrings =
{
[
"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", // Base 10 units, used for formatting and parsing
"KB", "MB", "GB", "TB", "PB", "EB", // Base 2 units, used for parsing legacy values
};
"KB", "MB", "GB", "TB", "PB", "EB" // Base 2 units, used for parsing legacy values
];
/// <summary>
/// Used by <see cref="FormatFileSize"/>.