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

Mark or set encoding param in StreamReader ctor to be nullable #108542

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

eriawan
Copy link
Member

@eriawan eriawan commented Oct 4, 2024

Fixes #106236

Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

1 similar comment
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Oct 4, 2024
@eriawan
Copy link
Member Author

eriawan commented Oct 4, 2024

@jozkee please review

cc @rameel

@lilinus
Copy link
Contributor

lilinus commented Oct 4, 2024

Should the string path constructors also be modified to allow null (similar to #106658, as discussed in #2376 (comment))? I.e. the ctors below:

public StreamReader(string path, System.Text.Encoding encoding)
public StreamReader(string path, System.Text.Encoding encoding, bool detectEncodingFromByteOrderMarks)
public StreamReader(string path, System.Text.Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize)
public StreamReader(string path, System.Text.Encoding encoding, bool detectEncodingFromByteOrderMarks, System.IO.FileStreamOptions options)

Also; are there any tests that could be modified to verify null encoding works (and acts as UTF8)?

@rameel
Copy link

rameel commented Oct 4, 2024

Yes, as @lilinus mentioned, the constructors that accept path and encoding parameters also need to be aligned with the Stream-based constructors, similar to how it was done for StreamWriter.

@eriawan
Copy link
Member Author

eriawan commented Oct 5, 2024

Yes, as @lilinus mentioned, the constructors that accept path and encoding parameters also need to be aligned with the Stream-based constructors, similar to how it was done for StreamWriter.

thanks for the feedback! sure, I'm gong to update now.

…sAndOpenPath to not require Encoding param anymore like StreamWriter
…sAndOpenPath to not require Encoding param anymore like StreamWriter
@eriawan
Copy link
Member Author

eriawan commented Oct 5, 2024

@lilinus @rameel

Done updating the ccror with the string path as well.

@jozkee
Could you please review?

@eriawan
Copy link
Member Author

eriawan commented Oct 5, 2024

Ok, I also have done refactoring the test of StreamReader's constructor as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.IO community-contribution Indicates that the PR has been added by a community member new-api-needs-documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StreamReader constructor documentation mismatch with implementation
3 participants