diff --git a/src/System.CommandLine.DragonFruit.Tests/CommandLineTests.cs b/src/System.CommandLine.DragonFruit.Tests/CommandLineTests.cs index 7bc9dac397..eba1f8a52f 100644 --- a/src/System.CommandLine.DragonFruit.Tests/CommandLineTests.cs +++ b/src/System.CommandLine.DragonFruit.Tests/CommandLineTests.cs @@ -93,6 +93,30 @@ public async Task When_XML_documentation_comment_contains_a_para_tag_then_help_i .Contain($"Description:{Environment.NewLine} Help for the test program{Environment.NewLine} More help for the test program{Environment.NewLine}"); } + [Fact] + public async Task When_XML_documentation_comment_contains_a_para_tag_and_some_text_then_help_skips_text_outside_para_tag() + { + int exitCode = await CommandLine.InvokeMethodAsync( + new[] { "--help" }, + TestProgram.TestMainMethodInfoWithTextAndPara, + null, + _testProgram, + _terminal); + + exitCode.Should().Be(0); + + var stdOut = _terminal.Out.ToString(); + + stdOut.Should() + .Contain(" These are arguments") + .And.Contain("Arguments:"); + stdOut.Should() + .ContainAll("--name ", "Specifies the name option") + .And.Contain("Options:"); + stdOut.Should() + .Contain($"Description:{Environment.NewLine} Help for the test program{Environment.NewLine} More help for the test program{Environment.NewLine}"); + } + [Fact] public void It_synchronously_shows_help_text_based_on_XML_documentation_comments() { diff --git a/src/System.CommandLine.DragonFruit.Tests/TestProgram.cs b/src/System.CommandLine.DragonFruit.Tests/TestProgram.cs index f6c75729c6..0b4916d056 100644 --- a/src/System.CommandLine.DragonFruit.Tests/TestProgram.cs +++ b/src/System.CommandLine.DragonFruit.Tests/TestProgram.cs @@ -11,6 +11,8 @@ public class TestProgram public static readonly MethodInfo TestMainMethodInfoWithPara = typeof(TestProgram).GetMethod(nameof(TestMainWithPara)); + public static readonly MethodInfo TestMainMethodInfoWithTextAndPara = typeof(TestProgram).GetMethod(nameof(TestMainWithTextAndPara)); + public static readonly MethodInfo TestMainMethodInfoWithDefault = typeof(TestProgram).GetMethod(nameof(TestMainWithDefault)); /// @@ -29,6 +31,25 @@ public void TestMainWithPara(string name, IConsole console, string[] args = null } } + /// + /// Skipped help for the test program + /// More skipped help for the test programHelp for the test programMore skipped help for the test program + /// More skipped help for the test programMore help for the test programMore skipped help for the test program + /// + /// More skipped help for the test program + /// + /// Specifies the name option + /// + /// These are arguments + public void TestMainWithTextAndPara(string name, IConsole console, string[] args = null) + { + console.Out.Write(name); + if (args != null && args.Length > 0) + { + console.Out.Write($"args: { string.Join(",", args) }"); + } + } + /// /// Normal summary ///