This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Revert making Nullable<T> readonly#15198
Merged
stephentoub merged 2 commits intodotnet:masterfrom Nov 23, 2017
Merged
Conversation
23cddbc to
5547606
Compare
jkotas
reviewed
Nov 23, 2017
| { | ||
| private readonly bool hasValue; // Do not rename (binary serialization) | ||
| internal readonly T value; // Do not rename (binary serialization) | ||
| internal T value; // Do not rename (binary serialization) |
Member
There was a problem hiding this comment.
Add a comment why this cannot be readonly?
Member
Author
There was a problem hiding this comment.
Will add. The test I've added in corefx will also fail if this is made readonly.
dotnet-bot
pushed a commit
to dotnet/corert
that referenced
this pull request
Nov 23, 2017
* Revert making Nullable<T> readonly * Address PR feedback Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
stephentoub
added a commit
to dotnet/corert
that referenced
this pull request
Nov 23, 2017
* Revert making Nullable<T> readonly * Address PR feedback Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Member
|
After thinking a bit about this, it looks like a bug/oversight in Nullable. Mutable Nullable is less convenient and is unlikely intentional. Methods like ToString can change the state. Even T being readonly or a primitive would not help much. ToString could still do anything - as gross as ‘this = null’. I guess we are keeping it as is anyways... |
dotnet-bot
pushed a commit
to dotnet/corefx
that referenced
this pull request
Jan 13, 2018
* Revert making Nullable<T> readonly * Address PR feedback Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
dotnet-bot
pushed a commit
to dotnet/corefx
that referenced
this pull request
Jan 13, 2018
* Revert making Nullable<T> readonly * Address PR feedback Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
safern
pushed a commit
to dotnet/corefx
that referenced
this pull request
Jan 16, 2018
* Revert making Nullable<T> readonly * Address PR feedback Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
safern
pushed a commit
to dotnet/corefx
that referenced
this pull request
Jan 16, 2018
* Revert making Nullable<T> readonly * Address PR feedback Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cc: @jkotas, @VSadov, @jaredpar