Skip to content

Commit

Permalink
Fix CommandArgumentEnumerator behavior for .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaslevesque committed Dec 31, 2023
1 parent 14f9a49 commit e44d5fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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; }

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

0 comments on commit e44d5fc

Please sign in to comment.