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

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

View File

@@ -20,7 +20,7 @@ namespace Ryujinx.Ava.Utilities
public static void ParseArguments(string[] args)
{
List<string> arguments = new();
List<string> arguments = [];
// Parse Arguments.
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)
{
DownloadableContentContainer container = default;
List<DownloadableContentContainer> downloadableContentContainerList = new();
List<DownloadableContentContainer> downloadableContentContainerList = [];
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)
{
List<(DownloadableContentModel, bool IsEnabled)> result = new();
List<(DownloadableContentModel, bool IsEnabled)> result = [];
foreach (DownloadableContentContainer downloadableContentContainer in downloadableContentContainers)
{

View File

@@ -124,7 +124,7 @@ namespace Ryujinx.Ava.Utilities
private static string GetArgsString(string appFilePath, string applicationId)
{
// 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))
{
@@ -152,7 +152,7 @@ namespace Ryujinx.Ava.Utilities
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);

View File

@@ -79,7 +79,7 @@ namespace Ryujinx.Ava.Utilities
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.ErrorOnInvalid

View File

@@ -10,10 +10,10 @@ namespace Ryujinx.Ava.Utilities
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"/>.