misc: chore: Use explicit types & fix object creation

This commit is contained in:
KeatonTheBot
2026-08-12 13:57:33 -05:00
parent 69c088004a
commit 88cef7e853
461 changed files with 3163 additions and 3082 deletions
+3 -3
View File
@@ -73,14 +73,14 @@ namespace Ryujinx.UI.App.Common
}
else
{
var pfsTemp = new PartitionFileSystem();
PartitionFileSystem pfsTemp = new();
pfsTemp.Initialize(file.AsStorage()).ThrowIfFailure();
pfs = pfsTemp;
}
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca"))
{
using var ncaFile = new UniqueRef<IFile>();
using UniqueRef<IFile> ncaFile = new();
pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@@ -155,7 +155,7 @@ namespace Ryujinx.UI.App.Common
return string.Empty;
}
using var nsoFile = new UniqueRef<IFile>();
using UniqueRef<IFile> nsoFile = new();
codeFs.OpenFile(ref nsoFile.Ref, $"/{MainExeFs}".ToU8Span(), OpenMode.Read).ThrowIfFailure();
+45 -45
View File
@@ -209,7 +209,7 @@ namespace Ryujinx.UI.App.Common
/// <exception cref="HorizonResultException">An error occured while reading PFS data.</exception>
private List<ApplicationData> GetApplicationsFromPfs(IFileSystem pfs, string filePath)
{
var 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))
@@ -264,7 +264,7 @@ namespace Ryujinx.UI.App.Common
continue;
}
using var icon = new UniqueRef<IFile>();
using UniqueRef<IFile> icon = new();
controlFs.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@@ -332,7 +332,7 @@ namespace Ryujinx.UI.App.Common
case ".nsp":
case ".pfs0":
{
var pfs = new PartitionFileSystem();
PartitionFileSystem pfs = new();
pfs.Initialize(file.AsStorage()).ThrowIfFailure();
ApplicationData result = GetApplicationFromNsp(pfs, applicationPath);
@@ -457,7 +457,7 @@ namespace Ryujinx.UI.App.Common
return false;
}
foreach (var data in applications)
foreach (ApplicationData data in applications)
{
// Only load metadata for applications with an ID
if (data.Id != 0)
@@ -524,7 +524,7 @@ namespace Ryujinx.UI.App.Common
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca"))
{
using var ncaFile = new UniqueRef<IFile>();
using UniqueRef<IFile> ncaFile = new();
pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@@ -611,8 +611,8 @@ namespace Ryujinx.UI.App.Common
nacpFile.Get.Read(out _, 0, SpanHelpers.AsByteSpan(ref controlData),
ReadOption.None).ThrowIfFailure();
var displayVersion = controlData.DisplayVersionString.ToString();
var update = new TitleUpdateModel(content.ApplicationId, content.Version.Version,
string displayVersion = controlData.DisplayVersionString.ToString();
TitleUpdateModel update = new(content.ApplicationId, content.Version.Version,
displayVersion, filePath);
titleUpdates.Add(update);
@@ -709,11 +709,11 @@ namespace Ryujinx.UI.App.Common
return;
}
var fileInfo = new FileInfo(app);
FileInfo fileInfo = new(app);
try
{
var fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
string fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
applicationPaths.Add(fullPath);
numApplicationsFound++;
@@ -743,7 +743,7 @@ namespace Ryujinx.UI.App.Common
{
_applications.Edit(it =>
{
foreach (var application in applications)
foreach (ApplicationData application in applications)
{
it.AddOrUpdate(application);
LoadDlcForApplication(application);
@@ -802,7 +802,7 @@ namespace Ryujinx.UI.App.Common
using HttpClient httpClient = new();
string ldnGameDataArrayString = await httpClient.GetStringAsync($"https://{ldnWebHost}/api/public_games");
IEnumerable<LdnGameData> ldnGameDataArray = JsonHelper.Deserialize(ldnGameDataArrayString, _ldnDataSerializerContext.IEnumerableLdnGameData);
var evt = new LdnGameDataReceivedEventArgs
LdnGameDataReceivedEventArgs evt = new()
{
LdnData = ldnGameDataArray
};
@@ -865,7 +865,7 @@ namespace Ryujinx.UI.App.Common
{
// Remove any downloadable content which can no longer be located on disk
Logger.Notice.Print(LogClass.Application, $"Removing non-existing Title DLCs");
var dlcToRemove = _downloadableContents.Items
List<(DownloadableContentModel Dlc, bool IsEnabled)> dlcToRemove = _downloadableContents.Items
.Where(dlc => !File.Exists(dlc.Dlc.ContainerPath))
.ToList();
dlcToRemove.ForEach(dlc =>
@@ -909,11 +909,11 @@ namespace Ryujinx.UI.App.Common
return newDlcLoaded;
}
var fileInfo = new FileInfo(app);
FileInfo fileInfo = new(app);
try
{
var fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
string fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
dlcPaths.Add(fullPath);
}
@@ -931,7 +931,7 @@ namespace Ryujinx.UI.App.Common
}
}
var appIdLookup = Applications.Items.Select(it => it.IdBase).ToHashSet();
HashSet<ulong> appIdLookup = Applications.Items.Select(it => it.IdBase).ToHashSet();
foreach (string dlcPath in dlcPaths)
{
@@ -940,9 +940,9 @@ namespace Ryujinx.UI.App.Common
return newDlcLoaded;
}
if (TryGetDownloadableContentFromFile(dlcPath, out var foundDlcs))
if (TryGetDownloadableContentFromFile(dlcPath, out List<DownloadableContentModel> foundDlcs))
{
foreach (var dlc in foundDlcs.Where(it => appIdLookup.Contains(it.TitleIdBase)))
foreach (DownloadableContentModel dlc in foundDlcs.Where(it => appIdLookup.Contains(it.TitleIdBase)))
{
if (!_downloadableContents.Lookup(dlc).HasValue)
{
@@ -976,12 +976,12 @@ namespace Ryujinx.UI.App.Common
try
{
var titleIdsToSave = new HashSet<ulong>();
var titleIdsToRefresh = new HashSet<ulong>();
HashSet<ulong> titleIdsToSave = new();
HashSet<ulong> titleIdsToRefresh = new();
// Remove any updates which can no longer be located on disk
Logger.Notice.Print(LogClass.Application, $"Removing non-existing Title Updates");
var updatesToRemove = _titleUpdates.Items
List<(TitleUpdateModel TitleUpdate, bool IsSelected)> updatesToRemove = _titleUpdates.Items
.Where(it => !File.Exists(it.TitleUpdate.Path))
.ToList();
@@ -1028,11 +1028,11 @@ namespace Ryujinx.UI.App.Common
return numUpdatesLoaded;
}
var fileInfo = new FileInfo(app);
FileInfo fileInfo = new(app);
try
{
var fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
string fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
updatePaths.Add(fullPath);
}
@@ -1050,7 +1050,7 @@ namespace Ryujinx.UI.App.Common
}
}
var appIdLookup = Applications.Items.Select(it => it.IdBase).ToHashSet();
HashSet<ulong> appIdLookup = Applications.Items.Select(it => it.IdBase).ToHashSet();
foreach (string updatePath in updatePaths)
{
@@ -1059,9 +1059,9 @@ namespace Ryujinx.UI.App.Common
return numUpdatesLoaded;
}
if (TryGetTitleUpdatesFromFile(updatePath, out var foundUpdates))
if (TryGetTitleUpdatesFromFile(updatePath, out List<TitleUpdateModel> foundUpdates))
{
foreach (var update in foundUpdates.Where(it => appIdLookup.Contains(it.TitleIdBase)))
foreach (TitleUpdateModel update in foundUpdates.Where(it => appIdLookup.Contains(it.TitleIdBase)))
{
if (!_titleUpdates.Lookup(update).HasValue)
{
@@ -1078,8 +1078,8 @@ namespace Ryujinx.UI.App.Common
}
}
foreach (var titleId in titleIdsToSave) SaveTitleUpdatesForGame(titleId);
foreach (var titleId in titleIdsToRefresh) RefreshApplicationInfo(titleId);
foreach (ulong titleId in titleIdsToSave) SaveTitleUpdatesForGame(titleId);
foreach (ulong titleId in titleIdsToRefresh) RefreshApplicationInfo(titleId);
}
finally
{
@@ -1097,8 +1097,8 @@ namespace Ryujinx.UI.App.Common
var currentlySelected = TitleUpdates.Items.FirstOrOptional(it =>
it.TitleUpdate.TitleIdBase == update.TitleIdBase && it.IsSelected);
var shouldSelect = !currentlySelected.HasValue ||
currentlySelected.Value.TitleUpdate.Version < update.Version;
bool shouldSelect = !currentlySelected.HasValue ||
currentlySelected.Value.TitleUpdate.Version < update.Version;
_titleUpdates.AddOrUpdate((update, shouldSelect));
@@ -1207,7 +1207,7 @@ namespace Ryujinx.UI.App.Common
}
else
{
var pfsTemp = new PartitionFileSystem();
PartitionFileSystem pfsTemp = new();
pfsTemp.Initialize(file.AsStorage()).ThrowIfFailure();
pfs = pfsTemp;
@@ -1241,7 +1241,7 @@ namespace Ryujinx.UI.App.Common
// Read the icon from the ControlFS and store it as a byte array
try
{
using var icon = new UniqueRef<IFile>();
using UniqueRef<IFile> icon = new();
controlFs?.OpenFile(ref icon.Ref, $"/icon_{desiredTitleLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure();
@@ -1259,7 +1259,7 @@ namespace Ryujinx.UI.App.Common
continue;
}
using var icon = new UniqueRef<IFile>();
using UniqueRef<IFile> icon = new();
controlFs?.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@@ -1459,16 +1459,16 @@ namespace Ryujinx.UI.App.Common
{
_downloadableContents.Edit(it =>
{
var savedDlc =
List<(DownloadableContentModel, bool IsEnabled)> savedDlc =
DownloadableContentsHelper.LoadDownloadableContentsJson(_virtualFileSystem, application.IdBase);
it.AddOrUpdate(savedDlc);
if (TryGetDownloadableContentFromFile(application.Path, out var bundledDlc))
if (TryGetDownloadableContentFromFile(application.Path, out List<DownloadableContentModel> bundledDlc))
{
var savedDlcLookup = savedDlc.Select(dlc => dlc.Item1).ToHashSet();
HashSet<DownloadableContentModel> savedDlcLookup = savedDlc.Select(dlc => dlc.Item1).ToHashSet();
bool addedNewDlc = false;
foreach (var dlc in bundledDlc)
foreach (DownloadableContentModel dlc in bundledDlc)
{
if (!savedDlcLookup.Contains(dlc))
{
@@ -1491,22 +1491,22 @@ namespace Ryujinx.UI.App.Common
// file itself
private bool LoadTitleUpdatesForApplication(ApplicationData application)
{
var modifiedVersion = false;
bool modifiedVersion = false;
_titleUpdates.Edit(it =>
{
var savedUpdates =
List<(TitleUpdateModel Update, bool IsSelected)> savedUpdates =
TitleUpdatesHelper.LoadTitleUpdatesJson(_virtualFileSystem, application.IdBase);
it.AddOrUpdate(savedUpdates);
var selectedUpdate = savedUpdates.FirstOrOptional(update => update.IsSelected);
if (TryGetTitleUpdatesFromFile(application.Path, out var bundledUpdates))
if (TryGetTitleUpdatesFromFile(application.Path, out List<TitleUpdateModel> bundledUpdates))
{
var savedUpdateLookup = savedUpdates.Select(update => update.Update).ToHashSet();
HashSet<TitleUpdateModel> savedUpdateLookup = savedUpdates.Select(update => update.Update).ToHashSet();
bool updatesChanged = false;
foreach (var update in bundledUpdates.OrderByDescending(bundled => bundled.Version))
foreach (TitleUpdateModel update in bundledUpdates.OrderByDescending(bundled => bundled.Version))
{
if (!savedUpdateLookup.Contains(update))
{
@@ -1540,14 +1540,14 @@ namespace Ryujinx.UI.App.Common
// Save the _currently tracked_ DLC state for the game
private void SaveDownloadableContentsForGame(ulong titleIdBase)
{
var dlcs = DownloadableContents.Items.Where(dlc => dlc.Dlc.TitleIdBase == titleIdBase).ToList();
List<(DownloadableContentModel Dlc, bool IsEnabled)> dlcs = DownloadableContents.Items.Where(dlc => dlc.Dlc.TitleIdBase == titleIdBase).ToList();
DownloadableContentsHelper.SaveDownloadableContentsJson(_virtualFileSystem, titleIdBase, dlcs);
}
// Save the _currently tracked_ update state for the game
private void SaveTitleUpdatesForGame(ulong titleIdBase)
{
var updates = TitleUpdates.Items.Where(update => update.TitleUpdate.TitleIdBase == titleIdBase).ToList();
List<(TitleUpdateModel TitleUpdate, bool IsSelected)> updates = TitleUpdates.Items.Where(update => update.TitleUpdate.TitleIdBase == titleIdBase).ToList();
TitleUpdatesHelper.SaveTitleUpdatesJson(_virtualFileSystem, titleIdBase, updates);
}
@@ -1555,7 +1555,7 @@ namespace Ryujinx.UI.App.Common
// of its state
private void RefreshApplicationInfo(ulong appIdBase)
{
var application = _applications.Lookup(appIdBase);
Optional<ApplicationData> application = _applications.Lookup(appIdBase);
if (!application.HasValue)
return;
@@ -1563,7 +1563,7 @@ namespace Ryujinx.UI.App.Common
if (!TryGetApplicationsFromFile(application.Value.Path, out List<ApplicationData> newApplications))
return;
var newApplication = newApplications.First(it => it.IdBase == appIdBase);
ApplicationData newApplication = newApplications.First(it => it.IdBase == appIdBase);
_applications.AddOrUpdate(newApplication);
}
}
@@ -1787,7 +1787,7 @@ namespace Ryujinx.UI.Common.Configuration
bool didPathUpdate = false;
{ // Game dirs
foreach (var gameDir in UI.GameDirs.Value)
foreach (string gameDir in UI.GameDirs.Value)
{
if (Directory.Exists(gameDir))
{
@@ -1806,7 +1806,7 @@ namespace Ryujinx.UI.Common.Configuration
existingDirs.Clear();
{ // Autoload dirs
foreach (var autoloadDir in UI.AutoloadDirs.Value)
foreach (string autoloadDir in UI.AutoloadDirs.Value)
{
if (Directory.Exists(autoloadDir))
{
@@ -67,12 +67,12 @@ namespace Ryujinx.UI.Common.Configuration
{
bool noFilter = e.NewValue.Length == 0;
foreach (var logClass in Enum.GetValues<LogClass>())
foreach (LogClass logClass in Enum.GetValues<LogClass>())
{
Logger.SetEnable(logClass, noFilter);
}
foreach (var logClass in e.NewValue)
foreach (LogClass logClass in e.NewValue)
{
Logger.SetEnable(logClass, true);
}
@@ -22,7 +22,7 @@ namespace Ryujinx.UI.Common.Helper
public static List<(DownloadableContentModel, bool IsEnabled)> LoadDownloadableContentsJson(VirtualFileSystem vfs, ulong applicationIdBase)
{
var downloadableContentJsonPath = PathToGameDLCJson(applicationIdBase);
string downloadableContentJsonPath = PathToGameDLCJson(applicationIdBase);
if (!File.Exists(downloadableContentJsonPath))
{
@@ -31,7 +31,7 @@ namespace Ryujinx.UI.Common.Helper
try
{
var downloadableContentContainerList = JsonHelper.DeserializeFromFile(downloadableContentJsonPath,
List<DownloadableContentContainer> downloadableContentContainerList = JsonHelper.DeserializeFromFile(downloadableContentJsonPath,
_serializerContext.ListDownloadableContentContainer);
return LoadDownloadableContents(vfs, downloadableContentContainerList);
}
@@ -76,13 +76,13 @@ namespace Ryujinx.UI.Common.Helper
downloadableContentContainerList.Add(container);
}
var downloadableContentJsonPath = PathToGameDLCJson(applicationIdBase);
string downloadableContentJsonPath = PathToGameDLCJson(applicationIdBase);
JsonHelper.SerializeToFile(downloadableContentJsonPath, downloadableContentContainerList, _serializerContext.ListDownloadableContentContainer);
}
private static List<(DownloadableContentModel, bool IsEnabled)> LoadDownloadableContents(VirtualFileSystem vfs, List<DownloadableContentContainer> downloadableContentContainers)
{
var result = new List<(DownloadableContentModel, bool IsEnabled)>();
List<(DownloadableContentModel, bool IsEnabled)> result = new();
foreach (DownloadableContentContainer downloadableContentContainer in downloadableContentContainers)
{
@@ -105,7 +105,7 @@ namespace Ryujinx.UI.Common.Helper
continue;
}
var content = new DownloadableContentModel(nca.Header.TitleId,
DownloadableContentModel content = new(nca.Header.TitleId,
downloadableContentContainer.ContainerPath,
downloadableContentNca.FullPath);
@@ -101,7 +101,7 @@ namespace Ryujinx.UI.Common.Helper
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@$"Software\Classes\{ext}");
var openCmd = key?.OpenSubKey(@"shell\open\command");
RegistryKey openCmd = key?.OpenSubKey(@"shell\open\command");
if (openCmd is null)
{
@@ -143,7 +143,7 @@ namespace Ryujinx.UI.Common.Helper
}
else
{
using var key = Registry.CurrentUser.CreateSubKey(keyString);
using RegistryKey key = Registry.CurrentUser.CreateSubKey(keyString);
if (key is null)
{
@@ -151,7 +151,7 @@ namespace Ryujinx.UI.Common.Helper
}
Logger.Debug?.Print(LogClass.Application, $"Adding type association {ext}");
using var openCmd = key.CreateSubKey(@"shell\open\command");
using RegistryKey openCmd = key.CreateSubKey(@"shell\open\command");
openCmd?.SetValue("", $"\"{Environment.ProcessPath}\" \"%1\"");
Logger.Debug?.Print(LogClass.Application, $"Added type association {ext}");
+1 -1
View File
@@ -24,7 +24,7 @@ namespace Ryujinx.UI.Common.Helper
return null;
}
foreach (var searchPath in pathVar.Split(":", StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries))
foreach (string searchPath in pathVar.Split(":", StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries))
{
string binaryPath = Path.Combine(searchPath, binary);
+2 -2
View File
@@ -57,7 +57,7 @@ namespace Ryujinx.UI.Common.Helper
{
ObjectiveC.NSString nsStringPath = new(path);
ObjectiveC.Object nsUrl = new("NSURL");
var urlPtr = nsUrl.GetFromMessage("fileURLWithPath:", nsStringPath);
ObjectiveC.Object urlPtr = nsUrl.GetFromMessage("fileURLWithPath:", nsStringPath);
ObjectiveC.Object nsArray = new("NSArray");
ObjectiveC.Object urlArray = nsArray.GetFromMessage("arrayWithObject:", urlPtr);
@@ -96,7 +96,7 @@ namespace Ryujinx.UI.Common.Helper
{
ObjectiveC.NSString nsStringPath = new(url);
ObjectiveC.Object nsUrl = new("NSURL");
var urlPtr = nsUrl.GetFromMessage("URLWithString:", nsStringPath);
ObjectiveC.Object urlPtr = nsUrl.GetFromMessage("URLWithString:", nsStringPath);
ObjectiveC.Object nsWorkspace = new("NSWorkspace");
ObjectiveC.Object sharedWorkspace = nsWorkspace.GetFromMessage("sharedWorkspace");
+10 -10
View File
@@ -18,11 +18,11 @@ namespace Ryujinx.UI.Common.Helper
iconPath += ".ico";
MemoryStream iconDataStream = new(iconData);
using var image = SKBitmap.Decode(iconDataStream);
using SKBitmap image = SKBitmap.Decode(iconDataStream);
image.Resize(new SKImageInfo(128, 128), SKFilterQuality.High);
SaveBitmapAsIcon(image, iconPath);
var shortcut = Shortcut.CreateShortcut(basePath, GetArgsString(applicationFilePath, applicationId), iconPath, 0);
Shortcut shortcut = Shortcut.CreateShortcut(basePath, GetArgsString(applicationFilePath, applicationId), iconPath, 0);
shortcut.StringData.NameString = cleanedAppName;
shortcut.WriteToFile(Path.Combine(desktopPath, cleanedAppName + ".lnk"));
}
@@ -31,12 +31,12 @@ namespace Ryujinx.UI.Common.Helper
private static void CreateShortcutLinux(string applicationFilePath, string applicationId, byte[] iconData, string iconPath, string desktopPath, string cleanedAppName)
{
string basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Ryujinx.sh");
var desktopFile = EmbeddedResources.ReadAllText("Ryujinx.UI.Common/shortcut-template.desktop");
string desktopFile = EmbeddedResources.ReadAllText("Ryujinx.UI.Common/shortcut-template.desktop");
iconPath += ".png";
var image = SKBitmap.Decode(iconData);
SKBitmap image = SKBitmap.Decode(iconData);
using var data = image.Encode(SKEncodedImageFormat.Png, 100);
using var file = File.OpenWrite(iconPath);
using FileStream file = File.OpenWrite(iconPath);
data.SaveTo(file);
using StreamWriter outputFile = new(Path.Combine(desktopPath, cleanedAppName + ".desktop"));
@@ -47,8 +47,8 @@ namespace Ryujinx.UI.Common.Helper
private static void CreateShortcutMacos(string appFilePath, string applicationId, byte[] iconData, string desktopPath, string cleanedAppName)
{
string basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Ryujinx");
var plistFile = EmbeddedResources.ReadAllText("Ryujinx.UI.Common/shortcut-template.plist");
var shortcutScript = EmbeddedResources.ReadAllText("Ryujinx.UI.Common/shortcut-launch-script.sh");
string plistFile = EmbeddedResources.ReadAllText("Ryujinx.UI.Common/shortcut-template.plist");
string shortcutScript = EmbeddedResources.ReadAllText("Ryujinx.UI.Common/shortcut-launch-script.sh");
// Macos .App folder
string contentFolderPath = Path.Combine("/Applications", cleanedAppName + ".app", "Contents");
string scriptFolderPath = Path.Combine(contentFolderPath, "MacOS");
@@ -77,9 +77,9 @@ namespace Ryujinx.UI.Common.Helper
}
const string IconName = "icon.png";
var image = SKBitmap.Decode(iconData);
SKBitmap image = SKBitmap.Decode(iconData);
using var data = image.Encode(SKEncodedImageFormat.Png, 100);
using var file = File.OpenWrite(Path.Combine(resourceFolderPath, IconName));
using FileStream file = File.OpenWrite(Path.Combine(resourceFolderPath, IconName));
data.SaveTo(file);
// plist file
@@ -124,7 +124,7 @@ namespace Ryujinx.UI.Common.Helper
private static string GetArgsString(string appFilePath, string applicationId)
{
// args are first defined as a list, for easier adjustments in the future
var argsList = new List<string>();
List<string> argsList = new();
if (!string.IsNullOrEmpty(CommandLineState.BaseDirPathArg))
{
@@ -30,7 +30,7 @@ namespace Ryujinx.UI.Common.Helper
public static List<(TitleUpdateModel Update, bool IsSelected)> LoadTitleUpdatesJson(VirtualFileSystem vfs, ulong applicationIdBase)
{
var titleUpdatesJsonPath = PathToGameUpdatesJson(applicationIdBase);
string titleUpdatesJsonPath = PathToGameUpdatesJson(applicationIdBase);
if (!File.Exists(titleUpdatesJsonPath))
{
@@ -39,7 +39,7 @@ namespace Ryujinx.UI.Common.Helper
try
{
var titleUpdateWindowData = JsonHelper.DeserializeFromFile(titleUpdatesJsonPath, _serializerContext.TitleUpdateMetadata);
TitleUpdateMetadata titleUpdateWindowData = JsonHelper.DeserializeFromFile(titleUpdatesJsonPath, _serializerContext.TitleUpdateMetadata);
return LoadTitleUpdates(vfs, titleUpdateWindowData, applicationIdBase);
}
catch
@@ -51,7 +51,7 @@ namespace Ryujinx.UI.Common.Helper
public static void SaveTitleUpdatesJson(VirtualFileSystem vfs, ulong applicationIdBase, List<(TitleUpdateModel, bool IsSelected)> updates)
{
var titleUpdateWindowData = new TitleUpdateMetadata
TitleUpdateMetadata titleUpdateWindowData = new()
{
Selected = "",
Paths = [],
@@ -73,13 +73,13 @@ namespace Ryujinx.UI.Common.Helper
}
}
var titleUpdatesJsonPath = PathToGameUpdatesJson(applicationIdBase);
string titleUpdatesJsonPath = PathToGameUpdatesJson(applicationIdBase);
JsonHelper.SerializeToFile(titleUpdatesJsonPath, titleUpdateWindowData, _serializerContext.TitleUpdateMetadata);
}
private static List<(TitleUpdateModel Update, bool IsSelected)> LoadTitleUpdates(VirtualFileSystem vfs, TitleUpdateMetadata titleUpdateMetadata, ulong applicationIdBase)
{
var result = new List<(TitleUpdateModel, bool IsSelected)>();
List<(TitleUpdateModel, bool IsSelected)> result = new();
IntegrityCheckLevel checkLevel = ConfigurationState.Instance.System.EnableFsIntegrityChecks
? IntegrityCheckLevel.ErrorOnInvalid
@@ -121,8 +121,8 @@ namespace Ryujinx.UI.Common.Helper
nacpFile.Get.Read(out _, 0, SpanHelpers.AsByteSpan(ref controlData), ReadOption.None)
.ThrowIfFailure();
var displayVersion = controlData.DisplayVersionString.ToString();
var update = new TitleUpdateModel(content.ApplicationId, content.Version.Version,
string displayVersion = controlData.DisplayVersionString.ToString();
TitleUpdateModel update = new(content.ApplicationId, content.Version.Version,
displayVersion, path);
result.Add((update, path == titleUpdateMetadata.Selected));
@@ -140,10 +140,10 @@ namespace Ryujinx.UI.Common.Helper
// An input string can either look like "01:23:45" or "1d, 01:23:45" if the timespan represents a duration of more than a day.
// Here, we split the input string to check if it's the former or the latter.
var valueSplit = timeSpanString.Split(", ");
string[] valueSplit = timeSpanString.Split(", ");
if (valueSplit.Length > 1)
{
var dayPart = valueSplit[0].Split("d")[0];
string dayPart = valueSplit[0].Split("d")[0];
if (int.TryParse(dayPart, out int days))
{
returnTimeSpan = returnTimeSpan.Add(TimeSpan.FromDays(days));
@@ -16,7 +16,7 @@ namespace Ryujinx.UI.Common.Models
{
public static XCITrimmerFileModel FromApplicationData(ApplicationData applicationData, XCIFileTrimmerLog logger)
{
var trimmer = new XCIFileTrimmer(applicationData.Path, logger);
XCIFileTrimmer trimmer = new(applicationData.Path, logger);
return new XCITrimmerFileModel(
applicationData.Name,
@@ -16,7 +16,7 @@ namespace Ryujinx.UI.Common.SystemInfo
if (cpuName == null)
{
var 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.UI.Common.SystemInfo
cpuName = cpuDict["model name"] ?? cpuDict["Processor"] ?? cpuDict["Hardware"] ?? "Unknown";
}
var memDict = new Dictionary<string, string>(StringComparer.Ordinal)
Dictionary<string, string> memDict = new(StringComparer.Ordinal)
{
["MemTotal"] = null,
["MemAvailable"] = null,
@@ -40,10 +40,10 @@ namespace Ryujinx.UI.Common.SystemInfo
static ulong GetVMInfoAvailableMemory()
{
var port = mach_host_self();
uint port = mach_host_self();
uint pageSize = 0;
var result = host_page_size(port, ref pageSize);
int result = host_page_size(port, ref pageSize);
if (result != 0)
{
@@ -34,7 +34,7 @@ namespace Ryujinx.UI.Common.SystemInfo
if (cpuObjs != null)
{
foreach (var cpuObj in cpuObjs)
foreach (ManagementBaseObject cpuObj in cpuObjs)
{
return cpuObj["Name"].ToString()?.Trim();
}