-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
Fix unknown command throws System.InvalidOperationException: Enumeration already finished #542
Conversation
…lse in CommandArgumentEnumerator.
@@ -533,9 +535,10 @@ public CommandArgumentEnumerator(IEnumerator<CommandArgument> enumerator) | |||
|
|||
public bool MoveNext() | |||
{ | |||
if (Current == null || !Current.MultipleValues) | |||
if (!_currentValid || !Current.MultipleValues) |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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. Better than my own attempt, actually, so I'll close my PR.
@@ -533,9 +535,10 @@ public CommandArgumentEnumerator(IEnumerator<CommandArgument> enumerator) | |||
|
|||
public bool MoveNext() | |||
{ | |||
if (Current == null || !Current.MultipleValues) | |||
if (!_currentValid || !Current.MultipleValues) |
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.
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.