8000 On Linux, the `KeyChar` of the `ConsoleKeyInfo` returned from `Ctrl+c` becomes `\0` with .NET 7-RC.1 · Issue #75795 · dotnet/runtime · GitHub
[go: up one dir, main page]

Skip to content

On Linux, the KeyChar of the ConsoleKeyInfo returned from Ctrl+c becomes \0 with .NET 7-RC.1 #75795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
daxian-dbw opened this issue Sep 17, 2022 · 3 comments · Fixed by #75853

Comments

@daxian-dbw
Copy link
Contributor

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

image

PowerShell 7.3.0-preview.7 runs on top of .NET 7-preview.7

image

PowerShell 7.2.6 runs on top of the latest .NET 6

image

@ghost ghost added untriaged New issue has not been triaged by the area owner area-System.Console labels Sep 17, 2022
@ghost
Copy link
ghost commented Sep 17, 2022

Tagging subscribers to this area: @dotnet/area-system-console
See info in area-owners.md if you want to be subscribed.

Issue Details

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

image

PowerShell 7.3.0-preview.7 runs on top of .NET 7-preview.7

image

PowerShell 7.2.6 runs on top of the latest .NET 6

image

Author: daxian-dbw
Assignees: -
Labels:

area-System.Console, untriaged

Milestone: -

@daxian-dbw
Copy link
Contributor Author

/cc @adamsitnik for visibility.

@SteveL-MSFT
Copy link
Contributor

This issue blocks PS7.3 release with .NET7-rc1

@danmoseley danmoseley added this to the 7.0.0 milestone Sep 19, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Sep 19, 2022
@adamsitnik adamsitnik self-assigned this Sep 19, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Sep 19, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Sep 20, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
0