You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Convert.TryToHexString{Lower} will allow the destination that smaller than actual length and will NOT allow what is bigger than 2x actual length.
Reproduction Steps
Span<byte> hashBuffer = stackalloc byte[16];
Span<char> biggerThanDoubleLength = stackalloc char[33];
Debug.Assert(Convert.TryToHexString(hashBuffer, biggerThanDoubleLength, out _) == false);
Span<char> lessThanLength = stackalloc char[31];
Debug.Assert(Convert.TryToHexStringLower(hashBuffer, lessThanLength, out var length));
Debug.Assert(length == 32);
Console.WriteLine("done");
Expected behavior
The function may return false when the size of destination is smaller than 2x source and working when destination is bigger than 2x source.
Actual behavior
The function will return true when the size of destination is smaller than 2x source with proper out variable charsWritten and will NOT working when destination is bigger than 2x source.
Description
Convert.TryToHexString{Lower} will allow the destination that smaller than actual length and will NOT allow what is bigger than 2x actual length.
Reproduction Steps
Expected behavior
The function may return
false
when the size of destination is smaller than 2x source and working when destination is bigger than 2x source.Actual behavior
The function will return
true
when the size of destination is smaller than 2x source with proper out variablecharsWritten
and will NOT working when destination is bigger than 2x source.Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
It look like 2 variable is reversed.
runtime/src/libraries/System.Private.CoreLib/src/System/Convert.cs
Line 3102 in 1c4c009
runtime/src/libraries/System.Private.CoreLib/src/System/Convert.cs
Line 3179 in 1c4c009
The text was updated successfully, but these errors were encountered: