aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Ui.Common/App
diff options
context:
space:
mode:
authorTSRBerry <20988865+TSRBerry@users.noreply.github.com>2023-06-29 02:39:22 +0200
committerGitHub <noreply@github.com>2023-06-29 02:39:22 +0200
commit6e28a4dd13df0ab866e6a178086abe36ca4a2b25 (patch)
tree68e6b5f9e62212216cab071e5b9455550f2b971b /src/Ryujinx.Ui.Common/App
parent7c989f88bdab65dfa7783e824a180220ba829bd0 (diff)
[Ryujinx.Ui.Common] Address dotnet-format issues (#5392)
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Silence dotnet format IDE0060 warnings * Address dotnet format CA1401 warnings * dotnet-format fixes after rebase * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Another rebase, another dotnet format run * Run dotnet format style after rebase * Add comments to disabled warnings * Remove a few unused parameters * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Address IDE0251 warnings * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * Small optimizations * Remove alignment * Apply formatting * Fix build issues * Final pass for dotnet format * Add trailing commas Co-authored-by: Ac_K <Acoustik666@gmail.com> * Add trailing commas --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
Diffstat (limited to 'src/Ryujinx.Ui.Common/App')
-rw-r--r--src/Ryujinx.Ui.Common/App/ApplicationAddedEventArgs.cs2
-rw-r--r--src/Ryujinx.Ui.Common/App/ApplicationCountUpdatedEventArgs.cs4
-rw-r--r--src/Ryujinx.Ui.Common/App/ApplicationData.cs28
-rw-r--r--src/Ryujinx.Ui.Common/App/ApplicationJsonSerializerContext.cs2
-rw-r--r--src/Ryujinx.Ui.Common/App/ApplicationLibrary.cs68
-rw-r--r--src/Ryujinx.Ui.Common/App/ApplicationMetadata.cs4
6 files changed, 54 insertions, 54 deletions
diff --git a/src/Ryujinx.Ui.Common/App/ApplicationAddedEventArgs.cs b/src/Ryujinx.Ui.Common/App/ApplicationAddedEventArgs.cs
index 6ae7409a..78eed7af 100644
--- a/src/Ryujinx.Ui.Common/App/ApplicationAddedEventArgs.cs
+++ b/src/Ryujinx.Ui.Common/App/ApplicationAddedEventArgs.cs
@@ -6,4 +6,4 @@ namespace Ryujinx.Ui.App.Common
{
public ApplicationData AppData { get; set; }
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Ui.Common/App/ApplicationCountUpdatedEventArgs.cs b/src/Ryujinx.Ui.Common/App/ApplicationCountUpdatedEventArgs.cs
index 981a82d5..6a8e465e 100644
--- a/src/Ryujinx.Ui.Common/App/ApplicationCountUpdatedEventArgs.cs
+++ b/src/Ryujinx.Ui.Common/App/ApplicationCountUpdatedEventArgs.cs
@@ -4,7 +4,7 @@ namespace Ryujinx.Ui.App.Common
{
public class ApplicationCountUpdatedEventArgs : EventArgs
{
- public int NumAppsFound { get; set; }
+ public int NumAppsFound { get; set; }
public int NumAppsLoaded { get; set; }
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Ui.Common/App/ApplicationData.cs b/src/Ryujinx.Ui.Common/App/ApplicationData.cs
index 1081fcf3..e6130bda 100644
--- a/src/Ryujinx.Ui.Common/App/ApplicationData.cs
+++ b/src/Ryujinx.Ui.Common/App/ApplicationData.cs
@@ -18,19 +18,19 @@ namespace Ryujinx.Ui.App.Common
{
public class ApplicationData
{
- public bool Favorite { get; set; }
- public byte[] Icon { get; set; }
- public string TitleName { get; set; }
- public string TitleId { get; set; }
- public string Developer { get; set; }
- public string Version { get; set; }
- public string TimePlayed { get; set; }
- public double TimePlayedNum { get; set; }
- public DateTime? LastPlayed { get; set; }
- public string FileExtension { get; set; }
- public string FileSize { get; set; }
- public double FileSizeBytes { get; set; }
- public string Path { get; set; }
+ public bool Favorite { get; set; }
+ public byte[] Icon { get; set; }
+ public string TitleName { get; set; }
+ public string TitleId { get; set; }
+ public string Developer { get; set; }
+ public string Version { get; set; }
+ public string TimePlayed { get; set; }
+ public double TimePlayedNum { get; set; }
+ public DateTime? LastPlayed { get; set; }
+ public string FileExtension { get; set; }
+ public string FileSize { get; set; }
+ public double FileSizeBytes { get; set; }
+ public string Path { get; set; }
public BlitStruct<ApplicationControlProperty> ControlHolder { get; set; }
[JsonIgnore]
@@ -159,7 +159,7 @@ namespace Ryujinx.Ui.App.Common
codeFs.OpenFile(ref nsoFile.Ref, $"/{MainExeFs}".ToU8Span(), OpenMode.Read).ThrowIfFailure();
- NsoReader reader = new NsoReader();
+ NsoReader reader = new();
reader.Initialize(nsoFile.Release().AsStorage().AsFile(OpenMode.Read)).ThrowIfFailure();
return BitConverter.ToString(reader.Header.ModuleId.ItemsRo.ToArray()).Replace("-", "").ToUpper()[..16];
diff --git a/src/Ryujinx.Ui.Common/App/ApplicationJsonSerializerContext.cs b/src/Ryujinx.Ui.Common/App/ApplicationJsonSerializerContext.cs
index f81121c2..76eea33c 100644
--- a/src/Ryujinx.Ui.Common/App/ApplicationJsonSerializerContext.cs
+++ b/src/Ryujinx.Ui.Common/App/ApplicationJsonSerializerContext.cs
@@ -7,4 +7,4 @@ namespace Ryujinx.Ui.App.Common
internal partial class ApplicationJsonSerializerContext : JsonSerializerContext
{
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Ui.Common/App/ApplicationLibrary.cs b/src/Ryujinx.Ui.Common/App/ApplicationLibrary.cs
index 28280bd9..33e6c4aa 100644
--- a/src/Ryujinx.Ui.Common/App/ApplicationLibrary.cs
+++ b/src/Ryujinx.Ui.Common/App/ApplicationLibrary.cs
@@ -26,12 +26,13 @@ using System.Text;
using System.Text.Json;
using System.Threading;
using Path = System.IO.Path;
+using TimeSpan = System.TimeSpan;
namespace Ryujinx.Ui.App.Common
{
public class ApplicationLibrary
{
- public event EventHandler<ApplicationAddedEventArgs> ApplicationAdded;
+ public event EventHandler<ApplicationAddedEventArgs> ApplicationAdded;
public event EventHandler<ApplicationCountUpdatedEventArgs> ApplicationCountUpdated;
private readonly byte[] _nspIcon;
@@ -41,11 +42,11 @@ namespace Ryujinx.Ui.App.Common
private readonly byte[] _nsoIcon;
private readonly VirtualFileSystem _virtualFileSystem;
- private Language _desiredTitleLanguage;
- private CancellationTokenSource _cancellationToken;
+ private Language _desiredTitleLanguage;
+ private CancellationTokenSource _cancellationToken;
- private static readonly ApplicationJsonSerializerContext SerializerContext = new(JsonHelper.GetDefaultSerializerOptions());
- private static readonly TitleUpdateMetadataJsonSerializerContext TitleSerializerContext = new(JsonHelper.GetDefaultSerializerOptions());
+ private static readonly ApplicationJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
+ private static readonly TitleUpdateMetadataJsonSerializerContext _titleSerializerContext = new(JsonHelper.GetDefaultSerializerOptions());
public ApplicationLibrary(VirtualFileSystem virtualFileSystem)
{
@@ -60,7 +61,7 @@ namespace Ryujinx.Ui.App.Common
private static byte[] GetResourceBytes(string resourceName)
{
- Stream resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resourceName);
+ Stream resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resourceName);
byte[] resourceByteArray = new byte[resourceStream.Length];
resourceStream.Read(resourceByteArray);
@@ -83,7 +84,7 @@ namespace Ryujinx.Ui.App.Common
public void LoadApplications(List<string> appDirs, Language desiredTitleLanguage)
{
- int numApplicationsFound = 0;
+ int numApplicationsFound = 0;
int numApplicationsLoaded = 0;
_desiredTitleLanguage = desiredTitleLanguage;
@@ -114,14 +115,14 @@ namespace Ryujinx.Ui.App.Common
IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", SearchOption.AllDirectories).Where(file =>
{
return
- (Path.GetExtension(file).ToLower() is ".nsp" && ConfigurationState.Instance.Ui.ShownFileTypes.NSP.Value) ||
+ (Path.GetExtension(file).ToLower() is ".nsp" && ConfigurationState.Instance.Ui.ShownFileTypes.NSP.Value) ||
(Path.GetExtension(file).ToLower() is ".pfs0" && ConfigurationState.Instance.Ui.ShownFileTypes.PFS0.Value) ||
- (Path.GetExtension(file).ToLower() is ".xci" && ConfigurationState.Instance.Ui.ShownFileTypes.XCI.Value) ||
- (Path.GetExtension(file).ToLower() is ".nca" && ConfigurationState.Instance.Ui.ShownFileTypes.NCA.Value) ||
- (Path.GetExtension(file).ToLower() is ".nro" && ConfigurationState.Instance.Ui.ShownFileTypes.NRO.Value) ||
- (Path.GetExtension(file).ToLower() is ".nso" && ConfigurationState.Instance.Ui.ShownFileTypes.NSO.Value);
+ (Path.GetExtension(file).ToLower() is ".xci" && ConfigurationState.Instance.Ui.ShownFileTypes.XCI.Value) ||
+ (Path.GetExtension(file).ToLower() is ".nca" && ConfigurationState.Instance.Ui.ShownFileTypes.NCA.Value) ||
+ (Path.GetExtension(file).ToLower() is ".nro" && ConfigurationState.Instance.Ui.ShownFileTypes.NRO.Value) ||
+ (Path.GetExtension(file).ToLower() is ".nso" && ConfigurationState.Instance.Ui.ShownFileTypes.NSO.Value);
});
-
+
foreach (string app in files)
{
if (_cancellationToken.Token.IsCancellationRequested)
@@ -459,27 +460,27 @@ namespace Ryujinx.Ui.App.Common
FileSize = (fileSize < 1) ? (fileSize * 1024).ToString("0.##") + " MiB" : fileSize.ToString("0.##") + " GiB",
FileSizeBytes = fileSize,
Path = applicationPath,
- ControlHolder = controlHolder
+ ControlHolder = controlHolder,
};
numApplicationsLoaded++;
- OnApplicationAdded(new ApplicationAddedEventArgs()
+ OnApplicationAdded(new ApplicationAddedEventArgs
{
- AppData = data
+ AppData = data,
});
- OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs()
+ OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs
{
NumAppsFound = numApplicationsFound,
- NumAppsLoaded = numApplicationsLoaded
+ NumAppsLoaded = numApplicationsLoaded,
});
}
- OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs()
+ OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs
{
NumAppsFound = numApplicationsFound,
- NumAppsLoaded = numApplicationsLoaded
+ NumAppsLoaded = numApplicationsLoaded,
});
}
finally
@@ -505,13 +506,13 @@ namespace Ryujinx.Ui.App.Common
// Return the ControlFS
controlFs = controlNca?.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None);
- titleId = controlNca?.Header.TitleId.ToString("x16");
+ titleId = controlNca?.Header.TitleId.ToString("x16");
}
- public ApplicationMetadata LoadAndSaveMetaData(string titleId, Action<ApplicationMetadata> modifyFunction = null)
+ public static ApplicationMetadata LoadAndSaveMetaData(string titleId, Action<ApplicationMetadata> modifyFunction = null)
{
string metadataFolder = Path.Combine(AppDataManager.GamesDirPath, titleId, "gui");
- string metadataFile = Path.Combine(metadataFolder, "metadata.json");
+ string metadataFile = Path.Combine(metadataFolder, "metadata.json");
ApplicationMetadata appMetadata;
@@ -521,12 +522,12 @@ namespace Ryujinx.Ui.App.Common
appMetadata = new ApplicationMetadata();
- JsonHelper.SerializeToFile(metadataFile, appMetadata, SerializerContext.ApplicationMetadata);
+ JsonHelper.SerializeToFile(metadataFile, appMetadata, _serializerContext.ApplicationMetadata);
}
try
{
- appMetadata = JsonHelper.DeserializeFromFile(metadataFile, SerializerContext.ApplicationMetadata);
+ appMetadata = JsonHelper.DeserializeFromFile(metadataFile, _serializerContext.ApplicationMetadata);
}
catch (JsonException)
{
@@ -539,7 +540,7 @@ namespace Ryujinx.Ui.App.Common
{
modifyFunction(appMetadata);
- JsonHelper.SerializeToFile(metadataFile, appMetadata, SerializerContext.ApplicationMetadata);
+ JsonHelper.SerializeToFile(metadataFile, appMetadata, _serializerContext.ApplicationMetadata);
}
return appMetadata;
@@ -703,7 +704,7 @@ namespace Ryujinx.Ui.App.Common
}
}
}
- catch(Exception)
+ catch (Exception)
{
Logger.Warning?.Print(LogClass.Application, $"Could not retrieve a valid icon for the app. Default icon will be used. Errored File: {applicationPath}");
}
@@ -713,7 +714,7 @@ namespace Ryujinx.Ui.App.Common
private static string ConvertSecondsToFormattedString(double seconds)
{
- System.TimeSpan time = System.TimeSpan.FromSeconds(seconds);
+ TimeSpan time = TimeSpan.FromSeconds(seconds);
string timeString;
if (time.Days != 0)
@@ -840,7 +841,7 @@ namespace Ryujinx.Ui.App.Common
pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
- Nca nca = new Nca(fileSystem.KeySet, ncaFile.Release().AsStorage());
+ Nca nca = new(fileSystem.KeySet, ncaFile.Release().AsStorage());
int ncaProgramIndex = (int)(nca.Header.TitleId & 0xF);
@@ -884,7 +885,7 @@ namespace Ryujinx.Ui.App.Common
pfs.OpenFile(ref ncaFile.Ref, fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
- Nca nca = new Nca(fileSystem.KeySet, ncaFile.Release().AsStorage());
+ Nca nca = new(fileSystem.KeySet, ncaFile.Release().AsStorage());
int ncaProgramIndex = (int)(nca.Header.TitleId & 0xF);
@@ -925,12 +926,12 @@ namespace Ryujinx.Ui.App.Common
if (File.Exists(titleUpdateMetadataPath))
{
- updatePath = JsonHelper.DeserializeFromFile(titleUpdateMetadataPath, TitleSerializerContext.TitleUpdateMetadata).Selected;
+ updatePath = JsonHelper.DeserializeFromFile(titleUpdateMetadataPath, _titleSerializerContext.TitleUpdateMetadata).Selected;
if (File.Exists(updatePath))
{
- FileStream file = new FileStream(updatePath, FileMode.Open, FileAccess.Read);
- PartitionFileSystem nsp = new PartitionFileSystem(file.AsStorage());
+ FileStream file = new(updatePath, FileMode.Open, FileAccess.Read);
+ PartitionFileSystem nsp = new(file.AsStorage());
return GetGameUpdateDataFromPartition(fileSystem, nsp, titleIdBase.ToString("x16"), programIndex);
}
@@ -941,4 +942,3 @@ namespace Ryujinx.Ui.App.Common
}
}
}
-
diff --git a/src/Ryujinx.Ui.Common/App/ApplicationMetadata.cs b/src/Ryujinx.Ui.Common/App/ApplicationMetadata.cs
index 0abd4680..01b857a6 100644
--- a/src/Ryujinx.Ui.Common/App/ApplicationMetadata.cs
+++ b/src/Ryujinx.Ui.Common/App/ApplicationMetadata.cs
@@ -6,7 +6,7 @@ namespace Ryujinx.Ui.App.Common
public class ApplicationMetadata
{
public string Title { get; set; }
- public bool Favorite { get; set; }
+ public bool Favorite { get; set; }
public double TimePlayed { get; set; }
[JsonPropertyName("last_played_utc")]
@@ -16,4 +16,4 @@ namespace Ryujinx.Ui.App.Common
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string LastPlayedOld { get; set; }
}
-} \ No newline at end of file
+}