Skip to content
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 CommandArgumentEnumerator behavior for .NET 8 #544

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/CommandLineUtils/Internal/CommandLineProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ public CommandArgumentEnumerator(IEnumerator<CommandArgument> enumerator)
_enumerator = enumerator;
}

public CommandArgument Current => _enumerator.Current;
public CommandArgument Current { get; private set; } = null!;

object IEnumerator.Current => Current;

Expand All @@ -535,7 +535,10 @@ public bool MoveNext()
{
if (Current == null || !Current.MultipleValues)
{
return _enumerator.MoveNext();
var result = _enumerator.MoveNext();
if (result)
Current = _enumerator.Current!;
return result;
}

// If current argument allows multiple values, we don't move forward and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<TargetFrameworks Condition="'$(TestFullFramework)' != 'false'">$(TargetFrameworks);net472</TargetFrameworks>
<!-- Once xunit supports nullable reference types, I might reconsider -->
<Nullable>annotations</Nullable>
Expand Down
Loading