mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix to not pass StringBuilder by reference (out or ref) in P/Invoke (#9066)
Don't pass StringBuilder by reference (using out or ref). Otherwise, the CLR will expect the signature of this argument to be wchar_t ** instead of wchar_t *, and it won't be able to pin StringBuilder's internal buffer. Performance will be significantly degraded.
This commit is contained in:
@@ -758,7 +758,7 @@ namespace Microsoft.PowerShell
|
||||
bool result =
|
||||
NativeMethods.ReadConsole(
|
||||
consoleHandle.DangerousGetHandle(),
|
||||
out buffer,
|
||||
buffer,
|
||||
(DWORD)charactersToRead,
|
||||
out charsReadUnused,
|
||||
ref control);
|
||||
@@ -3022,7 +3022,7 @@ namespace Microsoft.PowerShell
|
||||
internal static extern bool ReadConsole
|
||||
(
|
||||
NakedWin32Handle consoleInput,
|
||||
out StringBuilder buffer,
|
||||
StringBuilder buffer,
|
||||
DWORD numberOfCharsToRead,
|
||||
out DWORD numberOfCharsRead,
|
||||
ref CONSOLE_READCONSOLE_CONTROL controlData
|
||||
|
||||
Reference in New Issue
Block a user