From 49a0bcb001adf7f4ce5c01cab900a1f360e9f353 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 3 Oct 2026 08:26:49 +0200 Subject: [PATCH] CultCache: spell a version with APIs the netstandard Caching target has Convert.ToHexString and SHA256.HashData do not exist on the target. Co-Authored-By: Claude Sonnet 5.5 --- src/GameCult.Caching/CultCache.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/GameCult.Caching/CultCache.cs b/src/GameCult.Caching/CultCache.cs index da52a8bd..a15a1c84 100644 --- a/src/GameCult.Caching/CultCache.cs +++ b/src/GameCult.Caching/CultCache.cs @@ -3682,7 +3682,13 @@ namespace GameCult.Caching string.Equals(version, otherVersion, StringComparison.Ordinal); // The one spelling of a version in both store kinds: the lowercase hex of the SHA-256 of a record's persisted encoding. - protected static string VersionOf(byte[] sha256) => Convert.ToHexString(sha256).ToLowerInvariant(); + protected static string VersionOf(byte[] sha256) + { + var hex = new StringBuilder(sha256.Length * 2); + foreach (var value in sha256) + hex.Append(value.ToString("x2", CultureInfo.InvariantCulture)); + return hex.ToString(); + } // The one re-mint, for every store kind (storedat-on-change): a record written over one the store holds is stored at a storedAt // later than the one it replaces, whoever wrote that. The staged storedAt stands only when it is already later (both parsed @@ -3738,7 +3744,11 @@ namespace GameCult.Caching // One record's persisted encoding: the bytes a version names. protected abstract byte[] SerializeRecord(CultPersistedRecord record); - private string Version(CultPersistedRecord record) => VersionOf(SHA256.HashData(SerializeRecord(record))); + private string Version(CultPersistedRecord record) + { + using var sha256 = SHA256.Create(); + return VersionOf(sha256.ComputeHash(SerializeRecord(record))); + } /// /// This store's one reader of a non-empty store file, and so its one verdict on whether the file may be replaced: open,