Skip to content

Commit 2dd1d0e

Browse files
adamralphjonsequitur
authored andcommitted
ignore non-positive max width in HelpBuilder.ctor
1 parent a0a2bf5 commit 2dd1d0e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/System.CommandLine.Tests/Help/HelpBuilderTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,10 +1638,10 @@ public void Help_describes_default_values_for_subcommand_with_multiple_defaultab
16381638
[InlineData(0)]
16391639
[InlineData(-1)]
16401640
[InlineData(int.MinValue)]
1641-
public void Constructor_max_width_must_be_positive(int maxWidth)
1641+
public void Constructor_ignores_non_positive_max_width(int maxWidth)
16421642
{
1643-
var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new HelpBuilder(_console, maxWidth));
1644-
Assert.Equal("maxWidth", ex.ParamName);
1643+
var helpBuilder = new HelpBuilder(_console, maxWidth);
1644+
Assert.Equal(int.MaxValue, helpBuilder.MaxWidth);
16451645
}
16461646

16471647
private class CustomHelpBuilderThatAddsTextAfterDefaultText : HelpBuilder

src/System.CommandLine/Help/HelpBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class HelpBuilder : IHelpBuilder
2222
public HelpBuilder(IConsole console, int maxWidth = int.MaxValue)
2323
{
2424
Console = console ?? throw new ArgumentNullException(nameof(console));
25-
if (maxWidth <= 0) throw new ArgumentOutOfRangeException(nameof(maxWidth), "Max width must be positive");
25+
if (maxWidth <= 0) maxWidth = int.MaxValue;
2626
MaxWidth = maxWidth;
2727
}
2828

0 commit comments

Comments
 (0)