-
Notifications
You must be signed in to change notification settings - Fork 1.1k
SelectAsync: check equality by reference on placeholder, rather than by value on struct
#7543
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
Conversation
…n by value on `struct`
Aaronontheweb
left a comment
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.
Detailed my changes
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.
Removed a ton of TBD spam from here
| } | ||
|
|
||
| private static readonly Result<TOut> NotYetThere = Result.Failure<TOut>(new Exception()); | ||
| private static readonly Exception NotYetThereException = new Exception(); |
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.
Create the Exception itself as a static readonly
| private readonly Decider _decider; | ||
|
|
||
| private IBuffer<Holder<TOut>>? _buffer; | ||
| private IBuffer<Holder<TOut>> _buffer = null!; // gets initialized in PreStart |
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 tried but the downstream _buffer calls still complained about nullability anyway 🤷
| if (_buffer!.IsEmpty) | ||
| PullIfNeeded(); | ||
| else if (_buffer.Peek()!.Element == NotYetThere) // Shebang is fine, we checked that the buffer is not empty | ||
| else if (_buffer.Peek()!.Element.Exception == NotYetThereException) // Shebang is fine, we checked that the buffer is not empty |
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.
The fix - check the value of the Exceptions by reference. Can't get a false positive that way.
Arkatufus
left a comment
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
Changes
Supersedes #7537 using @tomachristian's research from that PR
Checklist
For significant changes, please ensure that the following have been completed (delete if not relevant):
SelectAsyncto useTry<T>#7537