-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Comments
Tagging subscribers to this area: @dotnet/area-system-text-encoding |
Tagging subscribers to this area: @dotnet/area-system-io |
Related to #106237. |
@jozkee A PR will be up tomorrow 🙂 |
For reference, see #106658 |
Keeping the behavior in .NET 10 but correcting the nullability annotations seems correct. Since .NET Framework does have those Encoding inputs as null-rejecting, the documentation probably needs to call that out as a version differentiated behavior. - 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); |
There is an inconsistency between the documentation and the actual implementation of the
StreamReader
constructors. The documentation states that passingnull
to theEncoding
parameter in some constructors, except the main one, will result in an exception being thrown. However, all these constructors pass theEncoding
argument to the main constructor, which allowsnull
.StreamReader.cs
Documentation
Suggested Fix:
Encoding
parameter as nullable in these constructors.The text was updated successfully, but these errors were encountered: