Document trailing newline behavior for ReadLine and ReadAllLines/ReadLines APIs#12493
Draft
Document trailing newline behavior for ReadLine and ReadAllLines/ReadLines APIs#12493
Conversation
… TextReader.ReadLine, StringReader.ReadLine, File.ReadAllLines, and File.ReadLines Agent-Logs-Url: https://github.com/dotnet/dotnet-api-docs/sessions/26046a78-c7a0-46a9-bccb-394eb343d453 Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
…eadLine docs Agent-Logs-Url: https://github.com/dotnet/dotnet-api-docs/sessions/26046a78-c7a0-46a9-bccb-394eb343d453 Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Document newline treatment in StreamReader.ReadLine
Document trailing newline behavior for ReadLine and ReadAllLines/ReadLines APIs
Apr 7, 2026
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-io |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A trailing newline at the end of a stream or file does not produce a final empty string —
"foo\nbar\n"and"foo\nbar"both yield the same two lines. This behavior is common but undocumented, making it a source of confusion.Affected APIs
Added a note to the
## Remarkssection of each:StreamReader.ReadLineTextReader.ReadLineStringReader.ReadLineFile.ReadAllLines(string)/File.ReadAllLines(string, Encoding)File.ReadLines(string)/File.ReadLines(string, Encoding)Example note added (StreamReader.ReadLine)