misc: chore: Fix object creation in Avalonia project

This commit is contained in:
Evan Husted
2025-01-26 15:16:50 -06:00
parent 5f023ca49b
commit 3cdaaa0b69
25 changed files with 63 additions and 63 deletions

View File

@@ -76,14 +76,14 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
}
else
{
PartitionFileSystem pfsTemp = new PartitionFileSystem();
PartitionFileSystem pfsTemp = new();
pfsTemp.Initialize(file.AsStorage()).ThrowIfFailure();
pfs = pfsTemp;
}
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca"))
{
using UniqueRef<IFile> ncaFile = new UniqueRef<IFile>();
using UniqueRef<IFile> ncaFile = new();
pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@@ -158,7 +158,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return string.Empty;
}
using UniqueRef<IFile> nsoFile = new UniqueRef<IFile>();
using UniqueRef<IFile> nsoFile = new();
codeFs.OpenFile(ref nsoFile.Ref, $"/{MainExeFs}".ToU8Span(), OpenMode.Read).ThrowIfFailure();

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>();
List<ApplicationData> applications = new();
string extension = Path.GetExtension(filePath).ToLower();
foreach ((ulong titleId, ContentMetaData content) in pfs.GetContentData(ContentMetaType.Application, _virtualFileSystem, _checkLevel))
@@ -245,7 +245,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
continue;
}
using UniqueRef<IFile> icon = new UniqueRef<IFile>();
using UniqueRef<IFile> icon = new();
controlFs.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@@ -313,7 +313,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
case ".nsp":
case ".pfs0":
{
PartitionFileSystem pfs = new PartitionFileSystem();
PartitionFileSystem pfs = new();
pfs.Initialize(file.AsStorage()).ThrowIfFailure();
ApplicationData result = GetApplicationFromNsp(pfs, applicationPath);
@@ -501,7 +501,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca"))
{
using UniqueRef<IFile> ncaFile = new UniqueRef<IFile>();
using UniqueRef<IFile> ncaFile = new();
pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@@ -589,7 +589,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
ReadOption.None).ThrowIfFailure();
string displayVersion = controlData.DisplayVersionString.ToString();
TitleUpdateModel update = new TitleUpdateModel(content.ApplicationId, content.Version.Version,
TitleUpdateModel update = new(content.ApplicationId, content.Version.Version,
displayVersion, filePath);
titleUpdates.Add(update);
@@ -685,7 +685,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return;
}
FileInfo fileInfo = new FileInfo(app);
FileInfo fileInfo = new(app);
try
{
@@ -776,7 +776,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
ldnWebHost = DefaultLanPlayWebHost;
}
IEnumerable<LdnGameData> ldnGameDataArray = Array.Empty<LdnGameData>();
using HttpClient httpClient = new HttpClient();
using HttpClient httpClient = new();
string ldnGameDataArrayString = await httpClient.GetStringAsync($"https://{ldnWebHost}/api/public_games");
ldnGameDataArray = JsonHelper.Deserialize(ldnGameDataArrayString, _ldnDataSerializerContext.IEnumerableLdnGameData);
LdnGameDataReceived?.Invoke(new LdnGameDataReceivedEventArgs
@@ -882,7 +882,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return newDlcLoaded;
}
FileInfo fileInfo = new FileInfo(app);
FileInfo fileInfo = new(app);
try
{
@@ -949,8 +949,8 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
try
{
HashSet<ulong> titleIdsToSave = new HashSet<ulong>();
HashSet<ulong> titleIdsToRefresh = new HashSet<ulong>();
HashSet<ulong> titleIdsToSave = new();
HashSet<ulong> titleIdsToRefresh = new();
// Remove any updates which can no longer be located on disk
List<(TitleUpdateModel TitleUpdate, bool IsSelected)> updatesToRemove = _titleUpdates.Items
@@ -998,7 +998,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return numUpdatesLoaded;
}
FileInfo fileInfo = new FileInfo(app);
FileInfo fileInfo = new(app);
try
{
@@ -1170,7 +1170,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
}
else
{
PartitionFileSystem pfsTemp = new PartitionFileSystem();
PartitionFileSystem pfsTemp = new();
pfsTemp.Initialize(file.AsStorage()).ThrowIfFailure();
pfs = pfsTemp;
@@ -1204,7 +1204,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
// Read the icon from the ControlFS and store it as a byte array
try
{
using UniqueRef<IFile> icon = new UniqueRef<IFile>();
using UniqueRef<IFile> icon = new();
controlFs.OpenFile(ref icon.Ref, $"/icon_{desiredTitleLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure();
@@ -1222,7 +1222,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
continue;
}
using UniqueRef<IFile> icon = new UniqueRef<IFile>();
using UniqueRef<IFile> icon = new();
controlFs.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();

View File

@@ -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)>();
List<(DownloadableContentModel, bool IsEnabled)> result = new();
foreach (DownloadableContentContainer downloadableContentContainer in downloadableContentContainers)
{
@@ -105,7 +105,7 @@ namespace Ryujinx.Ava.Utilities
continue;
}
DownloadableContentModel content = new DownloadableContentModel(nca.Header.TitleId,
DownloadableContentModel content = new(nca.Header.TitleId,
downloadableContentContainer.ContainerPath,
downloadableContentNca.FullPath);

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>();
List<string> argsList = new();
if (!string.IsNullOrEmpty(CommandLineState.BaseDirPathArg))
{

View File

@@ -16,7 +16,7 @@ namespace Ryujinx.Ava.Utilities.SystemInfo
if (cpuName == null)
{
Dictionary<string, string> cpuDict = new Dictionary<string, string>(StringComparer.Ordinal)
Dictionary<string, string> cpuDict = new(StringComparer.Ordinal)
{
["model name"] = null,
["Processor"] = null,
@@ -28,7 +28,7 @@ namespace Ryujinx.Ava.Utilities.SystemInfo
cpuName = cpuDict["model name"] ?? cpuDict["Processor"] ?? cpuDict["Hardware"] ?? "Unknown";
}
Dictionary<string, string> memDict = new Dictionary<string, string>(StringComparer.Ordinal)
Dictionary<string, string> memDict = new(StringComparer.Ordinal)
{
["MemTotal"] = null,
["MemAvailable"] = null,

View File

@@ -51,7 +51,7 @@ namespace Ryujinx.Ava.Utilities
public static void SaveTitleUpdatesJson(ulong applicationIdBase, List<(TitleUpdateModel, bool IsSelected)> updates)
{
TitleUpdateMetadata titleUpdateWindowData = new TitleUpdateMetadata
TitleUpdateMetadata titleUpdateWindowData = new()
{
Selected = string.Empty,
Paths = [],
@@ -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)>();
List<(TitleUpdateModel, bool IsSelected)> result = new();
IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
? IntegrityCheckLevel.ErrorOnInvalid
@@ -116,7 +116,7 @@ namespace Ryujinx.Ava.Utilities
.ThrowIfFailure();
string displayVersion = controlData.DisplayVersionString.ToString();
TitleUpdateModel update = new TitleUpdateModel(content.ApplicationId, content.Version.Version,
TitleUpdateModel update = new(content.ApplicationId, content.Version.Version,
displayVersion, path);
result.Add((update, path == titleUpdateMetadata.Selected));