Description
Description
This is a regression in .NET 7-RC1 to previous .NET versions, such as .NET 7-preview.7 and .NET 6
On Linux, with .NET 7-RC1, the ConsoleKeyInfo
returned from Console.ReadKey($true)
when pressing Ctrl+c has the value \0
for the KeyChar
property. With the previous .NET versions. the value of KeyChar
for the same operation is (char)3
.
Note that, on Windows, with either .NET 7-RC1 or previous .NET versions, the value of KeyChar
for the same operation is always (char)3
.
This prevents Ctrl+c from working in PowerShell running on .NET 7-RC.1
Reproduction Steps
Using PowerShell 7.3.0-preview.8, which is built against .NET SDK 7.0.100-rc.1.22431.12, on Ubuntu 18.04.
The TERM
env var is xterm-256color
, but you get the same result when setting the TERM
to rxvt
.
PS /> [Console]::TreatControlCAsInput = $true
PS /> $s = [System.Console]::ReadKey($true) ## Press 'Ctrl+c'
PS /> [int]$s.KeyChar
0
Expected behavior
For Ctrl+c, the returned ConsoleKeyInfo
should have KeyChar
with the value (char)3
.
The TERM
env var is xterm-256color
## This is the expected result when using .NET 7-preview.7 or .NET 6
PS:1> [console]::TreatControlCAsInput = $true
PS:2> $s = [console]::ReadKey($true)
PS:3> [int]$s.KeyChar
3
Actual behavior
PS /> [Console]::TreatControlCAsInput = $true
PS /> $s = [System.Console]::ReadKey($true) ## Press 'Ctrl+c'
PS /> [int]$s.KeyChar
0
Regression?
Yes. It's a regression in .NET 7-RC1 to previous .NET versions, including .NET 7-preview versions and .NET 6.
Known Workarounds
No known workaround.
Configuration
Which version of .NET is the code running on?
.NET SDK 7.0.100-rc.1.22431.12
Microsoft.NETCore.App 7.0.0-rc.1.22426.10
Host Version: 7.0.0-rc.1.22426.10
What OS and version, and what distro if applicable?
Ubuntu 18.04, WSLv2. x64
Other information
PowerShell 7.3.0-preview.8 runs on top of .NET 7-RC.1
PowerShell 7.3.0-preview.7 runs on top of .NET 7-preview.7
PowerShell 7.2.6 runs on top of the latest .NET 6