CliCommandLineParser icon indicating copy to clipboard operation
CliCommandLineParser copied to clipboard

System.IndexOutOfRangeException from Microsoft.DotNet.Cli.CommandLine.StringExtensions.HasPrefix

Open tmat opened this issue 6 years ago • 1 comments

>dotnet.exe msbuild ""
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.String.get_Chars(Int32 index)
   at Microsoft.DotNet.Cli.CommandLine.StringExtensions.HasPrefix(String arg)
   at Microsoft.DotNet.Cli.CommandLine.StringExtensions.<Lex>d__7.MoveNext()
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source, Int32& length)
   at System.Collections.Generic.Queue`1..ctor(IEnumerable`1 collection)
   at Microsoft.DotNet.Cli.CommandLine.Parser.Parse(IReadOnlyCollection`1 rawArgs, Boolean isProgressive)
   at Microsoft.DotNet.Cli.CommandLine.Parser.Parse(String[] args)
   at Microsoft.DotNet.Cli.ParserExtensions.ParseFrom(Parser parser, String context, String[] args)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

tmat avatar May 03 '18 01:05 tmat

The check on https://github.com/dotnet/CliCommandLineParser/blob/ed4799b3d86e4eb3bef7c33956a4ef65c91fecbc/src/source/CommandLine/OptionError.cs#L19 should simply be for null, not for null or whitespace.

peterhuene avatar May 09 '18 20:05 peterhuene