Skip to content

Commit b751c2e

Browse files
jonsequiturKeboo
andauthored
XML docs, refactoring, a couple of renames (#1339)
* R: GetValueOrDefault from extension methods to members * R: use some C# 9, clean up * rename ValidateSymbol to ValidateSymbolResult * rename Option.HasAliasIgnorePrefix to HasAliasIgnoringPrefix * add XML comments * R: cleanup * disable documentation warnings * langword instead of c * R: or instead of || * more XML docs, remove dotnet-suggest error loc strings * Update src/System.CommandLine/ArgumentExtensions.cs Co-authored-by: Kevin B <[email protected]> * Update src/System.CommandLine/Collections/ISymbolSet.cs Co-authored-by: Kevin B <[email protected]> * Update src/System.CommandLine/Option.cs Co-authored-by: Kevin B <[email protected]> * Update src/System.CommandLine/Resources.cs Co-authored-by: Kevin B <[email protected]> * Update src/System.CommandLine/Resources.cs Co-authored-by: Kevin B <[email protected]> * Update src/System.CommandLine/Parsing/OptionResult.cs Co-authored-by: Kevin B <[email protected]> * Update src/System.CommandLine/Resources.cs Co-authored-by: Kevin B <[email protected]> * Update src/System.CommandLine/Option.cs Co-authored-by: Kevin B <[email protected]> * Update src/System.CommandLine/CommandExtensions.cs Co-authored-by: Kevin B <[email protected]> * Update src/System.CommandLine/OptionExtensions.cs Co-authored-by: Kevin B <[email protected]> * Update src/System.CommandLine/OptionExtensions.cs Co-authored-by: Kevin B <[email protected]> * Update src/System.CommandLine/OptionExtensions.cs Co-authored-by: Kevin B <[email protected]> * Update src/System.CommandLine/Parsing/CommandResult.cs Co-authored-by: Kevin B <[email protected]> * PR comments Co-authored-by: Kevin B <[email protected]>
1 parent e99b4ee commit b751c2e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+475
-471
lines changed

src/System.CommandLine.DragonFruit/CommandLine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public static CommandLineBuilder ConfigureHelpFromXmlComments(
215215
{
216216
var kebabCasedParameterName = parameterDescription.Key.ToKebabCase();
217217

218-
var option = options.FirstOrDefault(o => o.HasAliasIgnorePrefix(kebabCasedParameterName));
218+
var option = options.FirstOrDefault(o => o.HasAliasIgnoringPrefix(kebabCasedParameterName));
219219

220220
if (option != null)
221221
{

src/System.CommandLine.Tests/ArgumentTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System.Linq;
1010
using System.Threading.Tasks;
1111
using Xunit;
12-
using Xunit.Abstractions;
1312

1413
namespace System.CommandLine.Tests
1514
{

src/System.CommandLine.Tests/Binding/ModelBindingCommandHandlerTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ public async Task Handler_method_receives_command_arguments_explicitly_bound_to_
418418
{
419419
argument
420420
};
421-
if (!(handler is ModelBindingCommandHandler bindingHandler))
421+
if (handler is not ModelBindingCommandHandler bindingHandler)
422422
{
423423
throw new InvalidOperationException("Cannot bind to this type of handler");
424424
}
@@ -470,7 +470,7 @@ public async Task Handler_method_receive_option_arguments_explicitly_bound_to_th
470470
{
471471
option
472472
};
473-
if (!(handler is ModelBindingCommandHandler bindingHandler))
473+
if (handler is not ModelBindingCommandHandler bindingHandler)
474474
{
475475
throw new InvalidOperationException("Cannot bind to this type of handler");
476476
}
@@ -515,7 +515,7 @@ public void Apply(InvocationContext context)
515515
}
516516
}
517517

518-
internal static readonly BindingTestSet BindingCases = new BindingTestSet
518+
internal static readonly BindingTestSet BindingCases = new()
519519
{
520520
BindingTestCase.Create<int>(
521521
"123",

src/System.CommandLine.Tests/Binding/TypeConversionTests.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
using System.Collections.Generic;
5-
using System.CommandLine.Invocation;
65
using System.CommandLine.Parsing;
76
using System.IO;
87
using FluentAssertions;
@@ -644,14 +643,5 @@ public void When_getting_an_array_of_values_and_specifying_a_conversion_type_tha
644643
.Should()
645644
.Be("Option '-x' expects a single argument but 2 were provided.");
646645
}
647-
648-
public class MyCustomType
649-
{
650-
private readonly List<string> values = new List<string>();
651-
652-
public void Add(string value) => values.Add(value);
653-
654-
public string[] Values => values.ToArray();
655-
}
656646
}
657647
}

src/System.CommandLine.Tests/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<UseBetaVersion>true</UseBetaVersion>
5+
<NoWarn>IDE1006</NoWarn>
56
</PropertyGroup>
67

78
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
using System.CommandLine.Parsing;
1010
using System.IO;
1111
using System.Linq;
12-
using System.Security;
13-
using System.Text;
1412
using Xunit;
15-
using Xunit.Abstractions;
1613
using static System.Environment;
1714

1815
namespace System.CommandLine.Tests.Help

src/System.CommandLine.Tests/Invocation/CommandHandlerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace System.CommandLine.Tests.Invocation
1414
{
1515
public class CommandHandlerTests
1616
{
17-
private readonly TestConsole _console = new TestConsole();
17+
private readonly TestConsole _console = new();
1818

1919
[Fact]
2020
public async Task Specific_invocation_behavior_can_be_specified_in_the_command()

src/System.CommandLine.Tests/OptionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void A_prefixed_alias_can_be_added_to_an_option()
6464

6565
option.AddAlias("-a");
6666

67-
option.HasAliasIgnorePrefix("a").Should().BeTrue();
67+
option.HasAliasIgnoringPrefix("a").Should().BeTrue();
6868
option.HasAlias("-a").Should().BeTrue();
6969
}
7070

@@ -89,7 +89,7 @@ public void HasAliasIgnorePrefix_accepts_unprefixed_short_value()
8989
{
9090
var option = new Option(new[] { "-o", "--option" });
9191

92-
option.HasAliasIgnorePrefix("o").Should().BeTrue();
92+
option.HasAliasIgnoringPrefix("o").Should().BeTrue();
9393
}
9494

9595
[Fact]
@@ -105,7 +105,7 @@ public void HasAliasIgnorePrefix_accepts_unprefixed_long_value()
105105
{
106106
var option = new Option(new[] { "-o", "--option" });
107107

108-
option.HasAliasIgnorePrefix("option").Should().BeTrue();
108+
option.HasAliasIgnoringPrefix("option").Should().BeTrue();
109109
}
110110

111111
[Fact]

src/System.CommandLine.Tests/ParserTests.MultipleArguments.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
using System.Collections.Generic;
5-
using System.CommandLine.Parsing;
65
using System.CommandLine.Tests.Utility;
76
using FluentAssertions;
87
using FluentAssertions.Execution;

src/System.CommandLine.Tests/Utility/AssertionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static AndConstraint<StringCollectionAssertions> BeEquivalentSequenceTo(
4444
return assertions.BeEquivalentTo(expectedValues, c => c.WithStrictOrderingFor(s => s));
4545
}
4646

47-
public static ConsoleAssertions Should(this IConsole console) => new ConsoleAssertions(console);
47+
public static ConsoleAssertions Should(this IConsole console) => new(console);
4848

4949
public static AndConstraint<ConsoleAssertions> ShowHelp(this ConsoleAssertions assertions)
5050
{

0 commit comments

Comments
 (0)