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

@ -975,7 +975,7 @@ namespace Ryujinx.Ava
private static IHardwareDeviceDriver InitializeAudio() private static IHardwareDeviceDriver InitializeAudio()
{ {
List<AudioBackend> availableBackends = new List<AudioBackend> List<AudioBackend> availableBackends = new()
{ {
AudioBackend.SDL2, AudioBackend.SDL2,
AudioBackend.SoundIo, AudioBackend.SoundIo,

View File

@ -144,7 +144,7 @@ namespace Ryujinx.Ava.Common
public static void ExtractSection(string destination, NcaSectionType ncaSectionType, string titleFilePath, string titleName, int programIndex = 0) public static void ExtractSection(string destination, NcaSectionType ncaSectionType, string titleFilePath, string titleName, int programIndex = 0)
{ {
CancellationTokenSource cancellationToken = new CancellationTokenSource(); CancellationTokenSource cancellationToken = new();
UpdateWaitWindow waitingDialog = new( UpdateWaitWindow waitingDialog = new(
RyujinxApp.FormatTitle(LocaleKeys.DialogNcaExtractionTitle), RyujinxApp.FormatTitle(LocaleKeys.DialogNcaExtractionTitle),
@ -171,14 +171,14 @@ namespace Ryujinx.Ava.Common
} }
else else
{ {
PartitionFileSystem pfsTemp = new PartitionFileSystem(); PartitionFileSystem pfsTemp = new();
pfsTemp.Initialize(file.AsStorage()).ThrowIfFailure(); pfsTemp.Initialize(file.AsStorage()).ThrowIfFailure();
pfs = pfsTemp; pfs = pfsTemp;
} }
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca")) 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(); pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@ -244,8 +244,8 @@ namespace Ryujinx.Ava.Common
string source = DateTime.Now.ToFileTime().ToString()[10..]; string source = DateTime.Now.ToFileTime().ToString()[10..];
string output = DateTime.Now.ToFileTime().ToString()[10..]; string output = DateTime.Now.ToFileTime().ToString()[10..];
using UniqueRef<IFileSystem> uniqueSourceFs = new UniqueRef<IFileSystem>(ncaFileSystem); using UniqueRef<IFileSystem> uniqueSourceFs = new(ncaFileSystem);
using UniqueRef<IFileSystem> uniqueOutputFs = new UniqueRef<IFileSystem>(new LocalFileSystem(destination)); using UniqueRef<IFileSystem> uniqueOutputFs = new(new LocalFileSystem(destination));
fsClient.Register(source.ToU8Span(), ref uniqueSourceFs.Ref); fsClient.Register(source.ToU8Span(), ref uniqueSourceFs.Ref);
fsClient.Register(output.ToU8Span(), ref uniqueOutputFs.Ref); fsClient.Register(output.ToU8Span(), ref uniqueOutputFs.Ref);
@ -299,7 +299,7 @@ namespace Ryujinx.Ava.Common
public static void ExtractAoc(string destination, string updateFilePath, string updateName) public static void ExtractAoc(string destination, string updateFilePath, string updateName)
{ {
CancellationTokenSource cancellationToken = new CancellationTokenSource(); CancellationTokenSource cancellationToken = new();
UpdateWaitWindow waitingDialog = new( UpdateWaitWindow waitingDialog = new(
RyujinxApp.FormatTitle(LocaleKeys.DialogNcaExtractionTitle), RyujinxApp.FormatTitle(LocaleKeys.DialogNcaExtractionTitle),
@ -317,13 +317,13 @@ namespace Ryujinx.Ava.Common
string extension = Path.GetExtension(updateFilePath).ToLower(); string extension = Path.GetExtension(updateFilePath).ToLower();
if (extension is ".nsp") if (extension is ".nsp")
{ {
PartitionFileSystem pfsTemp = new PartitionFileSystem(); PartitionFileSystem pfsTemp = new();
pfsTemp.Initialize(file.AsStorage()).ThrowIfFailure(); pfsTemp.Initialize(file.AsStorage()).ThrowIfFailure();
IFileSystem pfs = pfsTemp; IFileSystem pfs = pfsTemp;
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca")) 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(); pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@ -364,8 +364,8 @@ namespace Ryujinx.Ava.Common
string source = DateTime.Now.ToFileTime().ToString()[10..]; string source = DateTime.Now.ToFileTime().ToString()[10..];
string output = DateTime.Now.ToFileTime().ToString()[10..]; string output = DateTime.Now.ToFileTime().ToString()[10..];
using UniqueRef<IFileSystem> uniqueSourceFs = new UniqueRef<IFileSystem>(ncaFileSystem); using UniqueRef<IFileSystem> uniqueSourceFs = new(ncaFileSystem);
using UniqueRef<IFileSystem> uniqueOutputFs = new UniqueRef<IFileSystem>(new LocalFileSystem(destination)); using UniqueRef<IFileSystem> uniqueOutputFs = new(new LocalFileSystem(destination));
fsClient.Register(source.ToU8Span(), ref uniqueSourceFs.Ref); fsClient.Register(source.ToU8Span(), ref uniqueSourceFs.Ref);
fsClient.Register(output.ToU8Span(), ref uniqueOutputFs.Ref); fsClient.Register(output.ToU8Span(), ref uniqueOutputFs.Ref);

View File

@ -125,7 +125,7 @@ namespace Ryujinx.Ava.Common.Locale
private static Dictionary<LocaleKeys, string> LoadJsonLanguage(string languageCode) private static Dictionary<LocaleKeys, string> LoadJsonLanguage(string languageCode)
{ {
Dictionary<LocaleKeys, string> localeStrings = new Dictionary<LocaleKeys, string>(); Dictionary<LocaleKeys, string> localeStrings = new();
_localeData ??= EmbeddedResources.ReadAllText("Ryujinx/Assets/locales.json") _localeData ??= EmbeddedResources.ReadAllText("Ryujinx/Assets/locales.json")
.Into(it => JsonHelper.Deserialize(it, LocalesJsonContext.Default.LocalesJson)); .Into(it => JsonHelper.Deserialize(it, LocalesJsonContext.Default.LocalesJson));

View File

@ -16,7 +16,7 @@ namespace Ryujinx.Ava.Common.Models
{ {
public static XCITrimmerFileModel FromApplicationData(ApplicationData applicationData, XCIFileTrimmerLog logger) public static XCITrimmerFileModel FromApplicationData(ApplicationData applicationData, XCIFileTrimmerLog logger)
{ {
XCIFileTrimmer trimmer = new XCIFileTrimmer(applicationData.Path, logger); XCIFileTrimmer trimmer = new(applicationData.Path, logger);
return new XCITrimmerFileModel( return new XCITrimmerFileModel(
applicationData.Name, applicationData.Name,

View File

@ -172,7 +172,7 @@ namespace Ryujinx.Ava.UI.Applet
try try
{ {
_parent.ViewModel.AppHost.NpadManager.BlockInputUpdates(); _parent.ViewModel.AppHost.NpadManager.BlockInputUpdates();
SoftwareKeyboardUIArgs args = new SoftwareKeyboardUIArgs(); SoftwareKeyboardUIArgs args = new();
args.KeyboardMode = KeyboardMode.Default; args.KeyboardMode = KeyboardMode.Default;
args.InitialText = "Ryujinx"; args.InitialText = "Ryujinx";
args.StringLengthMin = 1; args.StringLengthMin = 1;
@ -264,7 +264,7 @@ namespace Ryujinx.Ava.UI.Applet
{ {
UserId selected = UserId.Null; UserId selected = UserId.Null;
byte[] defaultGuestImage = EmbeddedResources.Read("Ryujinx.HLE/HOS/Services/Account/Acc/GuestUserImage.jpg"); byte[] defaultGuestImage = EmbeddedResources.Read("Ryujinx.HLE/HOS/Services/Account/Acc/GuestUserImage.jpg");
UserProfile guest = new UserProfile(new UserId("00000000000000000000000000000080"), "Guest", defaultGuestImage); UserProfile guest = new(new UserId("00000000000000000000000000000080"), "Guest", defaultGuestImage);
ManualResetEvent dialogCloseEvent = new(false); ManualResetEvent dialogCloseEvent = new(false);

View File

@ -64,7 +64,7 @@ namespace Ryujinx.Ava.UI.Applet
{ {
if (item is UserProfile originalItem) if (item is UserProfile originalItem)
{ {
UserProfileSft profile = new UserProfileSft(originalItem.UserId, originalItem.Name, originalItem.Image); UserProfileSft profile = new(originalItem.UserId, originalItem.Name, originalItem.Image);
if (profile.UserId == ViewModel.SelectedUserId) if (profile.UserId == ViewModel.SelectedUserId)
{ {

View File

@ -108,7 +108,7 @@ namespace Ryujinx.Ava.UI.Controls
SaveDataFilter saveDataFilter = SaveDataFilter.Make(programId: default, saveType: SaveDataType.Account, default, saveDataId: default, index: default); SaveDataFilter saveDataFilter = SaveDataFilter.Make(programId: default, saveType: SaveDataType.Account, default, saveDataId: default, index: default);
using UniqueRef<SaveDataIterator> saveDataIterator = new UniqueRef<SaveDataIterator>(); using UniqueRef<SaveDataIterator> saveDataIterator = new();
HorizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref, SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure(); HorizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref, SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure();
@ -128,7 +128,7 @@ namespace Ryujinx.Ava.UI.Controls
for (int i = 0; i < readCount; i++) for (int i = 0; i < readCount; i++)
{ {
SaveDataInfo save = saveDataInfo[i]; SaveDataInfo save = saveDataInfo[i];
UserId id = new UserId((long)save.UserId.Id.Low, (long)save.UserId.Id.High); UserId id = new((long)save.UserId.Id.Low, (long)save.UserId.Id.High);
if (ViewModel.Profiles.Cast<UserProfile>().FirstOrDefault(x => x.UserId == id) == null) if (ViewModel.Profiles.Cast<UserProfile>().FirstOrDefault(x => x.UserId == id) == null)
{ {
lostAccounts.Add(id); lostAccounts.Add(id);

View File

@ -50,8 +50,8 @@ namespace Ryujinx.Ava.UI.Helpers
private static string Format(AvaLogLevel level, string area, string template, object source, object[] v) private static string Format(AvaLogLevel level, string area, string template, object source, object[] v)
{ {
StringBuilder result = new StringBuilder(); StringBuilder result = new();
CharacterReader r = new CharacterReader(template.AsSpan()); CharacterReader r = new(template.AsSpan());
int i = 0; int i = 0;
result.Append('['); result.Append('[');

View File

@ -28,7 +28,7 @@ namespace Ryujinx.Ava.UI.Helpers
Margin = new Thickness(0, 0, 15, 40), Margin = new Thickness(0, 0, 15, 40),
}; };
Lazy<AsyncWorkQueue<Notification>> maybeAsyncWorkQueue = new Lazy<AsyncWorkQueue<Notification>>( Lazy<AsyncWorkQueue<Notification>> maybeAsyncWorkQueue = new(
() => new AsyncWorkQueue<Notification>(notification => () => new AsyncWorkQueue<Notification>(notification =>
{ {
Dispatcher.UIThread.Post(() => Dispatcher.UIThread.Post(() =>

View File

@ -367,7 +367,7 @@ namespace Ryujinx.Ava.UI.Models.Input
public InputConfig GetConfig() public InputConfig GetConfig()
{ {
StandardKeyboardInputConfig config = new StandardKeyboardInputConfig StandardKeyboardInputConfig config = new()
{ {
Id = Id, Id = Id,
Backend = InputBackendType.WindowKeyboard, Backend = InputBackendType.WindowKeyboard,

View File

@ -1802,7 +1802,7 @@ namespace Ryujinx.Ava.UI.ViewModels
return; return;
} }
XCIFileTrimmer trimmer = new XCIFileTrimmer(filename, new XCITrimmerLog.MainWindow(this)); XCIFileTrimmer trimmer = new(filename, new XCITrimmerLog.MainWindow(this));
if (trimmer.CanBeTrimmed) if (trimmer.CanBeTrimmed)
{ {

View File

@ -82,13 +82,13 @@ namespace Ryujinx.Ava.UI.ViewModels
foreach (string path in modsBasePaths) foreach (string path in modsBasePaths)
{ {
bool inSd = path == ModLoader.GetSdModsBasePath(); bool inSd = path == ModLoader.GetSdModsBasePath();
ModLoader.ModCache modCache = new ModLoader.ModCache(); ModLoader.ModCache modCache = new();
ModLoader.QueryContentsDir(modCache, new DirectoryInfo(Path.Combine(path, "contents")), applicationId); ModLoader.QueryContentsDir(modCache, new DirectoryInfo(Path.Combine(path, "contents")), applicationId);
foreach (ModLoader.Mod<DirectoryInfo> mod in modCache.RomfsDirs) foreach (ModLoader.Mod<DirectoryInfo> mod in modCache.RomfsDirs)
{ {
ModModel modModel = new ModModel(mod.Path.Parent.FullName, mod.Name, mod.Enabled, inSd); ModModel modModel = new(mod.Path.Parent.FullName, mod.Name, mod.Enabled, inSd);
if (Mods.All(x => x.Path != mod.Path.Parent.FullName)) if (Mods.All(x => x.Path != mod.Path.Parent.FullName))
{ {
Mods.Add(modModel); Mods.Add(modModel);
@ -102,7 +102,7 @@ namespace Ryujinx.Ava.UI.ViewModels
foreach (ModLoader.Mod<DirectoryInfo> mod in modCache.ExefsDirs) foreach (ModLoader.Mod<DirectoryInfo> mod in modCache.ExefsDirs)
{ {
ModModel modModel = new ModModel(mod.Path.Parent.FullName, mod.Name, mod.Enabled, inSd); ModModel modModel = new(mod.Path.Parent.FullName, mod.Name, mod.Enabled, inSd);
if (Mods.All(x => x.Path != mod.Path.Parent.FullName)) if (Mods.All(x => x.Path != mod.Path.Parent.FullName))
{ {
Mods.Add(modModel); Mods.Add(modModel);

View File

@ -104,7 +104,7 @@ namespace Ryujinx.Ava.UI.ViewModels
// TODO: Parse DatabaseInfo.bin and table.bin files for more accuracy. // TODO: Parse DatabaseInfo.bin and table.bin files for more accuracy.
if (item.Type == DirectoryEntryType.File && item.FullPath.Contains("chara") && item.FullPath.Contains("szs")) if (item.Type == DirectoryEntryType.File && item.FullPath.Contains("chara") && item.FullPath.Contains("szs"))
{ {
using UniqueRef<IFile> file = new UniqueRef<IFile>(); using UniqueRef<IFile> file = new();
romfs.OpenFile(ref file.Ref, ("/" + item.FullPath).ToU8Span(), OpenMode.Read).ThrowIfFailure(); romfs.OpenFile(ref file.Ref, ("/" + item.FullPath).ToU8Span(), OpenMode.Read).ThrowIfFailure();

View File

@ -183,7 +183,7 @@ namespace Ryujinx.Ava.UI.ViewModels
if (cancellationToken.IsCancellationRequested) if (cancellationToken.IsCancellationRequested)
break; break;
XCIFileTrimmer trimmer = new XCIFileTrimmer(xciApp.Path, _logger); XCIFileTrimmer trimmer = new(xciApp.Path, _logger);
Dispatcher.UIThread.Post(() => Dispatcher.UIThread.Post(() =>
{ {

View File

@ -66,11 +66,11 @@ namespace Ryujinx.Ava.UI.Views.User
{ {
if (ViewModel.SelectedImage != null) if (ViewModel.SelectedImage != null)
{ {
using MemoryStream streamJpg = new MemoryStream(); using MemoryStream streamJpg = new();
using SKBitmap bitmap = SKBitmap.Decode(ViewModel.SelectedImage); using SKBitmap bitmap = SKBitmap.Decode(ViewModel.SelectedImage);
using SKBitmap newBitmap = new SKBitmap(bitmap.Width, bitmap.Height); using SKBitmap newBitmap = new(bitmap.Width, bitmap.Height);
using (SKCanvas canvas = new SKCanvas(newBitmap)) using (SKCanvas canvas = new(newBitmap))
{ {
canvas.Clear(new SKColor( canvas.Clear(new SKColor(
ViewModel.BackgroundColor.R, ViewModel.BackgroundColor.R,

View File

@ -103,7 +103,7 @@ namespace Ryujinx.Ava.UI.Views.User
SKBitmap resizedBitmap = bitmap.Resize(new SKImageInfo(256, 256), SKFilterQuality.High); SKBitmap resizedBitmap = bitmap.Resize(new SKImageInfo(256, 256), SKFilterQuality.High);
using MemoryStream streamJpg = new MemoryStream(); using MemoryStream streamJpg = new();
if (resizedBitmap != null) if (resizedBitmap != null)
{ {

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>(); ObservableCollection<SaveModel> saves = new();
SaveDataFilter saveDataFilter = SaveDataFilter.Make( SaveDataFilter saveDataFilter = SaveDataFilter.Make(
programId: default, programId: default,
saveType: SaveDataType.Account, saveType: SaveDataType.Account,
@ -75,7 +75,7 @@ namespace Ryujinx.Ava.UI.Views.User
saveDataId: default, saveDataId: default,
index: default); index: default);
using UniqueRef<SaveDataIterator> saveDataIterator = new UniqueRef<SaveDataIterator>(); using UniqueRef<SaveDataIterator> saveDataIterator = new();
_horizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref, SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure(); _horizonClient.Fs.OpenSaveDataIterator(ref saveDataIterator.Ref, SaveDataSpaceId.User, in saveDataFilter).ThrowIfFailure();
@ -95,7 +95,7 @@ namespace Ryujinx.Ava.UI.Views.User
SaveDataInfo save = saveDataInfo[i]; SaveDataInfo save = saveDataInfo[i];
if (save.ProgramId.Value != 0) if (save.ProgramId.Value != 0)
{ {
SaveModel saveModel = new SaveModel(save); SaveModel saveModel = new(save);
saves.Add(saveModel); saves.Add(saveModel);
} }
} }

View File

@ -59,7 +59,7 @@ namespace Ryujinx.Ava.UI.Windows
int cheatAdded = 0; int cheatAdded = 0;
ModLoader.ModCache mods = new ModLoader.ModCache(); ModLoader.ModCache mods = new();
ModLoader.QueryContentsDir(mods, new DirectoryInfo(Path.Combine(modsBasePath, "contents")), titleIdValue); ModLoader.QueryContentsDir(mods, new DirectoryInfo(Path.Combine(modsBasePath, "contents")), titleIdValue);
@ -81,7 +81,7 @@ namespace Ryujinx.Ava.UI.Windows
LoadedCheats.Add(currentGroup); LoadedCheats.Add(currentGroup);
} }
CheatNode model = new CheatNode(cheat.Name, buildId, string.Empty, false, enabled.Contains($"{buildId}-{cheat.Name}")); CheatNode model = new(cheat.Name, buildId, string.Empty, false, enabled.Contains($"{buildId}-{cheat.Name}"));
currentGroup?.SubNodes.Add(model); currentGroup?.SubNodes.Add(model);
cheatAdded++; cheatAdded++;

View File

@ -50,7 +50,7 @@ namespace Ryujinx.Ava.UI.Windows
public static SKColor GetColor(SKBitmap image) public static SKColor GetColor(SKBitmap image)
{ {
PaletteColor[] colors = new PaletteColor[TotalColors]; PaletteColor[] colors = new PaletteColor[TotalColors];
Dictionary<int, int> dominantColorBin = new Dictionary<int, int>(); Dictionary<int, int> dominantColorBin = new();
SKColor[] buffer = GetBuffer(image); SKColor[] buffer = GetBuffer(image);

View File

@ -76,14 +76,14 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
} }
else else
{ {
PartitionFileSystem pfsTemp = new PartitionFileSystem(); PartitionFileSystem pfsTemp = new();
pfsTemp.Initialize(file.AsStorage()).ThrowIfFailure(); pfsTemp.Initialize(file.AsStorage()).ThrowIfFailure();
pfs = pfsTemp; pfs = pfsTemp;
} }
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca")) 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(); pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@ -158,7 +158,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return string.Empty; 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(); 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> /// <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>(); List<ApplicationData> applications = new();
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))
@ -245,7 +245,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
continue; continue;
} }
using UniqueRef<IFile> icon = new UniqueRef<IFile>(); using UniqueRef<IFile> icon = new();
controlFs.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); controlFs.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@ -313,7 +313,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
case ".nsp": case ".nsp":
case ".pfs0": case ".pfs0":
{ {
PartitionFileSystem pfs = new PartitionFileSystem(); PartitionFileSystem pfs = new();
pfs.Initialize(file.AsStorage()).ThrowIfFailure(); pfs.Initialize(file.AsStorage()).ThrowIfFailure();
ApplicationData result = GetApplicationFromNsp(pfs, applicationPath); ApplicationData result = GetApplicationFromNsp(pfs, applicationPath);
@ -501,7 +501,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca")) 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(); pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@ -589,7 +589,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
ReadOption.None).ThrowIfFailure(); ReadOption.None).ThrowIfFailure();
string displayVersion = controlData.DisplayVersionString.ToString(); string displayVersion = controlData.DisplayVersionString.ToString();
TitleUpdateModel update = new TitleUpdateModel(content.ApplicationId, content.Version.Version, TitleUpdateModel update = new(content.ApplicationId, content.Version.Version,
displayVersion, filePath); displayVersion, filePath);
titleUpdates.Add(update); titleUpdates.Add(update);
@ -685,7 +685,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return; return;
} }
FileInfo fileInfo = new FileInfo(app); FileInfo fileInfo = new(app);
try try
{ {
@ -776,7 +776,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
ldnWebHost = DefaultLanPlayWebHost; ldnWebHost = DefaultLanPlayWebHost;
} }
IEnumerable<LdnGameData> ldnGameDataArray = Array.Empty<LdnGameData>(); 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"); string ldnGameDataArrayString = await httpClient.GetStringAsync($"https://{ldnWebHost}/api/public_games");
ldnGameDataArray = JsonHelper.Deserialize(ldnGameDataArrayString, _ldnDataSerializerContext.IEnumerableLdnGameData); ldnGameDataArray = JsonHelper.Deserialize(ldnGameDataArrayString, _ldnDataSerializerContext.IEnumerableLdnGameData);
LdnGameDataReceived?.Invoke(new LdnGameDataReceivedEventArgs LdnGameDataReceived?.Invoke(new LdnGameDataReceivedEventArgs
@ -882,7 +882,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return newDlcLoaded; return newDlcLoaded;
} }
FileInfo fileInfo = new FileInfo(app); FileInfo fileInfo = new(app);
try try
{ {
@ -949,8 +949,8 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
try try
{ {
HashSet<ulong> titleIdsToSave = new HashSet<ulong>(); HashSet<ulong> titleIdsToSave = new();
HashSet<ulong> titleIdsToRefresh = new HashSet<ulong>(); HashSet<ulong> titleIdsToRefresh = new();
// 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
@ -998,7 +998,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return numUpdatesLoaded; return numUpdatesLoaded;
} }
FileInfo fileInfo = new FileInfo(app); FileInfo fileInfo = new(app);
try try
{ {
@ -1170,7 +1170,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
} }
else else
{ {
PartitionFileSystem pfsTemp = new PartitionFileSystem(); PartitionFileSystem pfsTemp = new();
pfsTemp.Initialize(file.AsStorage()).ThrowIfFailure(); pfsTemp.Initialize(file.AsStorage()).ThrowIfFailure();
pfs = pfsTemp; pfs = pfsTemp;
@ -1204,7 +1204,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
// Read the icon from the ControlFS and store it as a byte array // Read the icon from the ControlFS and store it as a byte array
try 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(); controlFs.OpenFile(ref icon.Ref, $"/icon_{desiredTitleLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure();
@ -1222,7 +1222,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
continue; continue;
} }
using UniqueRef<IFile> icon = new UniqueRef<IFile>(); using UniqueRef<IFile> icon = new();
controlFs.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure(); 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) 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) foreach (DownloadableContentContainer downloadableContentContainer in downloadableContentContainers)
{ {
@ -105,7 +105,7 @@ namespace Ryujinx.Ava.Utilities
continue; continue;
} }
DownloadableContentModel content = new DownloadableContentModel(nca.Header.TitleId, DownloadableContentModel content = new(nca.Header.TitleId,
downloadableContentContainer.ContainerPath, downloadableContentContainer.ContainerPath,
downloadableContentNca.FullPath); downloadableContentNca.FullPath);

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

View File

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

View File

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