mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix build after package update
This commit is contained in:
@@ -78,7 +78,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
||||
private void ConvertGames(Models.ClrMamePro.GameBase[]? games, string filename, int indexId, bool statsOnly)
|
||||
private void ConvertGames(Models.ClrMamePro.GameBase?[]? games, string filename, int indexId, bool statsOnly)
|
||||
{
|
||||
// If the game array is missing, we can't do anything
|
||||
if (games == null || !games.Any())
|
||||
@@ -98,7 +98,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
||||
private void ConvertGame(Models.ClrMamePro.GameBase game, string filename, int indexId, bool statsOnly)
|
||||
private void ConvertGame(Models.ClrMamePro.GameBase? game, string filename, int indexId, bool statsOnly)
|
||||
{
|
||||
// If the game is missing, we can't do anything
|
||||
if (game == null)
|
||||
|
||||
@@ -23,25 +23,25 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Convert items
|
||||
switch (_hash)
|
||||
{
|
||||
case Hash.CRC:
|
||||
case Serialization.Hash.CRC:
|
||||
ConvertSFV(hashfile?.SFV, filename, indexId, statsOnly);
|
||||
break;
|
||||
case Hash.MD5:
|
||||
case Serialization.Hash.MD5:
|
||||
ConvertMD5(hashfile?.MD5, filename, indexId, statsOnly);
|
||||
break;
|
||||
case Hash.SHA1:
|
||||
case Serialization.Hash.SHA1:
|
||||
ConvertSHA1(hashfile?.SHA1, filename, indexId, statsOnly);
|
||||
break;
|
||||
case Hash.SHA256:
|
||||
case Serialization.Hash.SHA256:
|
||||
ConvertSHA256(hashfile?.SHA256, filename, indexId, statsOnly);
|
||||
break;
|
||||
case Hash.SHA384:
|
||||
case Serialization.Hash.SHA384:
|
||||
ConvertSHA384(hashfile?.SHA384, filename, indexId, statsOnly);
|
||||
break;
|
||||
case Hash.SHA512:
|
||||
case Serialization.Hash.SHA512:
|
||||
ConvertSHA512(hashfile?.SHA512, filename, indexId, statsOnly);
|
||||
break;
|
||||
case Hash.SpamSum:
|
||||
case Serialization.Hash.SpamSum:
|
||||
ConvertSpamSum(hashfile?.SpamSum, filename, indexId, statsOnly);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Check hash linked to specific Hashfile type
|
||||
switch (_hash)
|
||||
{
|
||||
case Hash.CRC:
|
||||
case Serialization.Hash.CRC:
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.Rom:
|
||||
@@ -48,7 +48,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Hash.MD5:
|
||||
case Serialization.Hash.MD5:
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.Disk:
|
||||
@@ -68,7 +68,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Hash.SHA1:
|
||||
case Serialization.Hash.SHA1:
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.Disk:
|
||||
@@ -88,7 +88,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Hash.SHA256:
|
||||
case Serialization.Hash.SHA256:
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.Media:
|
||||
@@ -104,7 +104,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Hash.SHA384:
|
||||
case Serialization.Hash.SHA384:
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.Rom:
|
||||
@@ -116,7 +116,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Hash.SHA512:
|
||||
case Serialization.Hash.SHA512:
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.Rom:
|
||||
@@ -128,7 +128,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Hash.SpamSum:
|
||||
case Serialization.Hash.SpamSum:
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.Media:
|
||||
@@ -185,25 +185,25 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
switch (_hash)
|
||||
{
|
||||
case Hash.CRC:
|
||||
case Serialization.Hash.CRC:
|
||||
hashfile.SFV = CreateSFV(ignoreblanks);
|
||||
break;
|
||||
case Hash.MD5:
|
||||
case Serialization.Hash.MD5:
|
||||
hashfile.MD5 = CreateMD5(ignoreblanks);
|
||||
break;
|
||||
case Hash.SHA1:
|
||||
case Serialization.Hash.SHA1:
|
||||
hashfile.SHA1 = CreateSHA1(ignoreblanks);
|
||||
break;
|
||||
case Hash.SHA256:
|
||||
case Serialization.Hash.SHA256:
|
||||
hashfile.SHA256 = CreateSHA256(ignoreblanks);
|
||||
break;
|
||||
case Hash.SHA384:
|
||||
case Serialization.Hash.SHA384:
|
||||
hashfile.SHA384 = CreateSHA384(ignoreblanks);
|
||||
break;
|
||||
case Hash.SHA512:
|
||||
case Serialization.Hash.SHA512:
|
||||
hashfile.SHA512 = CreateSHA512(ignoreblanks);
|
||||
break;
|
||||
case Hash.SpamSum:
|
||||
case Serialization.Hash.SpamSum:
|
||||
hashfile.SpamSum = CreateSpamSum(ignoreblanks);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
internal partial class Hashfile : DatFile
|
||||
{
|
||||
// Private instance variables specific to Hashfile DATs
|
||||
private readonly Hash _hash;
|
||||
private readonly Serialization.Hash _hash;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor designed for casting a base DatFile
|
||||
@@ -18,7 +18,25 @@ namespace SabreTools.DatFiles.Formats
|
||||
public Hashfile(DatFile? datFile, Hash hash)
|
||||
: base(datFile)
|
||||
{
|
||||
_hash = hash;
|
||||
_hash = ConvertHash(hash);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert hash types between internal and Serialization
|
||||
/// </summary>
|
||||
private Serialization.Hash ConvertHash(Hash hash)
|
||||
{
|
||||
return hash switch
|
||||
{
|
||||
Hash.CRC => Serialization.Hash.CRC,
|
||||
Hash.MD5 => Serialization.Hash.MD5,
|
||||
Hash.SHA1 => Serialization.Hash.SHA1,
|
||||
Hash.SHA256 => Serialization.Hash.SHA256,
|
||||
Hash.SHA384 => Serialization.Hash.SHA384,
|
||||
Hash.SHA512 => Serialization.Hash.SHA512,
|
||||
Hash.SpamSum => Serialization.Hash.SpamSum,
|
||||
_ => throw new System.ArgumentOutOfRangeException(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,14 +204,14 @@ namespace SabreTools.Test.Parser
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("test-sfv-files.sfv", Hash.CRC, 100)]
|
||||
[InlineData("test-md5-files.md5", Hash.MD5, 100)]
|
||||
[InlineData("test-sha1-files.sha1", Hash.SHA1, 100)]
|
||||
[InlineData("test-sha256.sha256", Hash.SHA256, 1)]
|
||||
[InlineData("test-sha384.sha384", Hash.SHA384, 1)]
|
||||
[InlineData("test-sha512.sha512", Hash.SHA512, 1)]
|
||||
[InlineData("test-spamsum.spamsum", Hash.SpamSum, 1)]
|
||||
public void HashfileDeserializeTest(string path, Hash hash, long count)
|
||||
[InlineData("test-sfv-files.sfv", Serialization.Hash.CRC, 100)]
|
||||
[InlineData("test-md5-files.md5", Serialization.Hash.MD5, 100)]
|
||||
[InlineData("test-sha1-files.sha1", Serialization.Hash.SHA1, 100)]
|
||||
[InlineData("test-sha256.sha256", Serialization.Hash.SHA256, 1)]
|
||||
[InlineData("test-sha384.sha384", Serialization.Hash.SHA384, 1)]
|
||||
[InlineData("test-sha512.sha512", Serialization.Hash.SHA512, 1)]
|
||||
[InlineData("test-spamsum.spamsum", Serialization.Hash.SpamSum, 1)]
|
||||
public void HashfileDeserializeTest(string path, Serialization.Hash hash, long count)
|
||||
{
|
||||
// Open the file for reading
|
||||
string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path);
|
||||
@@ -224,25 +224,25 @@ namespace SabreTools.Test.Parser
|
||||
|
||||
switch (hash)
|
||||
{
|
||||
case Hash.CRC:
|
||||
case Serialization.Hash.CRC:
|
||||
Assert.Equal(count, dat.SFV.Length);
|
||||
break;
|
||||
case Hash.MD5:
|
||||
case Serialization.Hash.MD5:
|
||||
Assert.Equal(count, dat.MD5.Length);
|
||||
break;
|
||||
case Hash.SHA1:
|
||||
case Serialization.Hash.SHA1:
|
||||
Assert.Equal(count, dat.SHA1.Length);
|
||||
break;
|
||||
case Hash.SHA256:
|
||||
case Serialization.Hash.SHA256:
|
||||
Assert.Equal(count, dat.SHA256.Length);
|
||||
break;
|
||||
case Hash.SHA384:
|
||||
case Serialization.Hash.SHA384:
|
||||
Assert.Equal(count, dat.SHA384.Length);
|
||||
break;
|
||||
case Hash.SHA512:
|
||||
case Serialization.Hash.SHA512:
|
||||
Assert.Equal(count, dat.SHA512.Length);
|
||||
break;
|
||||
case Hash.SpamSum:
|
||||
case Serialization.Hash.SpamSum:
|
||||
Assert.Equal(count, dat.SpamSum.Length);
|
||||
break;
|
||||
default:
|
||||
@@ -1005,7 +1005,7 @@ namespace SabreTools.Test.Parser
|
||||
string filename = System.IO.Path.Combine(Environment.CurrentDirectory, "TestData", path);
|
||||
|
||||
// Deserialize the file
|
||||
var dat = new Serialization.Files.SoftawreList().Deserialize(filename);
|
||||
var dat = new Serialization.Files.SoftwareList().Deserialize(filename);
|
||||
|
||||
// Validate the values
|
||||
Assert.NotNull(dat);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace SabreTools.Test.Parser
|
||||
var dat = GenerateOpenMSX();
|
||||
|
||||
// Deserialize the file
|
||||
var stream = new Serialization.Files.OpenMSX.SerializeToStream(dat) as System.IO.MemoryStream;
|
||||
var stream = new Serialization.Streams.OpenMSX().Serialize(dat) as System.IO.MemoryStream;
|
||||
|
||||
// Validate the values
|
||||
Assert.NotNull(stream);
|
||||
|
||||
Reference in New Issue
Block a user