-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Nullability annotations for System.Console #41161
Conversation
Contributes to: #40623
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except for the params comment I made which I'm pretty sure I'm remembering correctly but others might remember something else.
@@ -81,12 +82,12 @@ public static Encoding OutputEncoding | |||
// s_out reinitialize the console code page. | |||
if (Volatile.Read(ref s_out) != null && !s_isOutTextWriterRedirected) | |||
{ | |||
s_out.Flush(); | |||
s_out!.Flush(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This !
is correct, but a little unfortunate. @jcouv, our use of [NotNullIfNotNull] on Volatile.Read was intended to cover cases like this, but it falls short because it's only one directional: the compiler can know that the return value is not null if s_out is not null, but it can't then also infer that s_out is not null if the return value is not null.
6bb636e
to
60d9a30
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM.
This reverts commit fb4cd4b.
Contributes to: dotnet/corefx#40623 Commit migrated from dotnet/corefx@19b304f
Contributes to: #40623
cc: @safern @buyaa-n