-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement nullability in streams Buffer #7496
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
Implement nullability in streams Buffer #7496
Conversation
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.
Self-review
| } | ||
| } | ||
|
|
||
| if (_terminating && _buffer.IsEmpty) |
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 an actual bug, _buffer can be null if _stage._maxBuffer is less than 1. Moved the code to inside the previous if block
| /// </summary> | ||
| /// <returns>TBD</returns> | ||
| T Peek(); | ||
| T? Peek(); |
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.
Original behavior is that Peek() can return null
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.
Not done reviewing yet but left a comment
| else if (message is Status.Success) | ||
| { | ||
| if (BufferSize == 0 || Buffer.IsEmpty) | ||
| if (Buffer is null || Buffer.IsEmpty) |
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
| BufferSize = bufferSize; | ||
| OverflowStrategy = overflowStrategy; | ||
| Buffer = bufferSize != 0 ? Implementation.Buffer.Create<T>(bufferSize, maxFixedBufferSize) : null; | ||
| Buffer = bufferSize > 0 ? Implementation.Buffer.Create<T>(bufferSize, maxFixedBufferSize) : null; |
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
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.
Although, should we throw an exception here if the bufferSize is less than 0 ?
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.
I think we should, I just tried to preserve the old behavior
|
Another thing I'm wondering - is there a compelling reason to have a |
|
In |
|
Though for |
|
After thinking on this, yep, there are definitely scenarios where a user might want a |
Changes
Checklist
For significant changes, please ensure that the following have been completed (delete if not relevant):