dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.29k stars 4.74k forks source link

StreamReader constructor documentation mismatch with implementation #106236

Open rameel opened 3 months ago

rameel commented 3 months ago

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:

dotnet-policy-service[bot] commented 3 months ago

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

dotnet-policy-service[bot] commented 3 months ago

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

jozkee commented 3 months ago

Related to https://github.com/dotnet/runtime/issues/106237.

eriawan commented 1 month ago

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

A PR will be up tomorrow 🙂

rameel commented 1 month ago

For reference, see #106658