-
Notifications
You must be signed in to change notification settings - Fork 772
Fix IAsyncEnumerable SkipLast for count = 0 #1782
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
base: main
Are you sure you want to change the base?
Fix IAsyncEnumerable SkipLast for count = 0 #1782
Conversation
Could this, instead, throw early for invalid values of |
If I am not mistaken this is already handled in the reactive/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs Lines 34 to 35 in ff6e92a
also enforces. |
I see...so there is a case in which we have to return I am thinking about not touching the implementation of SkipLast, but instead having a generic way to wrap Is there more cases like this one, where In any case, good find! |
This seems to be a bit out of scope of this PR and quite some work, as it requires to search for such pattern in all extensions methods of Also, I noticed that there is an extensive use of Do you think such rework would be worth it to spot places where some simplfying logic such as the |
…tually hides an async sequence identity
@danielcweber Requested changes were done in e818952 |
Bugfix
Fixes bug where calling
SkipLast(0)
over a custom sequence (not being aAsyncIteratorBase
:reactive/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs
Line 36 in 85f1eb7
would result in
Core
callingDequeue
over an empty queue, asqueue.Count == count
(both value being equal to 0)reactive/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs
Line 58 in 85f1eb7
As a fix, I rewrote the
Core
method usingawait foreach
and matching its synchronous implementation forIEnumerable
as this version, aside being easier to read, also handles this particular case.reactive/Ix.NET/Source/System.Interactive/System/Linq/Operators/SkipLast.cs
Line 33 in 93386a9
I have also edited the unit test
SkipLast_Zero_NoAlias
so this one fails with current version of the code.