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

StreamReader constructor documentation mismatch with implementation #106236

Open
rameel opened this issue Aug 11, 2024 · 5 comments · May be fixed by #108542
Open

StreamReader constructor documentation mismatch with implementation #106236

rameel opened this issue Aug 11, 2024 · 5 comments · May be fixed by #108542
Labels
area-System.IO help wanted [up-for-grabs] Good issue for external contributors in-pr There is an active PR which will close this issue when it is merged
Milestone

Comments

@rameel
Copy link

rameel commented Aug 11, 2024

There is an inconsistency between the documentation and the actual implementation of the StreamReader constructors. The documentation states that passing null to the Encoding parameter in some constructors, except the main one, will result in an exception being thrown. However, all these constructors pass the Encoding argument to the main constructor, which allows null.

public StreamReader(Stream stream, Encoding encoding);
public StreamReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks);
public StreamReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize);
public StreamReader(Stream stream, Encoding? encoding = null, bool detectEncodingFromByteOrderMarks = true, int bufferSize = -1, bool leaveOpen = false)

StreamReader.cs
Documentation

Suggested Fix:

  • Mark the Encoding parameter as nullable in these constructors.
  • Update the documentation.
- public StreamReader(Stream stream, Encoding encoding);
- public StreamReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks);
- public StreamReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize);
+ public StreamReader(Stream stream, Encoding? encoding);
+ public StreamReader(Stream stream, Encoding? encoding, bool detectEncodingFromByteOrderMarks);
+ public StreamReader(Stream stream, Encoding? encoding, bool detectEncodingFromByteOrderMarks, int bufferSize);
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Aug 11, 2024
Copy link
Contributor

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

@rameel rameel changed the title Inconsistency between documentation and implementation in StreamReader constructors StreamReader constructor documentation mismatch with implementation Aug 11, 2024
Copy link
Contributor

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

@jozkee jozkee added this to the Future milestone Aug 12, 2024
@jozkee jozkee added help wanted [up-for-grabs] Good issue for external contributors and removed untriaged New issue has not been triaged by the area owner labels Aug 12, 2024
@jozkee
Copy link
Member

jozkee commented Aug 12, 2024

Related to #106237.

@eriawan
Copy link
Member

eriawan commented Oct 2, 2024

@jozkee
Could I take this issue to fix and assign this to me? This seems quite straightforward.

A PR will be up tomorrow 🙂

@rameel
Copy link
Author

rameel commented Oct 2, 2024

For reference, see #106658

@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.IO help wanted [up-for-grabs] Good issue for external contributors in-pr There is an active PR which will close this issue when it is merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants