Skip to content

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

Closed

Description

@daxian-dbw

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

Activity

  1. ghost added
    untriaged
    on Sep 17, 2022
  2. daxian-dbw commented on Sep 17, 2022

    @daxian-dbw
    ContributorAuthor

    /cc @adamsitnik for visibility.

  3. SteveL-MSFT commented on Sep 19, 2022

    @SteveL-MSFT
    Contributor

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

  4. added this to the 7.0.0 milestone on Sep 19, 2022
  5. ghost removed
    untriaged
    on Sep 19, 2022
  6. self-assigned this
    on Sep 19, 2022
  7. ghost added
    in-pr
    on Sep 19, 2022
  8. ghost removed
    in-pr
    on Sep 20, 2022
  9. ghost locked as resolved and limited conversation to collaborators on Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions