-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
area-System.IOhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributorsin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Milestone
Description
There is an inconsistency between the documentation and the actual implementation of the StreamWriter 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 StreamWriter(Stream stream, Encoding encoding)
: this(stream, encoding, DefaultBufferSize, false);
public StreamWriter(Stream stream, Encoding encoding, int bufferSize)
: this(stream, encoding, bufferSize, false);public StreamWriter(Stream stream, Encoding? encoding = null, int bufferSize = -1, bool leaveOpen = false);Suggested Fix:
- Mark the
Encodingparameter as nullable in these constructors. - Update the documentation.
- public StreamWriter(Stream stream, Encoding encoding);
- public StreamWriter(Stream stream, Encoding encoding, int bufferSize);
+ public StreamWriter(Stream stream, Encoding? encoding);
+ public StreamWriter(Stream stream, Encoding? encoding, int bufferSize);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-System.IOhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributorsin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged