Skip to content
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

Console.Unix: fix OpenStandardInput Stream sometimes throwing for Reads. #62153

Merged
merged 3 commits into from
Dec 1, 2021

Conversation

tmds
Copy link
Member

@tmds tmds commented Nov 29, 2021

When connected to a terminal reads happen line-by-line.
This was added in .NET 5 by #39192.

StdInReader caches the line in a StringBuilder.

Instead of returning when the destination buffer is full, an attempt
was made to decode the next chunk from the StringBuilder (if there is
one). This causes the encoder to throw for encoding into an empty buffer.

Fixes #61865.

@dotnet/area-system-console ptal.

cc @dmbarbour

When connected to a terminal reads happen line-by-line.

StdInReader caches the line in a StringBuilder.

Instead of returning when the destination buffer is full, an attempt
was made to decode the next chunk from the StringBuilder (if there is
one). This causes the encoder to throw for encoding into an empty buffer.
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Nov 29, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Console and removed community-contribution Indicates that the PR has been added by a community member labels Nov 29, 2021
@ghost
Copy link

ghost commented Nov 29, 2021

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

Issue Details

When connected to a terminal reads happen line-by-line.
This was added in .NET 5 by #39192.

StdInReader caches the line in a StringBuilder.

Instead of returning when the destination buffer is full, an attempt
was made to decode the next chunk from the StringBuilder (if there is
one). This causes the encoder to throw for encoding into an empty buffer.

Fixes #61865.

@dotnet/area-system-console ptal.

cc @dmbarbour

Author: tmds
Assignees: -
Labels:

area-System.Console

Milestone: -

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmds thank you for your contribution! I've left some comments, PTAL

@tmds
Copy link
Member Author

tmds commented Nov 30, 2021

Adam, thank you for reviewing! I've addressed your feedback.

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmds thank you for addressing the feedback, LGTM. :shipit:

@adamsitnik adamsitnik added this to the 7.0.0 milestone Nov 30, 2021
@adamsitnik
Copy link
Member

System.IO.FileSystem.Tests.DriveInfoWindowsTests.TestGetDrives test failure is a known issue (#62119) that I've just fixed (#62134). Other failures are #61643

@adamsitnik adamsitnik merged commit e51c22a into dotnet:main Dec 1, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Dec 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System.Console.OpenStandardInput() doesn't return a sane Stream.
2 participants