| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Could this, instead, throw early for invalid values of count resp. just return the identity enumerable for count == 0 ? |
Sorry, something went wrong.
If I am not mistaken this is already handled in the SkipLast method itself, Core only being called if the value of count is valid, or if there is a need to really return a new enumerable as stated in the comment also enforces. |
Sorry, something went wrong.
|
I see...so there is a case in which we have to return source unchanged but have to 'hide' the object identity. I wasn't aware of that. I am thinking about not touching the implementation of SkipLast, but instead having a generic way to wrap source but keep its behaviour. AsAsyncEnumerable comes to mind, but that'll only return the object itself. Is there more cases like this one, where Core is called only to hide source? If so, could you provide a more generic solution, like e.g. a Wrap method? I think that would be the cleanest solution because we wouldn't touch any implementations and correctness of the changes would be immediately obvious. In any case, good find! |
Sorry, something went wrong.
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 IAsyncEnumerable. Also, I noticed that there is an extensive use of GetAsyncEnumerator() + MoveNextAsync() instead of await foreach in this library, most likely due to the fact it predates the introduction of IAsyncEnumerable and C# 8 await foreach. Do you think such rework would be worth it to spot places where some simplfying logic such as the Wrap you suggest are relevant ? |
Sorry, something went wrong.
…tually hides an async sequence identity
|
@danielcweber Requested changes were done in e818952 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Bugfix
Fixes bug where calling SkipLast(0) over a custom sequence (not being a AsyncIteratorBase :
reactive/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SkipLast.cs
Line 36 in 85f1eb7
would result in Corecalling Dequeue over an empty queue, as queue.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 using await foreach and matching its synchronous implementation for IEnumerable 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.