diff --git a/RomRepoMgr.Core/Base32.cs b/RomRepoMgr.Core/Base32.cs
index 6de44c8..9237826 100644
--- a/RomRepoMgr.Core/Base32.cs
+++ b/RomRepoMgr.Core/Base32.cs
@@ -113,7 +113,7 @@ public static class Base32
if(base32String == null) return null;
// Check if empty
- if(base32String == string.Empty) return new byte[0];
+ if(base32String == string.Empty) return [];
// Convert to upper-case
string base32StringUpperCase = base32String.ToUpperInvariant();
diff --git a/RomRepoMgr.Core/Checksums/MD5Context.cs b/RomRepoMgr.Core/Checksums/MD5Context.cs
index 4f9e748..0c2b045 100644
--- a/RomRepoMgr.Core/Checksums/MD5Context.cs
+++ b/RomRepoMgr.Core/Checksums/MD5Context.cs
@@ -60,7 +60,7 @@ public sealed class Md5Context : IChecksum
/// Returns a byte array of the hash value.
public byte[] Final()
{
- _provider.TransformFinalBlock(new byte[0], 0, 0);
+ _provider.TransformFinalBlock([], 0, 0);
return _provider.Hash;
}
@@ -69,7 +69,7 @@ public sealed class Md5Context : IChecksum
/// Returns a hexadecimal representation of the hash value.
public string End()
{
- _provider.TransformFinalBlock(new byte[0], 0, 0);
+ _provider.TransformFinalBlock([], 0, 0);
var md5Output = new StringBuilder();
foreach(byte h in _provider.Hash) md5Output.Append(h.ToString("x2"));
diff --git a/RomRepoMgr.Core/Checksums/SHA1Context.cs b/RomRepoMgr.Core/Checksums/SHA1Context.cs
index 242b265..2e3050c 100644
--- a/RomRepoMgr.Core/Checksums/SHA1Context.cs
+++ b/RomRepoMgr.Core/Checksums/SHA1Context.cs
@@ -60,7 +60,7 @@ public sealed class Sha1Context : IChecksum
/// Returns a byte array of the hash value.
public byte[] Final()
{
- _provider.TransformFinalBlock(new byte[0], 0, 0);
+ _provider.TransformFinalBlock([], 0, 0);
return _provider.Hash;
}
@@ -69,7 +69,7 @@ public sealed class Sha1Context : IChecksum
/// Returns a hexadecimal representation of the hash value.
public string End()
{
- _provider.TransformFinalBlock(new byte[0], 0, 0);
+ _provider.TransformFinalBlock([], 0, 0);
var sha1Output = new StringBuilder();
foreach(byte h in _provider.Hash) sha1Output.Append(h.ToString("x2"));
diff --git a/RomRepoMgr.Core/Checksums/SHA256Context.cs b/RomRepoMgr.Core/Checksums/SHA256Context.cs
index 7df7414..c1449f5 100644
--- a/RomRepoMgr.Core/Checksums/SHA256Context.cs
+++ b/RomRepoMgr.Core/Checksums/SHA256Context.cs
@@ -60,7 +60,7 @@ public sealed class Sha256Context : IChecksum
/// Returns a byte array of the hash value.
public byte[] Final()
{
- _provider.TransformFinalBlock(new byte[0], 0, 0);
+ _provider.TransformFinalBlock([], 0, 0);
return _provider.Hash;
}
@@ -69,7 +69,7 @@ public sealed class Sha256Context : IChecksum
/// Returns a hexadecimal representation of the hash value.
public string End()
{
- _provider.TransformFinalBlock(new byte[0], 0, 0);
+ _provider.TransformFinalBlock([], 0, 0);
var sha256Output = new StringBuilder();
foreach(byte h in _provider.Hash) sha256Output.Append(h.ToString("x2"));
diff --git a/RomRepoMgr.Core/Checksums/SHA384Context.cs b/RomRepoMgr.Core/Checksums/SHA384Context.cs
index bfe47a9..437e2fd 100644
--- a/RomRepoMgr.Core/Checksums/SHA384Context.cs
+++ b/RomRepoMgr.Core/Checksums/SHA384Context.cs
@@ -60,7 +60,7 @@ public sealed class Sha384Context : IChecksum
/// Returns a byte array of the hash value.
public byte[] Final()
{
- _provider.TransformFinalBlock(new byte[0], 0, 0);
+ _provider.TransformFinalBlock([], 0, 0);
return _provider.Hash;
}
@@ -69,7 +69,7 @@ public sealed class Sha384Context : IChecksum
/// Returns a hexadecimal representation of the hash value.
public string End()
{
- _provider.TransformFinalBlock(new byte[0], 0, 0);
+ _provider.TransformFinalBlock([], 0, 0);
var sha384Output = new StringBuilder();
foreach(byte h in _provider.Hash) sha384Output.Append(h.ToString("x2"));
diff --git a/RomRepoMgr.Core/Checksums/SHA512Context.cs b/RomRepoMgr.Core/Checksums/SHA512Context.cs
index 7ed9df5..cb6492f 100644
--- a/RomRepoMgr.Core/Checksums/SHA512Context.cs
+++ b/RomRepoMgr.Core/Checksums/SHA512Context.cs
@@ -60,7 +60,7 @@ public sealed class Sha512Context : IChecksum
/// Returns a byte array of the hash value.
public byte[] Final()
{
- _provider.TransformFinalBlock(new byte[0], 0, 0);
+ _provider.TransformFinalBlock([], 0, 0);
return _provider.Hash;
}
@@ -69,7 +69,7 @@ public sealed class Sha512Context : IChecksum
/// Returns a hexadecimal representation of the hash value.
public string End()
{
- _provider.TransformFinalBlock(new byte[0], 0, 0);
+ _provider.TransformFinalBlock([], 0, 0);
var sha512Output = new StringBuilder();
foreach(byte h in _provider.Hash) sha512Output.Append(h.ToString("x2"));
diff --git a/RomRepoMgr.Core/Checksums/SpamSumContext.cs b/RomRepoMgr.Core/Checksums/SpamSumContext.cs
index d655f9b..8ea32e6 100644
--- a/RomRepoMgr.Core/Checksums/SpamSumContext.cs
+++ b/RomRepoMgr.Core/Checksums/SpamSumContext.cs
@@ -60,12 +60,12 @@ public sealed class SpamSumContext : IChecksum
//"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
readonly byte[] _b64 =
- {
+ [
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A,
0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31,
0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F
- };
+ ];
FuzzyState _self;
diff --git a/RomRepoMgr.Core/Filesystem/Winfsp.cs b/RomRepoMgr.Core/Filesystem/Winfsp.cs
index de388aa..940615e 100644
--- a/RomRepoMgr.Core/Filesystem/Winfsp.cs
+++ b/RomRepoMgr.Core/Filesystem/Winfsp.cs
@@ -415,19 +415,19 @@ public class Winfsp : FileSystemBase
ConcurrentDictionary cachedMachineMedias =
_vfs.GetMediasFromMachine(node.MachineId);
- node.Children = new List
- {
- new()
+ node.Children =
+ [
+ new FileEntry
{
FileName = ".",
Info = node.Info
},
- new()
+ new FileEntry
{
FileName = "..",
Info = node.ParentInfo
}
- };
+ ];
node.Children.AddRange(cachedMachineFiles.Select(file => new FileEntry
{
@@ -485,19 +485,19 @@ public class Winfsp : FileSystemBase
{
ConcurrentDictionary machines = _vfs.GetMachinesFromRomSet(node.RomSetId);
- node.Children = new List
- {
- new()
+ node.Children =
+ [
+ new FileEntry
{
FileName = ".",
Info = node.Info
},
- new()
+ new FileEntry
{
FileName = "..",
Info = node.ParentInfo
}
- };
+ ];
node.Children.AddRange(machines.Select(machine => new FileEntry
{
@@ -512,7 +512,7 @@ public class Winfsp : FileSystemBase
}
else
{
- node.Children = new List();
+ node.Children = [];
node.Children.AddRange(_vfs.GetRootEntries()
.Select(e => new FileEntry
diff --git a/RomRepoMgr.Core/Workers/DatImporter.cs b/RomRepoMgr.Core/Workers/DatImporter.cs
index 6b35210..88ddd9f 100644
--- a/RomRepoMgr.Core/Workers/DatImporter.cs
+++ b/RomRepoMgr.Core/Workers/DatImporter.cs
@@ -479,41 +479,41 @@ public sealed class DatImporter
? ctx.Files
.FromSqlRaw($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomCrc32Table}] AS t WHERE f.Crc32 = t.Crc32 AND f.Size = t.Size")
.ToList()
- : new List();
+ : [];
List pendingFilesByMd5List = romsHaveMd5
? ctx.Files
.FromSqlRaw($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomMd5Table}] AS t WHERE f.Md5 = t.Md5 AND f.Size = t.Size")
.ToList()
- : new List();
+ : [];
List pendingFilesBySha1List =
romsHaveSha1
? ctx.Files
.FromSqlRaw($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomSha1Table}] AS t WHERE f.Sha1 = t.Sha1 AND f.Size = t.Size")
.ToList()
- : new List();
+ : [];
List pendingFilesBySha256List =
romsHaveSha256
? ctx.Files
.FromSqlRaw($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomSha256Table}] AS t WHERE f.Sha256 = t.Sha256 AND f.Size = t.Size")
.ToList()
- : new List();
+ : [];
List pendingFilesBySha384List =
romsHaveSha384
? ctx.Files
.FromSqlRaw($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomSha384Table}] AS t WHERE f.Sha384 = t.Sha384 AND f.Size = t.Size")
.ToList()
- : new List();
+ : [];
List pendingFilesBySha512List =
romsHaveSha512
? ctx.Files
.FromSqlRaw($"SELECT DISTINCT f.* FROM Files AS f, [{tmpRomSha512Table}] AS t WHERE f.Sha512 = t.Sha512 AND f.Size = t.Size")
.ToList()
- : new List();
+ : [];
Dictionary pendingDisksByMd5 =
disksHaveMd5
@@ -756,40 +756,52 @@ public sealed class DatImporter
if(file == null && hashCollision)
{
if(rom.GetStringFieldValue(SabreTools.Models.Metadata.Rom.SHA512Key) != null)
+ {
file = pendingFiles.FirstOrDefault(f => f.Sha512 ==
rom.GetStringFieldValue(SabreTools.Models.Metadata.Rom
.SHA512Key) &&
f.Size == uSize);
+ }
if(file == null && rom.GetStringFieldValue(SabreTools.Models.Metadata.Rom.SHA384Key) != null)
+ {
file = pendingFiles.FirstOrDefault(f => f.Sha384 ==
rom.GetStringFieldValue(SabreTools.Models.Metadata.Rom
.SHA384Key) &&
f.Size == uSize);
+ }
if(file == null && rom.GetStringFieldValue(SabreTools.Models.Metadata.Rom.SHA256Key) != null)
+ {
file = pendingFiles.FirstOrDefault(f => f.Sha256 ==
rom.GetStringFieldValue(SabreTools.Models.Metadata.Rom
.SHA256Key) &&
f.Size == uSize);
+ }
if(file == null && rom.GetStringFieldValue(SabreTools.Models.Metadata.Rom.SHA1Key) != null)
+ {
file = pendingFiles.FirstOrDefault(f => f.Sha1 ==
rom.GetStringFieldValue(SabreTools.Models.Metadata.Rom
.SHA1Key) &&
f.Size == uSize);
+ }
if(file == null && rom.GetStringFieldValue(SabreTools.Models.Metadata.Rom.MD5Key) != null)
+ {
file = pendingFiles.FirstOrDefault(f => f.Md5 ==
rom.GetStringFieldValue(SabreTools.Models.Metadata.Rom
.MD5Key) &&
f.Size == uSize);
+ }
if(file == null && rom.GetStringFieldValue(SabreTools.Models.Metadata.Rom.CRCKey) != null)
+ {
file = pendingFiles.FirstOrDefault(f => f.Crc32 ==
rom.GetStringFieldValue(SabreTools.Models.Metadata.Rom
.CRCKey) &&
f.Size == uSize);
+ }
}
if(file == null)
@@ -991,12 +1003,16 @@ public sealed class DatImporter
DbDisk dbDisk = null;
if(disk.GetStringFieldValue(SabreTools.Models.Metadata.Disk.SHA1Key) != null && dbDisk == null)
+ {
pendingDisksBySha1.TryGetValue(disk.GetStringFieldValue(SabreTools.Models.Metadata.Disk.SHA1Key),
out dbDisk);
+ }
if(disk.GetStringFieldValue(SabreTools.Models.Metadata.Disk.MD5Key) != null && dbDisk == null)
+ {
pendingDisksByMd5.TryGetValue(disk.GetStringFieldValue(SabreTools.Models.Metadata.Disk.MD5Key),
out dbDisk);
+ }
if(dbDisk == null)
{
@@ -1115,17 +1131,23 @@ public sealed class DatImporter
DbMedia dbMedia = null;
if(media.GetStringFieldValue(SabreTools.Models.Metadata.Media.SHA256Key) != null && dbMedia == null)
+ {
pendingMediasBySha256.TryGetValue(media.GetStringFieldValue(SabreTools.Models.Metadata.Media
.SHA256Key),
out dbMedia);
+ }
if(media.GetStringFieldValue(SabreTools.Models.Metadata.Media.SHA1Key) != null && dbMedia == null)
+ {
pendingMediasBySha1.TryGetValue(media.GetStringFieldValue(SabreTools.Models.Metadata.Media.SHA1Key),
out dbMedia);
+ }
if(media.GetStringFieldValue(SabreTools.Models.Metadata.Media.MD5Key) != null && dbMedia == null)
+ {
pendingMediasByMd5.TryGetValue(media.GetStringFieldValue(SabreTools.Models.Metadata.Media.MD5Key),
out dbMedia);
+ }
// TODO: SpamSum
if(dbMedia == null)
diff --git a/RomRepoMgr.Core/Workers/FileImporter.cs b/RomRepoMgr.Core/Workers/FileImporter.cs
index b3680b4..7bcdbf6 100644
--- a/RomRepoMgr.Core/Workers/FileImporter.cs
+++ b/RomRepoMgr.Core/Workers/FileImporter.cs
@@ -45,9 +45,9 @@ public class FileImporter
_pendingMediasBySha256 = new Dictionary();
_pendingMediasBySha1 = new Dictionary();
_pendingMediasByMd5 = new Dictionary();
- _newFiles = new List();
- _newDisks = new List();
- _newMedias = new List();
+ _newFiles = [];
+ _newDisks = [];
+ _newMedias = [];
_onlyKnown = onlyKnown;
_deleteAfterImport = deleteAfterImport;
_position = 0;
diff --git a/RomRepoMgr.Settings/Interop/Version.cs b/RomRepoMgr.Settings/Interop/Version.cs
index 18b7999..84c34cc 100644
--- a/RomRepoMgr.Settings/Interop/Version.cs
+++ b/RomRepoMgr.Settings/Interop/Version.cs
@@ -52,11 +52,7 @@ public static class Version
{
Assembly assembly = typeof(GCSettings).Assembly;
- string[] assemblyPath = assembly.Location.Split(new[]
- {
- '/', '\\'
- },
- StringSplitOptions.RemoveEmptyEntries);
+ string[] assemblyPath = assembly.Location.Split(['/', '\\'], StringSplitOptions.RemoveEmptyEntries);
int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App");
diff --git a/RomRepoMgr/ViewModels/AboutViewModel.cs b/RomRepoMgr/ViewModels/AboutViewModel.cs
index 9fa6455..89acbbe 100644
--- a/RomRepoMgr/ViewModels/AboutViewModel.cs
+++ b/RomRepoMgr/ViewModels/AboutViewModel.cs
@@ -56,7 +56,7 @@ public sealed class AboutViewModel : ViewModelBase
LicenseCommand = ReactiveCommand.Create(ExecuteLicenseCommand);
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
- Assemblies = new ObservableCollection();
+ Assemblies = [];
// TODO: They do not load in time
Task.Run(() =>
diff --git a/RomRepoMgr/ViewModels/ImportDatFolderViewModel.cs b/RomRepoMgr/ViewModels/ImportDatFolderViewModel.cs
index 1735d65..1c34f64 100644
--- a/RomRepoMgr/ViewModels/ImportDatFolderViewModel.cs
+++ b/RomRepoMgr/ViewModels/ImportDatFolderViewModel.cs
@@ -70,7 +70,7 @@ public sealed class ImportDatFolderViewModel : ViewModelBase
FolderPath = folderPath;
_allFilesChecked = false;
_recursiveChecked = true;
- ImportResults = new ObservableCollection();
+ ImportResults = [];
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
}
diff --git a/RomRepoMgr/ViewModels/ImportRomFolderViewModel.cs b/RomRepoMgr/ViewModels/ImportRomFolderViewModel.cs
index 5174fad..5404c18 100644
--- a/RomRepoMgr/ViewModels/ImportRomFolderViewModel.cs
+++ b/RomRepoMgr/ViewModels/ImportRomFolderViewModel.cs
@@ -68,7 +68,7 @@ public sealed class ImportRomFolderViewModel : ViewModelBase
_removeFilesChecked = false;
_knownOnlyChecked = true;
_recurseArchivesChecked = Settings.Settings.UnArUsable;
- ImportResults = new ObservableCollection();
+ ImportResults = [];
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
IsReady = true;
diff --git a/RomRepoMgr/ViewModels/MainWindowViewModel.cs b/RomRepoMgr/ViewModels/MainWindowViewModel.cs
index 7364b82..45217a4 100644
--- a/RomRepoMgr/ViewModels/MainWindowViewModel.cs
+++ b/RomRepoMgr/ViewModels/MainWindowViewModel.cs
@@ -162,21 +162,14 @@ public class MainWindowViewModel : ViewModelBase
dlgOpen.Filters.Add(new FileDialogFilter
{
- Extensions = new List
- {
- "dat",
- "xml"
- },
- Name = Localization.DatFilesDialogLabel
+ Extensions = ["dat", "xml"],
+ Name = Localization.DatFilesDialogLabel
});
dlgOpen.Filters.Add(new FileDialogFilter
{
- Extensions = new List
- {
- "*"
- },
- Name = Localization.AllFilesDialogLabel
+ Extensions = ["*"],
+ Name = Localization.AllFilesDialogLabel
});
string[] result = await dlgOpen.ShowAsync(_view);
diff --git a/RomRepoMgr/ViewModels/UpdateStatsViewModel.cs b/RomRepoMgr/ViewModels/UpdateStatsViewModel.cs
index 5246262..7662066 100644
--- a/RomRepoMgr/ViewModels/UpdateStatsViewModel.cs
+++ b/RomRepoMgr/ViewModels/UpdateStatsViewModel.cs
@@ -57,7 +57,7 @@ public sealed class UpdateStatsViewModel : ViewModelBase
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
IndeterminateProgress = true;
ProgressVisible = false;
- RomSets = new ObservableCollection();
+ RomSets = [];
}
public string Title => Localization.UpdateStatsTitle;