Fix unknown command throws System.InvalidOperationException: Enumeration already finished#542
Conversation
…lse in CommandArgumentEnumerator.
| public bool MoveNext() | ||
| { | ||
| if (Current == null || !Current.MultipleValues) | ||
| if (!_currentValid || !Current.MultipleValues) |
There was a problem hiding this comment.
Current is not nullable so I removed the null check. I think it was only used to check if MoveNext had been called. Not to allow Current to be null while iterating. Please let me know if I should add it again.
There was a problem hiding this comment.
It's also better because it not only checks that MoveNext has been called, but also that it returned true. The error was caused by calling Current after MoveNext has returned false.
thomaslevesque
left a comment
There was a problem hiding this comment.
LGTM. Better than my own attempt, actually, so I'll close my PR.
| public bool MoveNext() | ||
| { | ||
| if (Current == null || !Current.MultipleValues) | ||
| if (!_currentValid || !Current.MultipleValues) |
There was a problem hiding this comment.
It's also better because it not only checks that MoveNext has been called, but also that it returned true. The error was caused by calling Current after MoveNext has returned false.
|
Just to say thanks. Looking forward to this fix. |
|
Thank you for already fixing this, I'd have submitted a PR now otherwise. 🙏 |
|
FYI: I've got a work-around that's working for my scenario. |
|
I really need this fix :( . Can i do something to help? |
Just fork the repo, fix it there, and include the source in your solution. And try this workaround: |
#541
Do not call enumerator.Current if enumerator.MoveNext has not been called or returns false.