Convert HashType from enum to static class with constants

Because the ordering of the enum was not guaranteed, both because of variances in .NET version and even library version, any change could mean that invisible version bumps would misalign. This attempts to fix that by converting HashType from an enum to a static class with a set of constants instead. This allows logical groupings and orderings without it affecting the values of each item.
This commit is contained in:
Matt Nadareski
2026-03-20 00:18:40 -04:00
parent 41efdaaf35
commit 00a5c6c2c5
10 changed files with 470 additions and 301 deletions

View File

@@ -13,7 +13,7 @@ namespace SabreTools.Hashing.Test
private const long _hashFileSize = 125;
private static readonly Dictionary<HashType, string> _knownHashes = new()
private static readonly Dictionary<string, string> _knownHashes = new()
{
{HashType.Adler32, "08562d95"},
@@ -224,7 +224,7 @@ namespace SabreTools.Hashing.Test
/// <summary>
/// Validate the hashes in a hash dictionary
/// </summary>
public static void ValidateHashes(Dictionary<HashType, string?>? hashDict)
public static void ValidateHashes(Dictionary<string, string?>? hashDict)
{
Assert.NotNull(hashDict);
foreach (var hashType in _knownHashes.Keys)
@@ -236,7 +236,7 @@ namespace SabreTools.Hashing.Test
/// <summary>
/// Validate a single hash
/// </summary>
public static void ValidateHash(HashType hashType, string? hashValue)
public static void ValidateHash(string hashType, string? hashValue)
=> Assert.Equal(_knownHashes[hashType], hashValue);
/// <summary>