misc: chore: Use collection expressions in Avalonia project

This commit is contained in:
Evan Husted 2025-01-26 15:47:11 -06:00
parent 46a5cafaa8
commit ae90db2040
28 changed files with 114 additions and 112 deletions

View file

@ -975,13 +975,13 @@ namespace Ryujinx.Ava
private static IHardwareDeviceDriver InitializeAudio() private static IHardwareDeviceDriver InitializeAudio()
{ {
List<AudioBackend> availableBackends = new() List<AudioBackend> availableBackends =
{ [
AudioBackend.SDL2, AudioBackend.SDL2,
AudioBackend.SoundIo, AudioBackend.SoundIo,
AudioBackend.OpenAl, AudioBackend.OpenAl,
AudioBackend.Dummy, AudioBackend.Dummy
}; ];
AudioBackend preferredBackend = ConfigurationState.Instance.System.AudioBackend.Value; AudioBackend preferredBackend = ConfigurationState.Instance.System.AudioBackend.Value;

View file

@ -11,7 +11,7 @@ namespace Ryujinx.Ava.Input
{ {
internal class AvaloniaKeyboardDriver : IGamepadDriver internal class AvaloniaKeyboardDriver : IGamepadDriver
{ {
private static readonly string[] _keyboardIdentifers = new string[1] { "0" }; private static readonly string[] _keyboardIdentifers = ["0"];
private readonly Control _control; private readonly Control _control;
private readonly HashSet<AvaKey> _pressedKeys; private readonly HashSet<AvaKey> _pressedKeys;
@ -25,7 +25,7 @@ namespace Ryujinx.Ava.Input
public AvaloniaKeyboardDriver(Control control) public AvaloniaKeyboardDriver(Control control)
{ {
_control = control; _control = control;
_pressedKeys = new HashSet<AvaKey>(); _pressedKeys = [];
_control.KeyDown += OnKeyPress; _control.KeyDown += OnKeyPress;
_control.KeyUp += OnKeyRelease; _control.KeyUp += OnKeyRelease;

View file

@ -7,7 +7,8 @@ namespace Ryujinx.Ava.Input
{ {
internal static class AvaloniaKeyboardMappingHelper internal static class AvaloniaKeyboardMappingHelper
{ {
private static readonly AvaKey[] _keyMapping = { private static readonly AvaKey[] _keyMapping =
[
// NOTE: Invalid // NOTE: Invalid
AvaKey.None, AvaKey.None,
@ -143,8 +144,8 @@ namespace Ryujinx.Ava.Input
AvaKey.OemBackslash, AvaKey.OemBackslash,
// NOTE: invalid // NOTE: invalid
AvaKey.None, AvaKey.None
}; ];
private static readonly Dictionary<AvaKey, Key> _avaKeyMapping; private static readonly Dictionary<AvaKey, Key> _avaKeyMapping;

View file

@ -146,7 +146,7 @@ namespace Ryujinx.Ava.UI.Controls
DirectoryInfo mainDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "cpu", "0")); DirectoryInfo mainDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "cpu", "0"));
DirectoryInfo backupDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "cpu", "1")); DirectoryInfo backupDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "cpu", "1"));
List<FileInfo> cacheFiles = new(); List<FileInfo> cacheFiles = [];
if (mainDir.Exists) if (mainDir.Exists)
{ {
@ -189,8 +189,8 @@ namespace Ryujinx.Ava.UI.Controls
{ {
DirectoryInfo shaderCacheDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "shader")); DirectoryInfo shaderCacheDir = new(Path.Combine(AppDataManager.GamesDirPath, viewModel.SelectedApplication.IdString, "cache", "shader"));
List<DirectoryInfo> oldCacheDirectories = new(); List<DirectoryInfo> oldCacheDirectories = [];
List<FileInfo> newCacheFiles = new(); List<FileInfo> newCacheFiles = [];
if (shaderCacheDir.Exists) if (shaderCacheDir.Exists)
{ {

View file

@ -114,7 +114,7 @@ namespace Ryujinx.Ava.UI.Controls
Span<SaveDataInfo> saveDataInfo = stackalloc SaveDataInfo[10]; Span<SaveDataInfo> saveDataInfo = stackalloc SaveDataInfo[10];
HashSet<UserId> lostAccounts = new(); HashSet<UserId> lostAccounts = [];
while (true) while (true)
{ {

View file

@ -8,7 +8,7 @@ namespace Ryujinx.Ava.UI.Models
public class CheatNode : BaseModel public class CheatNode : BaseModel
{ {
private bool _isEnabled = false; private bool _isEnabled = false;
public ObservableCollection<CheatNode> SubNodes { get; } = new(); public ObservableCollection<CheatNode> SubNodes { get; } = [];
public string CleanName => Name[1..^7]; public string CleanName => Name[1..^7];
public string BuildIdKey => $"{BuildId}-{Name}"; public string BuildIdKey => $"{BuildId}-{Name}";
public bool IsRootNode { get; } public bool IsRootNode { get; }

View file

@ -64,9 +64,9 @@ namespace Ryujinx.Ava.UI.ViewModels
Directory.CreateDirectory(Path.Join(AppDataManager.BaseDirPath, "system", "amiibo")); Directory.CreateDirectory(Path.Join(AppDataManager.BaseDirPath, "system", "amiibo"));
_amiiboJsonPath = Path.Join(AppDataManager.BaseDirPath, "system", "amiibo", "Amiibo.json"); _amiiboJsonPath = Path.Join(AppDataManager.BaseDirPath, "system", "amiibo", "Amiibo.json");
_amiiboList = new List<AmiiboApi>(); _amiiboList = [];
_amiiboSeries = new ObservableCollection<string>(); _amiiboSeries = [];
_amiibos = new AvaloniaList<AmiiboApi>(); _amiibos = [];
_amiiboLogoBytes = EmbeddedResources.Read("Ryujinx/Assets/UIImages/Logo_Amiibo.png"); _amiiboLogoBytes = EmbeddedResources.Read("Ryujinx/Assets/UIImages/Logo_Amiibo.png");

View file

@ -22,9 +22,9 @@ namespace Ryujinx.Ava.UI.ViewModels
public partial class DownloadableContentManagerViewModel : BaseModel public partial class DownloadableContentManagerViewModel : BaseModel
{ {
private readonly ApplicationLibrary _applicationLibrary; private readonly ApplicationLibrary _applicationLibrary;
private AvaloniaList<DownloadableContentModel> _downloadableContents = new(); private AvaloniaList<DownloadableContentModel> _downloadableContents = [];
[ObservableProperty] private AvaloniaList<DownloadableContentModel> _selectedDownloadableContents = new(); [ObservableProperty] private AvaloniaList<DownloadableContentModel> _selectedDownloadableContents = [];
[ObservableProperty] private AvaloniaList<DownloadableContentModel> _views = new(); [ObservableProperty] private AvaloniaList<DownloadableContentModel> _views = [];
[ObservableProperty] private bool _showBundledContentNotice = false; [ObservableProperty] private bool _showBundledContentNotice = false;
private string _search; private string _search;
@ -139,9 +139,9 @@ namespace Ryujinx.Ava.UI.ViewModels
{ {
new("NSP") new("NSP")
{ {
Patterns = new[] { "*.nsp" }, Patterns = ["*.nsp"],
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nsp" }, AppleUniformTypeIdentifiers = ["com.ryujinx.nsp"],
MimeTypes = new[] { "application/x-nx-nsp" }, MimeTypes = ["application/x-nx-nsp"],
}, },
}, },
}); });

View file

@ -257,11 +257,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
public InputViewModel() public InputViewModel()
{ {
PlayerIndexes = new ObservableCollection<PlayerModel>(); PlayerIndexes = [];
Controllers = new ObservableCollection<ControllerModel>(); Controllers = [];
Devices = new ObservableCollection<(DeviceType Type, string Id, string Name)>(); Devices = [];
ProfilesList = new AvaloniaList<string>(); ProfilesList = [];
DeviceList = new AvaloniaList<string>(); DeviceList = [];
ControllerImage = ProControllerResource; ControllerImage = ProControllerResource;
@ -810,7 +810,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
{ {
IsModified = false; IsModified = false;
List<InputConfig> newConfig = new(); List<InputConfig> newConfig = [];
newConfig.AddRange(ConfigurationState.Instance.Hid.InputConfig.Value); newConfig.AddRange(ConfigurationState.Instance.Hid.InputConfig.Value);

View file

@ -1245,21 +1245,21 @@ namespace Ryujinx.Ava.UI.ViewModels
{ {
new(LocaleManager.Instance[LocaleKeys.FileDialogAllTypes]) new(LocaleManager.Instance[LocaleKeys.FileDialogAllTypes])
{ {
Patterns = new[] { "*.xci", "*.zip" }, Patterns = ["*.xci", "*.zip"],
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci", "public.zip-archive" }, AppleUniformTypeIdentifiers = ["com.ryujinx.xci", "public.zip-archive"],
MimeTypes = new[] { "application/x-nx-xci", "application/zip" }, MimeTypes = ["application/x-nx-xci", "application/zip"],
}, },
new("XCI") new("XCI")
{ {
Patterns = new[] { "*.xci" }, Patterns = ["*.xci"],
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci" }, AppleUniformTypeIdentifiers = ["com.ryujinx.xci"],
MimeTypes = new[] { "application/x-nx-xci" }, MimeTypes = ["application/x-nx-xci"],
}, },
new("ZIP") new("ZIP")
{ {
Patterns = new[] { "*.zip" }, Patterns = ["*.zip"],
AppleUniformTypeIdentifiers = new[] { "public.zip-archive" }, AppleUniformTypeIdentifiers = ["public.zip-archive"],
MimeTypes = new[] { "application/zip" }, MimeTypes = ["application/zip"],
}, },
}, },
}); });
@ -1292,21 +1292,21 @@ namespace Ryujinx.Ava.UI.ViewModels
{ {
new(LocaleManager.Instance[LocaleKeys.FileDialogAllTypes]) new(LocaleManager.Instance[LocaleKeys.FileDialogAllTypes])
{ {
Patterns = new[] { "*.keys", "*.zip" }, Patterns = ["*.keys", "*.zip"],
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci", "public.zip-archive" }, AppleUniformTypeIdentifiers = ["com.ryujinx.xci", "public.zip-archive"],
MimeTypes = new[] { "application/keys", "application/zip" }, MimeTypes = ["application/keys", "application/zip"],
}, },
new("KEYS") new("KEYS")
{ {
Patterns = new[] { "*.keys" }, Patterns = ["*.keys"],
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci" }, AppleUniformTypeIdentifiers = ["com.ryujinx.xci"],
MimeTypes = new[] { "application/keys" }, MimeTypes = ["application/keys"],
}, },
new("ZIP") new("ZIP")
{ {
Patterns = new[] { "*.zip" }, Patterns = ["*.zip"],
AppleUniformTypeIdentifiers = new[] { "public.zip-archive" }, AppleUniformTypeIdentifiers = ["public.zip-archive"],
MimeTypes = new[] { "application/zip" }, MimeTypes = ["application/zip"],
}, },
}, },
}); });
@ -1418,53 +1418,53 @@ namespace Ryujinx.Ava.UI.ViewModels
{ {
new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats]) new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats])
{ {
Patterns = new[] { "*.nsp", "*.xci", "*.nca", "*.nro", "*.nso" }, Patterns = ["*.nsp", "*.xci", "*.nca", "*.nro", "*.nso"],
AppleUniformTypeIdentifiers = new[] AppleUniformTypeIdentifiers =
{ [
"com.ryujinx.nsp", "com.ryujinx.nsp",
"com.ryujinx.xci", "com.ryujinx.xci",
"com.ryujinx.nca", "com.ryujinx.nca",
"com.ryujinx.nro", "com.ryujinx.nro",
"com.ryujinx.nso", "com.ryujinx.nso"
}, ],
MimeTypes = new[] MimeTypes =
{ [
"application/x-nx-nsp", "application/x-nx-nsp",
"application/x-nx-xci", "application/x-nx-xci",
"application/x-nx-nca", "application/x-nx-nca",
"application/x-nx-nro", "application/x-nx-nro",
"application/x-nx-nso", "application/x-nx-nso"
}, ],
}, },
new("NSP") new("NSP")
{ {
Patterns = new[] { "*.nsp" }, Patterns = ["*.nsp"],
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nsp" }, AppleUniformTypeIdentifiers = ["com.ryujinx.nsp"],
MimeTypes = new[] { "application/x-nx-nsp" }, MimeTypes = ["application/x-nx-nsp"],
}, },
new("XCI") new("XCI")
{ {
Patterns = new[] { "*.xci" }, Patterns = ["*.xci"],
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xci" }, AppleUniformTypeIdentifiers = ["com.ryujinx.xci"],
MimeTypes = new[] { "application/x-nx-xci" }, MimeTypes = ["application/x-nx-xci"],
}, },
new("NCA") new("NCA")
{ {
Patterns = new[] { "*.nca" }, Patterns = ["*.nca"],
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nca" }, AppleUniformTypeIdentifiers = ["com.ryujinx.nca"],
MimeTypes = new[] { "application/x-nx-nca" }, MimeTypes = ["application/x-nx-nca"],
}, },
new("NRO") new("NRO")
{ {
Patterns = new[] { "*.nro" }, Patterns = ["*.nro"],
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nro" }, AppleUniformTypeIdentifiers = ["com.ryujinx.nro"],
MimeTypes = new[] { "application/x-nx-nro" }, MimeTypes = ["application/x-nx-nro"],
}, },
new("NSO") new("NSO")
{ {
Patterns = new[] { "*.nso" }, Patterns = ["*.nso"],
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nso" }, AppleUniformTypeIdentifiers = ["com.ryujinx.nso"],
MimeTypes = new[] { "application/x-nx-nso" }, MimeTypes = ["application/x-nx-nso"],
}, },
}, },
}); });
@ -1690,7 +1690,7 @@ namespace Ryujinx.Ava.UI.ViewModels
{ {
new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats]) new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats])
{ {
Patterns = new[] { "*.bin" }, Patterns = ["*.bin"],
} }
} }
}); });

View file

@ -23,9 +23,9 @@ namespace Ryujinx.Ava.UI.ViewModels
{ {
private readonly string _modJsonPath; private readonly string _modJsonPath;
private AvaloniaList<ModModel> _mods = new(); private AvaloniaList<ModModel> _mods = [];
[ObservableProperty] private AvaloniaList<ModModel> _views = new(); [ObservableProperty] private AvaloniaList<ModModel> _views = [];
[ObservableProperty] private AvaloniaList<ModModel> _selectedMods = new(); [ObservableProperty] private AvaloniaList<ModModel> _selectedMods = [];
private string _search; private string _search;
private readonly ulong _applicationId; private readonly ulong _applicationId;

View file

@ -51,7 +51,7 @@ namespace Ryujinx.Ava.UI.ViewModels
[ObservableProperty] private bool _isVulkanAvailable = true; [ObservableProperty] private bool _isVulkanAvailable = true;
[ObservableProperty] private bool _gameDirectoryChanged; [ObservableProperty] private bool _gameDirectoryChanged;
[ObservableProperty] private bool _autoloadDirectoryChanged; [ObservableProperty] private bool _autoloadDirectoryChanged;
private readonly List<string> _gpuIds = new(); private readonly List<string> _gpuIds = [];
private int _graphicsBackendIndex; private int _graphicsBackendIndex;
private int _scalingFilter; private int _scalingFilter;
private int _scalingFilterLevel; private int _scalingFilterLevel;

View file

@ -21,8 +21,8 @@ namespace Ryujinx.Ava.UI.ViewModels
private ApplicationLibrary ApplicationLibrary { get; } private ApplicationLibrary ApplicationLibrary { get; }
private ApplicationData ApplicationData { get; } private ApplicationData ApplicationData { get; }
[ObservableProperty] private AvaloniaList<TitleUpdateModel> _titleUpdates = new(); [ObservableProperty] private AvaloniaList<TitleUpdateModel> _titleUpdates = [];
[ObservableProperty] private AvaloniaList<object> _views = new(); [ObservableProperty] private AvaloniaList<object> _views = [];
[ObservableProperty] private object _selectedUpdate = new TitleUpdateViewModelNoUpdate(); [ObservableProperty] private object _selectedUpdate = new TitleUpdateViewModelNoUpdate();
[ObservableProperty] private bool _showBundledContentNotice; [ObservableProperty] private bool _showBundledContentNotice;
@ -149,9 +149,9 @@ namespace Ryujinx.Ava.UI.ViewModels
{ {
new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats]) new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats])
{ {
Patterns = new[] { "*.nsp" }, Patterns = ["*.nsp"],
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.nsp" }, AppleUniformTypeIdentifiers = ["com.ryujinx.nsp"],
MimeTypes = new[] { "application/x-nx-nsp" }, MimeTypes = ["application/x-nx-nsp"],
}, },
}, },
}); });

View file

@ -32,7 +32,7 @@ namespace Ryujinx.Ava.UI.ViewModels
public UserFirmwareAvatarSelectorViewModel() public UserFirmwareAvatarSelectorViewModel()
{ {
_images = new ObservableCollection<ProfileImageModel>(); _images = [];
LoadImagesFromStore(); LoadImagesFromStore();
PropertyChanged += (_, args) => PropertyChanged += (_, args) =>

View file

@ -9,8 +9,8 @@ namespace Ryujinx.Ava.UI.ViewModels
{ {
public UserProfileViewModel() public UserProfileViewModel()
{ {
Profiles = new ObservableCollection<BaseModel>(); Profiles = [];
LostProfiles = new ObservableCollection<UserProfile>(); LostProfiles = [];
IsEmpty = !LostProfiles.Any(); IsEmpty = !LostProfiles.Any();
} }

View file

@ -14,8 +14,8 @@ namespace Ryujinx.Ava.UI.ViewModels
[ObservableProperty] private int _sortIndex; [ObservableProperty] private int _sortIndex;
[ObservableProperty] private int _orderIndex; [ObservableProperty] private int _orderIndex;
[ObservableProperty] private string _search; [ObservableProperty] private string _search;
[ObservableProperty] private ObservableCollection<SaveModel> _saves = new(); [ObservableProperty] private ObservableCollection<SaveModel> _saves = [];
[ObservableProperty] private ObservableCollection<SaveModel> _views = new(); [ObservableProperty] private ObservableCollection<SaveModel> _views = [];
private readonly AccountManager _accountManager; private readonly AccountManager _accountManager;
public string SaveManagerHeading => LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.SaveManagerHeading, _accountManager.LastOpenedUser.Name, _accountManager.LastOpenedUser.UserId); public string SaveManagerHeading => LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.SaveManagerHeading, _accountManager.LastOpenedUser.Name, _accountManager.LastOpenedUser.UserId);

View file

@ -36,9 +36,9 @@ namespace Ryujinx.Ava.UI.ViewModels
private readonly Ryujinx.Common.Logging.XCIFileTrimmerLog _logger; private readonly Ryujinx.Common.Logging.XCIFileTrimmerLog _logger;
private ApplicationLibrary ApplicationLibrary => _mainWindowViewModel.ApplicationLibrary; private ApplicationLibrary ApplicationLibrary => _mainWindowViewModel.ApplicationLibrary;
private Optional<XCITrimmerFileModel> _processingApplication = null; private Optional<XCITrimmerFileModel> _processingApplication = null;
private AvaloniaList<XCITrimmerFileModel> _allXCIFiles = new(); private AvaloniaList<XCITrimmerFileModel> _allXCIFiles = [];
private AvaloniaList<XCITrimmerFileModel> _selectedXCIFiles = new(); private AvaloniaList<XCITrimmerFileModel> _selectedXCIFiles = [];
private AvaloniaList<XCITrimmerFileModel> _displayedXCIFiles = new(); private AvaloniaList<XCITrimmerFileModel> _displayedXCIFiles = [];
private MainWindowViewModel _mainWindowViewModel; private MainWindowViewModel _mainWindowViewModel;
private CancellationTokenSource _cancellationTokenSource; private CancellationTokenSource _cancellationTokenSource;
private string _search; private string _search;

View file

@ -70,9 +70,9 @@ namespace Ryujinx.Ava.UI.Views.User
{ {
new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats]) new(LocaleManager.Instance[LocaleKeys.AllSupportedFormats])
{ {
Patterns = new[] { "*.jpg", "*.jpeg", "*.png", "*.bmp" }, Patterns = ["*.jpg", "*.jpeg", "*.png", "*.bmp"],
AppleUniformTypeIdentifiers = new[] { "public.jpeg", "public.png", "com.microsoft.bmp" }, AppleUniformTypeIdentifiers = ["public.jpeg", "public.png", "com.microsoft.bmp"],
MimeTypes = new[] { "image/jpeg", "image/png", "image/bmp" }, MimeTypes = ["image/jpeg", "image/png", "image/bmp"],
}, },
}, },
}); });

View file

@ -67,7 +67,7 @@ namespace Ryujinx.Ava.UI.Views.User
public void LoadSaves() public void LoadSaves()
{ {
ViewModel.Saves.Clear(); ViewModel.Saves.Clear();
ObservableCollection<SaveModel> saves = new(); ObservableCollection<SaveModel> saves = [];
SaveDataFilter saveDataFilter = SaveDataFilter.Make( SaveDataFilter saveDataFilter = SaveDataFilter.Make(
programId: default, programId: default,
saveType: SaveDataType.Account, saveType: SaveDataType.Account,

View file

@ -34,7 +34,7 @@ namespace Ryujinx.Ava.UI.Windows
public CheatWindow(VirtualFileSystem virtualFileSystem, string titleId, string titleName, string titlePath) public CheatWindow(VirtualFileSystem virtualFileSystem, string titleId, string titleName, string titlePath)
{ {
LoadedCheats = new AvaloniaList<CheatNode>(); LoadedCheats = [];
IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
? IntegrityCheckLevel.ErrorOnInvalid ? IntegrityCheckLevel.ErrorOnInvalid
: IntegrityCheckLevel.None; : IntegrityCheckLevel.None;

View file

@ -712,12 +712,13 @@ namespace Ryujinx.Ava.UI.Windows
private void ShowNewContentAddedDialog(int numDlcAdded, int numDlcRemoved, int numUpdatesAdded, int numUpdatesRemoved) private void ShowNewContentAddedDialog(int numDlcAdded, int numDlcRemoved, int numUpdatesAdded, int numUpdatesRemoved)
{ {
string[] messages = { string[] messages =
[
numDlcRemoved > 0 ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadDlcRemovedMessage], numDlcRemoved): null, numDlcRemoved > 0 ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadDlcRemovedMessage], numDlcRemoved): null,
numDlcAdded > 0 ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadDlcAddedMessage], numDlcAdded): null, numDlcAdded > 0 ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadDlcAddedMessage], numDlcAdded): null,
numUpdatesRemoved > 0 ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadUpdateRemovedMessage], numUpdatesRemoved): null, numUpdatesRemoved > 0 ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadUpdateRemovedMessage], numUpdatesRemoved): null,
numUpdatesAdded > 0 ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadUpdateAddedMessage], numUpdatesAdded) : null numUpdatesAdded > 0 ? string.Format(LocaleManager.Instance[LocaleKeys.AutoloadUpdateAddedMessage], numUpdatesAdded) : null
}; ];
string msg = String.Join("\r\n", messages); string msg = String.Join("\r\n", messages);

View file

@ -372,7 +372,7 @@ namespace Ryujinx.Ava
for (int i = 0; i < ConnectionCount; i++) for (int i = 0; i < ConnectionCount; i++)
{ {
list.Add(Array.Empty<byte>()); list.Add([]);
} }
for (int i = 0; i < ConnectionCount; i++) for (int i = 0; i < ConnectionCount; i++)

View file

@ -190,7 +190,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
/// <exception cref="HorizonResultException">An error occured while reading PFS data.</exception> /// <exception cref="HorizonResultException">An error occured while reading PFS data.</exception>
private List<ApplicationData> GetApplicationsFromPfs(IFileSystem pfs, string filePath) private List<ApplicationData> GetApplicationsFromPfs(IFileSystem pfs, string filePath)
{ {
List<ApplicationData> applications = new(); List<ApplicationData> applications = [];
string extension = Path.GetExtension(filePath).ToLower(); string extension = Path.GetExtension(filePath).ToLower();
foreach ((ulong titleId, ContentMetaData content) in pfs.GetContentData(ContentMetaType.Application, _virtualFileSystem, _checkLevel)) foreach ((ulong titleId, ContentMetaData content) in pfs.GetContentData(ContentMetaType.Application, _virtualFileSystem, _checkLevel))
@ -642,7 +642,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
_applications.Clear(); _applications.Clear();
// Builds the applications list with paths to found applications // Builds the applications list with paths to found applications
List<string> applicationPaths = new(); List<string> applicationPaths = [];
try try
{ {
@ -833,7 +833,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
{ {
_cancellationToken = new CancellationTokenSource(); _cancellationToken = new CancellationTokenSource();
List<string> dlcPaths = new(); List<string> dlcPaths = [];
int newDlcLoaded = 0; int newDlcLoaded = 0;
numDlcRemoved = 0; numDlcRemoved = 0;
@ -943,14 +943,14 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
{ {
_cancellationToken = new CancellationTokenSource(); _cancellationToken = new CancellationTokenSource();
List<string> updatePaths = new(); List<string> updatePaths = [];
int numUpdatesLoaded = 0; int numUpdatesLoaded = 0;
numUpdatesRemoved = 0; numUpdatesRemoved = 0;
try try
{ {
HashSet<ulong> titleIdsToSave = new(); HashSet<ulong> titleIdsToSave = [];
HashSet<ulong> titleIdsToRefresh = new(); HashSet<ulong> titleIdsToRefresh = [];
// Remove any updates which can no longer be located on disk // Remove any updates which can no longer be located on disk
List<(TitleUpdateModel TitleUpdate, bool IsSelected)> updatesToRemove = _titleUpdates.Items List<(TitleUpdateModel TitleUpdate, bool IsSelected)> updatesToRemove = _titleUpdates.Items

View file

@ -20,7 +20,7 @@ namespace Ryujinx.Ava.Utilities
public static void ParseArguments(string[] args) public static void ParseArguments(string[] args)
{ {
List<string> arguments = new(); List<string> arguments = [];
// Parse Arguments. // Parse Arguments.
for (int i = 0; i < args.Length; ++i) for (int i = 0; i < args.Length; ++i)

View file

@ -45,7 +45,7 @@ namespace Ryujinx.Ava.Utilities
public static void SaveDownloadableContentsJson(ulong applicationIdBase, List<(DownloadableContentModel, bool IsEnabled)> dlcs) public static void SaveDownloadableContentsJson(ulong applicationIdBase, List<(DownloadableContentModel, bool IsEnabled)> dlcs)
{ {
DownloadableContentContainer container = default; DownloadableContentContainer container = default;
List<DownloadableContentContainer> downloadableContentContainerList = new(); List<DownloadableContentContainer> downloadableContentContainerList = [];
foreach ((DownloadableContentModel dlc, bool isEnabled) in dlcs) foreach ((DownloadableContentModel dlc, bool isEnabled) in dlcs)
{ {
@ -82,7 +82,7 @@ namespace Ryujinx.Ava.Utilities
private static List<(DownloadableContentModel, bool IsEnabled)> LoadDownloadableContents(VirtualFileSystem vfs, List<DownloadableContentContainer> downloadableContentContainers) private static List<(DownloadableContentModel, bool IsEnabled)> LoadDownloadableContents(VirtualFileSystem vfs, List<DownloadableContentContainer> downloadableContentContainers)
{ {
List<(DownloadableContentModel, bool IsEnabled)> result = new(); List<(DownloadableContentModel, bool IsEnabled)> result = [];
foreach (DownloadableContentContainer downloadableContentContainer in downloadableContentContainers) foreach (DownloadableContentContainer downloadableContentContainer in downloadableContentContainers)
{ {

View file

@ -124,7 +124,7 @@ namespace Ryujinx.Ava.Utilities
private static string GetArgsString(string appFilePath, string applicationId) private static string GetArgsString(string appFilePath, string applicationId)
{ {
// args are first defined as a list, for easier adjustments in the future // args are first defined as a list, for easier adjustments in the future
List<string> argsList = new(); List<string> argsList = [];
if (!string.IsNullOrEmpty(CommandLineState.BaseDirPathArg)) if (!string.IsNullOrEmpty(CommandLineState.BaseDirPathArg))
{ {
@ -152,7 +152,7 @@ namespace Ryujinx.Ava.Utilities
private static void SaveBitmapAsIcon(SKBitmap source, string filePath) private static void SaveBitmapAsIcon(SKBitmap source, string filePath)
{ {
// Code Modified From https://stackoverflow.com/a/11448060/368354 by Benlitz // 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); using FileStream fs = new(filePath, FileMode.Create);
fs.Write(header); fs.Write(header);

View file

@ -79,7 +79,7 @@ namespace Ryujinx.Ava.Utilities
private static List<(TitleUpdateModel Update, bool IsSelected)> LoadTitleUpdates(VirtualFileSystem vfs, TitleUpdateMetadata titleUpdateMetadata, ulong applicationIdBase) private static List<(TitleUpdateModel Update, bool IsSelected)> LoadTitleUpdates(VirtualFileSystem vfs, TitleUpdateMetadata titleUpdateMetadata, ulong applicationIdBase)
{ {
List<(TitleUpdateModel, bool IsSelected)> result = new(); List<(TitleUpdateModel, bool IsSelected)> result = [];
IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
? IntegrityCheckLevel.ErrorOnInvalid ? IntegrityCheckLevel.ErrorOnInvalid

View file

@ -10,10 +10,10 @@ namespace Ryujinx.Ava.Utilities
public static class ValueFormatUtils public static class ValueFormatUtils
{ {
private static readonly string[] _fileSizeUnitStrings = private static readonly string[] _fileSizeUnitStrings =
{ [
"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", // Base 10 units, used for formatting and parsing "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> /// <summary>
/// Used by <see cref="FormatFileSize"/>. /// Used by <see cref="FormatFileSize"/>.