misc: chore: Use explicit types in the Avalonia project

This commit is contained in:
Evan Husted
2025-01-25 14:00:23 -06:00
parent 3b5f6170d1
commit be3bd0bcb5
69 changed files with 367 additions and 348 deletions

View File

@@ -76,14 +76,14 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
}
else
{
var pfsTemp = new PartitionFileSystem();
PartitionFileSystem pfsTemp = new PartitionFileSystem();
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 UniqueRef<IFile>();
pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@@ -158,7 +158,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return string.Empty;
}
using var nsoFile = new UniqueRef<IFile>();
using UniqueRef<IFile> nsoFile = new UniqueRef<IFile>();
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)
{
var applications = new List<ApplicationData>();
List<ApplicationData> applications = new List<ApplicationData>();
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 var icon = new UniqueRef<IFile>();
using UniqueRef<IFile> icon = new UniqueRef<IFile>();
controlFs.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@@ -313,7 +313,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
case ".nsp":
case ".pfs0":
{
var pfs = new PartitionFileSystem();
PartitionFileSystem pfs = new PartitionFileSystem();
pfs.Initialize(file.AsStorage()).ThrowIfFailure();
ApplicationData result = GetApplicationFromNsp(pfs, applicationPath);
@@ -438,7 +438,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return false;
}
foreach (var data in applications)
foreach (ApplicationData data in applications)
{
// Only load metadata for applications with an ID
if (data.Id != 0)
@@ -501,7 +501,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca"))
{
using var ncaFile = new UniqueRef<IFile>();
using UniqueRef<IFile> ncaFile = new UniqueRef<IFile>();
pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@@ -588,8 +588,8 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
nacpFile.Get.Read(out _, 0, LibHac.Common.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 TitleUpdateModel(content.ApplicationId, content.Version.Version,
displayVersion, filePath);
titleUpdates.Add(update);
@@ -685,11 +685,11 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return;
}
var fileInfo = new FileInfo(app);
FileInfo fileInfo = new FileInfo(app);
try
{
var fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
string fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
applicationPaths.Add(fullPath);
numApplicationsFound++;
@@ -719,7 +719,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
{
_applications.Edit(it =>
{
foreach (var application in applications)
foreach (ApplicationData application in applications)
{
it.AddOrUpdate(application);
LoadDlcForApplication(application);
@@ -840,7 +840,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
try
{
// Remove any downloadable content which can no longer be located on disk
var dlcToRemove = _downloadableContents.Items
List<(DownloadableContentModel Dlc, bool IsEnabled)> dlcToRemove = _downloadableContents.Items
.Where(dlc => !File.Exists(dlc.Dlc.ContainerPath))
.ToList();
dlcToRemove.ForEach(dlc =>
@@ -882,11 +882,11 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return newDlcLoaded;
}
var fileInfo = new FileInfo(app);
FileInfo fileInfo = new FileInfo(app);
try
{
var fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
string fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
dlcPaths.Add(fullPath);
}
@@ -904,7 +904,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
}
}
var appIdLookup = Applications.Items.Select(it => it.IdBase).ToHashSet();
HashSet<ulong> appIdLookup = Applications.Items.Select(it => it.IdBase).ToHashSet();
foreach (string dlcPath in dlcPaths)
{
@@ -913,9 +913,9 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
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)
{
@@ -949,11 +949,11 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
try
{
var titleIdsToSave = new HashSet<ulong>();
var titleIdsToRefresh = new HashSet<ulong>();
HashSet<ulong> titleIdsToSave = new HashSet<ulong>();
HashSet<ulong> titleIdsToRefresh = new HashSet<ulong>();
// Remove any updates which can no longer be located on disk
var updatesToRemove = _titleUpdates.Items
List<(TitleUpdateModel TitleUpdate, bool IsSelected)> updatesToRemove = _titleUpdates.Items
.Where(it => !File.Exists(it.TitleUpdate.Path))
.ToList();
@@ -998,11 +998,11 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
return numUpdatesLoaded;
}
var fileInfo = new FileInfo(app);
FileInfo fileInfo = new FileInfo(app);
try
{
var fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
string fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
updatePaths.Add(fullPath);
}
@@ -1020,7 +1020,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
}
}
var appIdLookup = Applications.Items.Select(it => it.IdBase).ToHashSet();
HashSet<ulong> appIdLookup = Applications.Items.Select(it => it.IdBase).ToHashSet();
foreach (string updatePath in updatePaths)
{
@@ -1029,9 +1029,9 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
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)
{
@@ -1063,12 +1063,12 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
private bool AddAndAutoSelectUpdate(TitleUpdateModel update)
{
if (update == null) return false;
var currentlySelected = TitleUpdates.Items.FirstOrOptional(it =>
DynamicData.Kernel.Optional<(TitleUpdateModel TitleUpdate, bool IsSelected)> 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));
@@ -1170,7 +1170,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
}
else
{
var pfsTemp = new PartitionFileSystem();
PartitionFileSystem pfsTemp = new PartitionFileSystem();
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 var icon = new UniqueRef<IFile>();
using UniqueRef<IFile> icon = new UniqueRef<IFile>();
controlFs.OpenFile(ref icon.Ref, $"/icon_{desiredTitleLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure();
@@ -1222,7 +1222,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
continue;
}
using var icon = new UniqueRef<IFile>();
using UniqueRef<IFile> icon = new UniqueRef<IFile>();
controlFs.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
@@ -1330,7 +1330,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
if (string.IsNullOrWhiteSpace(data.Name))
{
foreach (ref readonly var controlTitle in controlData.Title.ItemsRo)
foreach (ref readonly ApplicationControlProperty.ApplicationTitle controlTitle in controlData.Title.ItemsRo)
{
if (!controlTitle.NameString.IsEmpty())
{
@@ -1343,7 +1343,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
if (string.IsNullOrWhiteSpace(data.Developer))
{
foreach (ref readonly var controlTitle in controlData.Title.ItemsRo)
foreach (ref readonly ApplicationControlProperty.ApplicationTitle controlTitle in controlData.Title.ItemsRo)
{
if (!controlTitle.PublisherString.IsEmpty())
{
@@ -1419,16 +1419,16 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
{
_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))
{
@@ -1439,7 +1439,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
if (addedNewDlc)
{
var gameDlcs = it.Items.Where(dlc => dlc.Dlc.TitleIdBase == application.IdBase).ToList();
List<(DownloadableContentModel Dlc, bool IsEnabled)> gameDlcs = it.Items.Where(dlc => dlc.Dlc.TitleIdBase == application.IdBase).ToList();
DownloadableContentsHelper.SaveDownloadableContentsJson(application.IdBase,
gameDlcs);
}
@@ -1451,22 +1451,22 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
// 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);
DynamicData.Kernel.Optional<(TitleUpdateModel Update, bool IsSelected)> 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))
{
@@ -1488,7 +1488,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
if (updatesChanged)
{
var gameUpdates = it.Items.Where(update => update.TitleUpdate.TitleIdBase == application.IdBase).ToList();
List<(TitleUpdateModel TitleUpdate, bool IsSelected)> gameUpdates = it.Items.Where(update => update.TitleUpdate.TitleIdBase == application.IdBase).ToList();
TitleUpdatesHelper.SaveTitleUpdatesJson(application.IdBase, gameUpdates);
}
}
@@ -1500,14 +1500,14 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
// 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(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(titleIdBase, updates);
}
@@ -1515,7 +1515,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
// of its state
private void RefreshApplicationInfo(ulong appIdBase)
{
var application = _applications.Lookup(appIdBase);
DynamicData.Kernel.Optional<ApplicationData> application = _applications.Lookup(appIdBase);
if (!application.HasValue)
return;
@@ -1523,7 +1523,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
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);
}
}

View File

@@ -88,7 +88,7 @@ namespace Ryujinx.Ava.Utilities.Compat
_ => null
};
if (DateTime.TryParse(ColStr(row[indices.LastUpdated]), out var dt))
if (DateTime.TryParse(ColStr(row[indices.LastUpdated]), out DateTime dt))
LastUpdated = dt;
return;

View File

@@ -661,7 +661,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
if (!ShowDirtyHacks)
return;
var newHacks = EnabledHacks.Select(x => x.Hack)
string newHacks = EnabledHacks.Select(x => x.Hack)
.JoinToString(", ");
if (newHacks != _lastHackCollection)

View File

@@ -31,12 +31,12 @@ namespace Ryujinx.Ava.Utilities.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);
}

View File

@@ -22,7 +22,7 @@ namespace Ryujinx.Ava.Utilities
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.Ava.Utilities
try
{
var downloadableContentContainerList = JsonHelper.DeserializeFromFile(downloadableContentJsonPath,
List<DownloadableContentContainer> downloadableContentContainerList = JsonHelper.DeserializeFromFile(downloadableContentJsonPath,
_serializerContext.ListDownloadableContentContainer);
return LoadDownloadableContents(vfs, downloadableContentContainerList);
}
@@ -76,13 +76,13 @@ namespace Ryujinx.Ava.Utilities
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 List<(DownloadableContentModel, bool IsEnabled)>();
foreach (DownloadableContentContainer downloadableContentContainer in downloadableContentContainers)
{
@@ -105,7 +105,7 @@ namespace Ryujinx.Ava.Utilities
continue;
}
var content = new DownloadableContentModel(nca.Header.TitleId,
DownloadableContentModel content = new DownloadableContentModel(nca.Header.TitleId,
downloadableContentContainer.ContainerPath,
downloadableContentNca.FullPath);

View File

@@ -18,11 +18,11 @@ namespace Ryujinx.Ava.Utilities
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.Ava.Utilities
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/Assets/ShortcutFiles/shortcut-template.desktop");
string desktopFile = EmbeddedResources.ReadAllText("Ryujinx/Assets/ShortcutFiles/shortcut-template.desktop");
iconPath += ".png";
var image = SKBitmap.Decode(iconData);
using var data = image.Encode(SKEncodedImageFormat.Png, 100);
using var file = File.OpenWrite(iconPath);
SKBitmap image = SKBitmap.Decode(iconData);
using SKData data = image.Encode(SKEncodedImageFormat.Png, 100);
using FileStream file = File.OpenWrite(iconPath);
data.SaveTo(file);
using StreamWriter outputFile = new(Path.Combine(desktopPath, cleanedAppName + ".desktop"));
@@ -47,8 +47,8 @@ namespace Ryujinx.Ava.Utilities
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/Assets/ShortcutFiles/shortcut-template.plist");
var shortcutScript = EmbeddedResources.ReadAllText("Ryujinx/Assets/ShortcutFiles/shortcut-launch-script.sh");
string plistFile = EmbeddedResources.ReadAllText("Ryujinx/Assets/ShortcutFiles/shortcut-template.plist");
string shortcutScript = EmbeddedResources.ReadAllText("Ryujinx/Assets/ShortcutFiles/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.Ava.Utilities
}
const string IconName = "icon.png";
var image = SKBitmap.Decode(iconData);
using var data = image.Encode(SKEncodedImageFormat.Png, 100);
using var file = File.OpenWrite(Path.Combine(resourceFolderPath, IconName));
SKBitmap image = SKBitmap.Decode(iconData);
using SKData data = image.Encode(SKEncodedImageFormat.Png, 100);
using FileStream file = File.OpenWrite(Path.Combine(resourceFolderPath, IconName));
data.SaveTo(file);
// plist 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
var argsList = new List<string>();
List<string> argsList = new List<string>();
if (!string.IsNullOrEmpty(CommandLineState.BaseDirPathArg))
{
@@ -157,7 +157,7 @@ namespace Ryujinx.Ava.Utilities
fs.Write(header);
// Writing actual data
using var data = source.Encode(SKEncodedImageFormat.Png, 100);
using SKData data = source.Encode(SKEncodedImageFormat.Png, 100);
data.SaveTo(fs);
// Getting data length (file length minus header)
long dataLength = fs.Length - header.Length;

View File

@@ -16,7 +16,7 @@ namespace Ryujinx.Ava.Utilities.SystemInfo
if (cpuName == null)
{
var cpuDict = new Dictionary<string, string>(StringComparer.Ordinal)
Dictionary<string, string> cpuDict = new Dictionary<string, string>(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";
}
var memDict = new Dictionary<string, string>(StringComparer.Ordinal)
Dictionary<string, string> memDict = new Dictionary<string, string>(StringComparer.Ordinal)
{
["MemTotal"] = null,
["MemAvailable"] = null,

View File

@@ -40,10 +40,10 @@ namespace Ryujinx.Ava.Utilities.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)
{

View File

@@ -34,7 +34,7 @@ namespace Ryujinx.Ava.Utilities.SystemInfo
if (cpuObjs != null)
{
foreach (var cpuObj in cpuObjs)
foreach (ManagementBaseObject cpuObj in cpuObjs)
{
return cpuObj["Name"].ToString().Trim();
}

View File

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

View File

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