-
-
Notifications
You must be signed in to change notification settings - Fork 254
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
.NET 8: CommandLineApplication.Execute with unknown command throws System.InvalidOperationException: Enumeration already finished
#541
Comments
There has been a change in the undefined behaviour for calling enumerator.Current before MoveNext has been called in net8: dotnet/runtime#94256 |
Is there a workaround for this? It basically makes the library unusable on .NET 8... |
The problem is here: CommandLineUtils/src/CommandLineUtils/Internal/CommandLineProcessor.cs Lines 534 to 539 in e0b6a2c
|
@thomaslevesque Correct. It's not usable on .NET 8. There is no workaround. I just spent a few days porting an app to System.CommandLine. If you take a look above, there was also a fix submitted by @sallerga (#542). |
We also just ran into this issue with pipelines failing after upgrading to .NET 8. Googling the error led me here. Just for my information. Do you by chance have a rough estimate when this will be available as nuget? 😊 Thank you for your great work! |
Given that @natemcmaster has never replied to this issue, he's probably unavailable for a prolonged period of time. I wouldn't expect a new release soon. I tried to switch to System.CommandLine, but it was hell. Since my use case was pretty simple, I eventually just wrote a bespoke parser. |
I've got a simple workaround that's working for my case and I'm able to replicate issue consistently with existing commands. Executing a command with a following empty argument would consistently throw the
args.Where(a => !string.IsNullOrEmpty(a)).ToArray() |
Describe the bug
Using McMaster.Extensions.CommandLineUtils 4.1.0.
Upgrading my application from .NET 7 to .NET 8 and my tests and application started failing with an unexpected error when parsing unexpected commands.
To Reproduce
Create a simple sample app with the following:
MyApp.csproj
Program.cs
Now run the app with an invalid command for each of the target frameworks:
Expected behavior
The result from the
net7.0
invocation is what I would expect. It correctly indicates that the parameter wasn't recognized.Additional context
I'm also seeing the issue with valid commands, but I haven't nailed down a minimal repro for that. I have a feeling the fix for the unexpected commands will either fix the same issue or shine light on a deeper issue.
Runtime information:
The text was updated successfully, but these errors were encountered: