Skip to content

Commit c54b149

Browse files
Fix .NET 7 build warnings
1 parent 8d25c97 commit c54b149

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/ImageSharp.Web/Caching/SHA256CacheHash.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@ public string Create(string value, uint length)
5656
[MethodImpl(MethodImplOptions.AggressiveInlining)]
5757
private static string HashValue(ReadOnlySpan<char> value, uint length, Span<byte> bufferSpan)
5858
{
59-
using var hashAlgorithm = SHA256.Create();
6059
Encoding.ASCII.GetBytes(value, bufferSpan);
6160

6261
// Hashed output maxes out at 32 bytes @ 256bit/8 so we're safe to use stackalloc
6362
Span<byte> hash = stackalloc byte[32];
64-
hashAlgorithm.TryComputeHash(bufferSpan, hash, out int _);
63+
SHA256.TryHashData(bufferSpan, hash, out int _);
6564

6665
// Length maxes out at 64 since we throw if options is greater
67-
return HexEncoder.Encode(hash.Slice(0, (int)(length / 2)));
66+
return HexEncoder.Encode(hash[..(int)(length / 2)]);
6867
}
6968
}

src/ImageSharp.Web/Commands/Converters/ColorConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public Color ConvertFrom(CommandParser parser, CultureInfo culture, string value
7979

8080
// Named colors
8181
IDictionary<string, Color> table = ColorConstantsTable.Value;
82-
return table.ContainsKey(value) ? table[value] : default;
82+
return table.TryGetValue(value, out Color color) ? color : default;
8383
}
8484

8585
private static IDictionary<string, Color> InitializeColorConstantsTable()

0 commit comments

Comments
 (0)