-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Nullability of StreamReader and StreamWriter encoding parameter is not consistent #2376
Comments
The overloads where you have an X next to them historically have thrown when Encoding is null, and still do on .NET Framework. It was only recently changed for .NET Core, in dotnet/coreclr#24056, specifically because of a desire to have optional arguments. We should probably change the other Encoding arguments to be nullable as well. |
That said, it's strange that we allow null for Encoding with the Stream-based constructors but not with the string-based constructors. @JeremyKuhne, what's the rhyme/reason for that? |
The overload without an X throws on .NET Framework also. |
I understand that; I was commenting on the ones that are currently specified to take |
Oversight, really. The original issue was targeting |
❌
StreamReader(Stream, Encoding)
does not throw whennull
is passed❌
StreamReader(Stream, Encoding, bool)
does not throw whennull
is passed❌
StreamReader(Stream, Encoding, bool, int)
does not throw whennull
is passed✔
StreamReader(Stream, Encoding?, bool, int, bool)
does not throw whennull
is passed❌
StreamWriter(Stream, Encoding)
does not throw whennull
is passed❌
StreamWriter(Stream, Encoding, int)
does not throw whennull
is passed✔
StreamWriter(Stream, Encoding?, int, bool)
does not throw whennull
is passedThe text was updated successfully, but these errors were encountered: