commandline icon indicating copy to clipboard operation
commandline copied to clipboard

AutoHelp crash if HelpTexts in attributes are too long

Open red-rj opened this issue 8 years ago • 0 comments

I started using command line parser in one of my projects, all was fine until, out of nowhere this error starts happening if I request HelpText:

System.ArgumentOutOfRangeException occurred
  HResult=0x80131502
  Message=Comprimento não pode ser menor que zero.
  Source=mscorlib
  StackTrace:
   at System.String.Substring(Int32 startIndex, Int32 length)
   at CommandLine.Text.HelpText.AddOption(String requiredWord, Int32 maxLength, Specification specification, Int32 widthOfHelpText)
   at CommandLine.Text.HelpText.<>c__DisplayClass62_0.<AddOptionsImpl>b__0(Specification option)
   at CSharpx.EnumerableExtensions.ForEach[T](IEnumerable`1 source, Action`1 action)
   at CommandLine.Text.HelpText.AddOptionsImpl(IEnumerable`1 specifications, String requiredWord, Int32 maximumLength)
   at CommandLine.Text.HelpText.AddOptions[T](ParserResult`1 result)
   at CommandLine.Text.HelpText.AutoBuild[T](ParserResult`1 parserResult, Func`2 onError, Func`2 onExample, Boolean verbsIndex, Int32 maxDisplayWidth)
   at CommandLine.Text.HelpText.AutoBuild[T](ParserResult`1 parserResult, Int32 maxDisplayWidth)
   at CommandLine.Parser.<>c__DisplayClass17_0`1.<DisplayHelp>b__1(IEnumerable`1 _, TextWriter writer)
   at CSharpx.MaybeExtensions.Do[T1,T2](Maybe`1 maybe, Action`2 action)
   at CommandLine.Parser.<>c__DisplayClass17_0`1.<DisplayHelp>b__0(IEnumerable`1 errors)
   at CommandLine.ParserResultExtensions.WithNotParsed[T](ParserResult`1 result, Action`1 action)
   at CommandLine.Parser.DisplayHelp[T](ParserResult`1 parserResult, TextWriter helpWriter, Int32 maxDisplayWidth)
   at CommandLine.Parser.MakeParserResult[T](ParserResult`1 parserResult, ParserSettings settings)
   at CommandLine.Parser.ParseArguments[T](IEnumerable`1 args)
   at FetcherTerminal.Program.Main(String[] args) in F:\DEV\poolFetcher\FetcherTerminal\Program.cs:line 49

I did some tests and it has something to do with the TOTAL LENGTH of ALL HelpTexts in the Options attributes.

I tested. 3 DummyClasses, one exactly like the problem class (Same properties and HelpTexts), one with the same proprieties but shorter HelpTexts and onother w/o HelpTextes. Only the first crashed

A similar issue is discussed here: #445

red-rj avatar Aug 03 '17 01:08 red-rj