Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 36f750c

Browse files
Use Convert.FromHexString.
1 parent cde4cdb commit 36f750c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

‎src/MySqlConnector/Core/ServerSession.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Buffers;
12
using System.Buffers.Text;
23
using System.ComponentModel;
34
using System.Diagnostics;
@@ -686,6 +687,9 @@ private bool ValidateFingerprint(byte[]? validationHash, ReadOnlySpan<byte> chal
686687

687688
static bool TryConvertFromHexString(ReadOnlySpan<byte> hexChars, Span<byte> data)
688689
{
690+
#if NET10_0_OR_GREATER
691+
return Convert.FromHexString(hexChars, data, out _, out _) == OperationStatus.Done;
692+
#else
689693
ReadOnlySpan<byte> hexDigits = "0123456789ABCDEFabcdef"u8;
690694
for (var i = 0; i < hexChars.Length; i += 2)
691695
{
@@ -700,6 +704,7 @@ static bool TryConvertFromHexString(ReadOnlySpan<byte> hexChars, Span<byte> data
700704
data[i / 2] = (byte) ((high << 4) | low);
701705
}
702706
return true;
707+
#endif
703708
}
704709
}
705710

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /