From 263690eff6086f39f6747e6eecaa72c66475db8f Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Thu, 30 Jun 2022 23:36:13 -0700 Subject: [PATCH 1/6] Move System.CommandLine.Builder to System.CommandLine --- samples/HostingPlayground/Program.cs | 1 - ...ne_Hosting_api_is_not_changed.approved.txt | 6 +- ...ommandLine_api_is_not_changed.approved.txt | 57 +++++++++---------- .../Perf_Parser_Directives_Suggest.cs | 1 - .../CommandLine/Perf_Parser_ParseResult.cs | 2 +- .../CommandLine/Perf_Parser_Simple.cs | 2 +- .../CommandLine/Perf_Parser_TypoCorrection.cs | 2 +- .../ConfigureFromMethodTests.cs | 2 +- .../CommandLine.cs | 2 +- .../HostingHandlerTest.cs | 2 +- .../HostingTests.cs | 2 +- .../HostingExtensions.cs | 2 +- .../ModelBinderTests.cs | 2 +- .../TerminalModeTests.cs | 2 +- .../ViewRenderingTests.cs | 2 +- .../CommandLineBuilderExtensions.cs | 1 - .../SuggestionDispatcher.cs | 2 +- .../CommandExtensionsTests.cs | 2 +- .../CompletionTests.cs | 2 +- .../EnvironmentVariableDirectiveTests.cs | 2 +- .../Help/HelpBuilderTests.Customization.cs | 2 +- .../Help/HelpBuilderTests.cs | 2 +- .../CancelOnProcessTerminationTests.cs | 1 - .../Invocation/InvocationPipelineTests.cs | 2 +- .../Invocation/TypoCorrectionTests.cs | 2 +- .../ParseDirectiveTests.cs | 2 +- .../ParserTests.DoubleDash.cs | 2 +- src/System.CommandLine.Tests/ParserTests.cs | 2 +- .../ResourceLocalizationTests.cs | 2 +- .../ResponseFileTests.cs | 2 +- .../SuggestDirectiveTests.cs | 2 +- .../TestApps/NativeAOT/Program.cs | 2 +- .../TokenReplacementTests.cs | 2 +- .../UseExceptionHandlerTests.cs | 2 +- src/System.CommandLine.Tests/UseHelpTests.cs | 2 +- .../UseParseErrorReportingTests.cs | 2 +- .../VersionOptionTests.cs | 2 +- .../Builder/CommandLineBuilder.cs | 2 +- .../Builder/CommandLineBuilderExtensions.cs | 4 +- src/System.CommandLine/Help/VersionOption.cs | 1 - src/System.CommandLine/SymbolExtensions.cs | 1 - 41 files changed, 65 insertions(+), 72 deletions(-) diff --git a/samples/HostingPlayground/Program.cs b/samples/HostingPlayground/Program.cs index d1e24b9bbf..c1105bf04d 100644 --- a/samples/HostingPlayground/Program.cs +++ b/samples/HostingPlayground/Program.cs @@ -1,5 +1,4 @@ using System.CommandLine; -using System.CommandLine.Builder; using System.CommandLine.Hosting; using System.CommandLine.NamingConventionBinder; using Microsoft.Extensions.Hosting; diff --git a/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_Hosting_api_is_not_changed.approved.txt b/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_Hosting_api_is_not_changed.approved.txt index 751524148f..a1123b8bd8 100644 --- a/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_Hosting_api_is_not_changed.approved.txt +++ b/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_Hosting_api_is_not_changed.approved.txt @@ -1,4 +1,4 @@ -System.CommandLine.Hosting +System.CommandLine.Hosting public static class DirectiveConfigurationExtensions public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCommandLineDirectives(this Microsoft.Extensions.Configuration.IConfigurationBuilder config, System.CommandLine.Parsing.ParseResult commandline, System.String name) public static class HostingExtensions @@ -8,8 +8,8 @@ public static System.CommandLine.Invocation.InvocationContext GetInvocationContext(this Microsoft.Extensions.Hosting.HostBuilderContext context) public static Microsoft.Extensions.Hosting.IHostBuilder UseCommandHandler(this Microsoft.Extensions.Hosting.IHostBuilder builder) public static Microsoft.Extensions.Hosting.IHostBuilder UseCommandHandler(this Microsoft.Extensions.Hosting.IHostBuilder builder, System.Type commandType, System.Type handlerType) - public static System.CommandLine.Builder.CommandLineBuilder UseHost(this System.CommandLine.Builder.CommandLineBuilder builder, System.Action configureHost = null) - public static System.CommandLine.Builder.CommandLineBuilder UseHost(this System.CommandLine.Builder.CommandLineBuilder builder, System.Func hostBuilderFactory, System.Action configureHost = null) + public static System.CommandLine.CommandLineBuilder UseHost(this System.CommandLine.CommandLineBuilder builder, System.Action configureHost = null) + public static System.CommandLine.CommandLineBuilder UseHost(this System.CommandLine.CommandLineBuilder builder, System.Func hostBuilderFactory, System.Action configureHost = null) public static Microsoft.Extensions.Hosting.IHostBuilder UseInvocationLifetime(this Microsoft.Extensions.Hosting.IHostBuilder host, System.CommandLine.Invocation.InvocationContext invocation, System.Action configureOptions = null) public class InvocationLifetime, Microsoft.Extensions.Hosting.IHostLifetime .ctor(Microsoft.Extensions.Options.IOptions options, Microsoft.Extensions.Hosting.IHostEnvironment environment, Microsoft.Extensions.Hosting.IHostApplicationLifetime applicationLifetime, System.CommandLine.Invocation.InvocationContext context = null, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory = null) diff --git a/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt b/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt index 77055af8ec..04ddf5a833 100644 --- a/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt +++ b/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt @@ -1,4 +1,4 @@ -System.CommandLine +System.CommandLine public abstract class Argument : Symbol, System.CommandLine.Binding.IValueDescriptor, System.CommandLine.Completions.ICompletionSource public ArgumentArity Arity { get; set; } public CompletionSourceList Completions { get; } @@ -70,6 +70,33 @@ public static System.Threading.Tasks.Task InvokeAsync(this Command command, System.String commandLine, IConsole console = null) public static System.CommandLine.Parsing.ParseResult Parse(this Command command, System.String[] args) public static System.CommandLine.Parsing.ParseResult Parse(this Command command, System.String commandLine) + public class CommandLineBuilder + .ctor(Command rootCommand = null) + public Command Command { get; } + public System.CommandLine.Parsing.Parser Build() + public static class CommandLineBuilderExtensions + public static CommandLineBuilder AddMiddleware(this CommandLineBuilder builder, System.CommandLine.Invocation.InvocationMiddleware middleware, System.CommandLine.Invocation.MiddlewareOrder order = Default) + public static CommandLineBuilder AddMiddleware(this CommandLineBuilder builder, System.Action onInvoke, System.CommandLine.Invocation.MiddlewareOrder order = Default) + public static CommandLineBuilder CancelOnProcessTermination(this CommandLineBuilder builder, System.Nullable timeout = null) + public static CommandLineBuilder EnableDirectives(this CommandLineBuilder builder, System.Boolean value = True) + public static CommandLineBuilder EnableLegacyDoubleDashBehavior(this CommandLineBuilder builder, System.Boolean value = True) + public static CommandLineBuilder EnablePosixBundling(this CommandLineBuilder builder, System.Boolean value = True) + public static CommandLineBuilder RegisterWithDotnetSuggest(this CommandLineBuilder builder) + public static CommandLineBuilder UseDefaults(this CommandLineBuilder builder) + public static CommandLineBuilder UseEnvironmentVariableDirective(this CommandLineBuilder builder) + public static CommandLineBuilder UseExceptionHandler(this CommandLineBuilder builder, System.Action onException = null, System.Nullable errorExitCode = null) + public static CommandLineBuilder UseHelp(this CommandLineBuilder builder, System.Nullable maxWidth = null) + public static CommandLineBuilder UseHelp(this CommandLineBuilder builder, System.String[] helpAliases) + public static CommandLineBuilder UseHelp(this CommandLineBuilder builder, System.Action customize, System.Nullable maxWidth = null) + public static TBuilder UseHelpBuilder(this TBuilder builder, System.Func getHelpBuilder) + public static CommandLineBuilder UseLocalizationResources(this CommandLineBuilder builder, LocalizationResources validationMessages) + public static CommandLineBuilder UseParseDirective(this CommandLineBuilder builder, System.Nullable errorExitCode = null) + public static CommandLineBuilder UseParseErrorReporting(this CommandLineBuilder builder, System.Nullable errorExitCode = null) + public static CommandLineBuilder UseSuggestDirective(this CommandLineBuilder builder) + public static CommandLineBuilder UseTokenReplacer(this CommandLineBuilder builder, System.CommandLine.Parsing.TryReplaceToken replaceToken) + public static CommandLineBuilder UseTypoCorrections(this CommandLineBuilder builder, System.Int32 maxLevenshteinDistance = 3) + public static CommandLineBuilder UseVersionOption(this CommandLineBuilder builder) + public static CommandLineBuilder UseVersionOption(this CommandLineBuilder builder, System.String[] aliases) public class CommandLineConfiguration .ctor(Command command, System.Boolean enablePosixBundling = True, System.Boolean enableDirectives = True, System.Boolean enableLegacyDoubleDashBehavior = False, System.Boolean enableTokenReplacement = True, LocalizationResources resources = null, System.Collections.Generic.IReadOnlyList middlewarePipeline = null, System.Func helpBuilderFactory = null, System.CommandLine.Parsing.TryReplaceToken tokenReplacer = null) public System.Boolean EnableDirectives { get; } @@ -232,34 +259,6 @@ System.CommandLine.Binding public interface IValueDescriptor : IValueDescriptor public interface IValueSource public System.Boolean TryGetValue(IValueDescriptor valueDescriptor, BindingContext bindingContext, ref System.Object& boundValue) -System.CommandLine.Builder - public class CommandLineBuilder - .ctor(System.CommandLine.Command rootCommand = null) - public System.CommandLine.Command Command { get; } - public System.CommandLine.Parsing.Parser Build() - public static class CommandLineBuilderExtensions - public static CommandLineBuilder AddMiddleware(this CommandLineBuilder builder, System.CommandLine.Invocation.InvocationMiddleware middleware, System.CommandLine.Invocation.MiddlewareOrder order = Default) - public static CommandLineBuilder AddMiddleware(this CommandLineBuilder builder, System.Action onInvoke, System.CommandLine.Invocation.MiddlewareOrder order = Default) - public static CommandLineBuilder CancelOnProcessTermination(this CommandLineBuilder builder, System.Nullable timeout = null) - public static CommandLineBuilder EnableDirectives(this CommandLineBuilder builder, System.Boolean value = True) - public static CommandLineBuilder EnableLegacyDoubleDashBehavior(this CommandLineBuilder builder, System.Boolean value = True) - public static CommandLineBuilder EnablePosixBundling(this CommandLineBuilder builder, System.Boolean value = True) - public static CommandLineBuilder RegisterWithDotnetSuggest(this CommandLineBuilder builder) - public static CommandLineBuilder UseDefaults(this CommandLineBuilder builder) - public static CommandLineBuilder UseEnvironmentVariableDirective(this CommandLineBuilder builder) - public static CommandLineBuilder UseExceptionHandler(this CommandLineBuilder builder, System.Action onException = null, System.Nullable errorExitCode = null) - public static CommandLineBuilder UseHelp(this CommandLineBuilder builder, System.Nullable maxWidth = null) - public static CommandLineBuilder UseHelp(this CommandLineBuilder builder, System.String[] helpAliases) - public static CommandLineBuilder UseHelp(this CommandLineBuilder builder, System.Action customize, System.Nullable maxWidth = null) - public static TBuilder UseHelpBuilder(this TBuilder builder, System.Func getHelpBuilder) - public static CommandLineBuilder UseLocalizationResources(this CommandLineBuilder builder, System.CommandLine.LocalizationResources validationMessages) - public static CommandLineBuilder UseParseDirective(this CommandLineBuilder builder, System.Nullable errorExitCode = null) - public static CommandLineBuilder UseParseErrorReporting(this CommandLineBuilder builder, System.Nullable errorExitCode = null) - public static CommandLineBuilder UseSuggestDirective(this CommandLineBuilder builder) - public static CommandLineBuilder UseTokenReplacer(this CommandLineBuilder builder, System.CommandLine.Parsing.TryReplaceToken replaceToken) - public static CommandLineBuilder UseTypoCorrections(this CommandLineBuilder builder, System.Int32 maxLevenshteinDistance = 3) - public static CommandLineBuilder UseVersionOption(this CommandLineBuilder builder) - public static CommandLineBuilder UseVersionOption(this CommandLineBuilder builder, System.String[] aliases) System.CommandLine.Completions public abstract class CompletionContext public System.CommandLine.Parsing.ParseResult ParseResult { get; } diff --git a/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Directives_Suggest.cs b/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Directives_Suggest.cs index aa1006c44a..f7cb9c8e45 100644 --- a/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Directives_Suggest.cs +++ b/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Directives_Suggest.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.CommandLine.Benchmarks.Helpers; -using System.CommandLine.Builder; using System.CommandLine.Invocation; using System.CommandLine.Parsing; using System.Threading.Tasks; diff --git a/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_ParseResult.cs b/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_ParseResult.cs index bf48c05412..581325a1e1 100644 --- a/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_ParseResult.cs +++ b/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_ParseResult.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.CommandLine.Benchmarks.Helpers; -using System.CommandLine.Builder; + using System.CommandLine.Parsing; using System.Linq; using BenchmarkDotNet.Attributes; diff --git a/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Simple.cs b/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Simple.cs index 7df4740269..6396b54d2d 100644 --- a/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Simple.cs +++ b/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Simple.cs @@ -1,5 +1,5 @@ using BenchmarkDotNet.Attributes; -using System.CommandLine.Builder; + using System.CommandLine.Invocation; using System.CommandLine.Parsing; using System.Threading.Tasks; diff --git a/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_TypoCorrection.cs b/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_TypoCorrection.cs index 63a4996c95..ab4d21c5d9 100644 --- a/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_TypoCorrection.cs +++ b/src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_TypoCorrection.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.CommandLine.Benchmarks.Helpers; -using System.CommandLine.Builder; + using System.CommandLine.Parsing; using System.Linq; using System.Threading.Tasks; diff --git a/src/System.CommandLine.DragonFruit.Tests/ConfigureFromMethodTests.cs b/src/System.CommandLine.DragonFruit.Tests/ConfigureFromMethodTests.cs index 0023e20d35..21938ec5cc 100644 --- a/src/System.CommandLine.DragonFruit.Tests/ConfigureFromMethodTests.cs +++ b/src/System.CommandLine.DragonFruit.Tests/ConfigureFromMethodTests.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.CommandLine.Binding; -using System.CommandLine.Builder; + using System.CommandLine.Invocation; using System.CommandLine.IO; using System.CommandLine.Parsing; diff --git a/src/System.CommandLine.DragonFruit/CommandLine.cs b/src/System.CommandLine.DragonFruit/CommandLine.cs index bd73b078ee..21dd9e419c 100644 --- a/src/System.CommandLine.DragonFruit/CommandLine.cs +++ b/src/System.CommandLine.DragonFruit/CommandLine.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.CommandLine.Binding; -using System.CommandLine.Builder; + using System.CommandLine.Invocation; using System.CommandLine.NamingConventionBinder; using System.CommandLine.Parsing; diff --git a/src/System.CommandLine.Hosting.Tests/HostingHandlerTest.cs b/src/System.CommandLine.Hosting.Tests/HostingHandlerTest.cs index c493c93fbf..e59dce3d64 100644 --- a/src/System.CommandLine.Hosting.Tests/HostingHandlerTest.cs +++ b/src/System.CommandLine.Hosting.Tests/HostingHandlerTest.cs @@ -1,5 +1,5 @@ using System.CommandLine.Binding; -using System.CommandLine.Builder; + using System.CommandLine.Invocation; using System.CommandLine.IO; using System.CommandLine.Parsing; diff --git a/src/System.CommandLine.Hosting.Tests/HostingTests.cs b/src/System.CommandLine.Hosting.Tests/HostingTests.cs index 3526399cc4..e2d98918af 100644 --- a/src/System.CommandLine.Hosting.Tests/HostingTests.cs +++ b/src/System.CommandLine.Hosting.Tests/HostingTests.cs @@ -1,5 +1,5 @@ using System.CommandLine.Binding; -using System.CommandLine.Builder; + using System.CommandLine.Invocation; using System.CommandLine.Parsing; using System.Linq; diff --git a/src/System.CommandLine.Hosting/HostingExtensions.cs b/src/System.CommandLine.Hosting/HostingExtensions.cs index dbef3565e5..466091f55f 100644 --- a/src/System.CommandLine.Hosting/HostingExtensions.cs +++ b/src/System.CommandLine.Hosting/HostingExtensions.cs @@ -1,5 +1,5 @@ using System.CommandLine.Binding; -using System.CommandLine.Builder; + using System.CommandLine.Invocation; using System.CommandLine.NamingConventionBinder; using System.Linq; diff --git a/src/System.CommandLine.NamingConventionBinder.Tests/ModelBinderTests.cs b/src/System.CommandLine.NamingConventionBinder.Tests/ModelBinderTests.cs index cd6c22a608..9e9bd49dd0 100644 --- a/src/System.CommandLine.NamingConventionBinder.Tests/ModelBinderTests.cs +++ b/src/System.CommandLine.NamingConventionBinder.Tests/ModelBinderTests.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using System.CommandLine.Builder; + using System.CommandLine.Invocation; using System.CommandLine.Parsing; using System.CommandLine.Tests.Binding; diff --git a/src/System.CommandLine.Rendering.Tests/TerminalModeTests.cs b/src/System.CommandLine.Rendering.Tests/TerminalModeTests.cs index f4a81ef22d..9a513d0792 100644 --- a/src/System.CommandLine.Rendering.Tests/TerminalModeTests.cs +++ b/src/System.CommandLine.Rendering.Tests/TerminalModeTests.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.CommandLine.Builder; + using System.CommandLine.Invocation; using System.CommandLine.IO; using System.CommandLine.Parsing; diff --git a/src/System.CommandLine.Rendering.Tests/ViewRenderingTests.cs b/src/System.CommandLine.Rendering.Tests/ViewRenderingTests.cs index 3c625b3916..120549bd1a 100644 --- a/src/System.CommandLine.Rendering.Tests/ViewRenderingTests.cs +++ b/src/System.CommandLine.Rendering.Tests/ViewRenderingTests.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.CommandLine.Builder; + using System.CommandLine.NamingConventionBinder; using System.CommandLine.Parsing; using System.CommandLine.Rendering.Views; diff --git a/src/System.CommandLine.Rendering/CommandLineBuilderExtensions.cs b/src/System.CommandLine.Rendering/CommandLineBuilderExtensions.cs index ee86c2bfc6..ab64436f2e 100644 --- a/src/System.CommandLine.Rendering/CommandLineBuilderExtensions.cs +++ b/src/System.CommandLine.Rendering/CommandLineBuilderExtensions.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.CommandLine.Binding; -using System.CommandLine.Builder; using System.Linq; namespace System.CommandLine.Rendering diff --git a/src/System.CommandLine.Suggest/SuggestionDispatcher.cs b/src/System.CommandLine.Suggest/SuggestionDispatcher.cs index a048320e48..23f45c4a26 100644 --- a/src/System.CommandLine.Suggest/SuggestionDispatcher.cs +++ b/src/System.CommandLine.Suggest/SuggestionDispatcher.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using System.CommandLine.Builder; + using System.CommandLine.Invocation; using System.CommandLine.IO; using System.CommandLine.Parsing; diff --git a/src/System.CommandLine.Tests/CommandExtensionsTests.cs b/src/System.CommandLine.Tests/CommandExtensionsTests.cs index a04d072137..638aa602ed 100644 --- a/src/System.CommandLine.Tests/CommandExtensionsTests.cs +++ b/src/System.CommandLine.Tests/CommandExtensionsTests.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using System.CommandLine.Builder; + using System.CommandLine.Invocation; using System.CommandLine.IO; using System.CommandLine.Parsing; diff --git a/src/System.CommandLine.Tests/CompletionTests.cs b/src/System.CommandLine.Tests/CompletionTests.cs index cad3b0b9a2..90cba5a61e 100644 --- a/src/System.CommandLine.Tests/CompletionTests.cs +++ b/src/System.CommandLine.Tests/CompletionTests.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.CommandLine.Builder; + using System.CommandLine.Parsing; using System.CommandLine.Tests.Utility; using System.IO; diff --git a/src/System.CommandLine.Tests/EnvironmentVariableDirectiveTests.cs b/src/System.CommandLine.Tests/EnvironmentVariableDirectiveTests.cs index 364e26afc2..752e2d4ce5 100644 --- a/src/System.CommandLine.Tests/EnvironmentVariableDirectiveTests.cs +++ b/src/System.CommandLine.Tests/EnvironmentVariableDirectiveTests.cs @@ -1,6 +1,6 @@ using FluentAssertions; -using System.CommandLine.Builder; + using System.CommandLine.Invocation; using System.CommandLine.Parsing; using System.Linq; diff --git a/src/System.CommandLine.Tests/Help/HelpBuilderTests.Customization.cs b/src/System.CommandLine.Tests/Help/HelpBuilderTests.Customization.cs index 37661cc51e..0354d7b0d7 100644 --- a/src/System.CommandLine.Tests/Help/HelpBuilderTests.Customization.cs +++ b/src/System.CommandLine.Tests/Help/HelpBuilderTests.Customization.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.CommandLine.Builder; + using System.CommandLine.Help; using System.CommandLine.IO; using System.CommandLine.Parsing; diff --git a/src/System.CommandLine.Tests/Help/HelpBuilderTests.cs b/src/System.CommandLine.Tests/Help/HelpBuilderTests.cs index f21c33965f..9ab174b22d 100644 --- a/src/System.CommandLine.Tests/Help/HelpBuilderTests.cs +++ b/src/System.CommandLine.Tests/Help/HelpBuilderTests.cs @@ -3,7 +3,7 @@ using FluentAssertions; using System.Collections.Generic; -using System.CommandLine.Builder; + using System.CommandLine.Help; using System.IO; using System.Linq; diff --git a/src/System.CommandLine.Tests/Invocation/CancelOnProcessTerminationTests.cs b/src/System.CommandLine.Tests/Invocation/CancelOnProcessTerminationTests.cs index 356b805a42..bb16e59a6d 100644 --- a/src/System.CommandLine.Tests/Invocation/CancelOnProcessTerminationTests.cs +++ b/src/System.CommandLine.Tests/Invocation/CancelOnProcessTerminationTests.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.CommandLine.Builder; using System.CommandLine.Invocation; using System.CommandLine.Parsing; using System.CommandLine.Tests.Utility; diff --git a/src/System.CommandLine.Tests/Invocation/InvocationPipelineTests.cs b/src/System.CommandLine.Tests/Invocation/InvocationPipelineTests.cs index 33051dd747..b5a91fc867 100644 --- a/src/System.CommandLine.Tests/Invocation/InvocationPipelineTests.cs +++ b/src/System.CommandLine.Tests/Invocation/InvocationPipelineTests.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.CommandLine.Binding; -using System.CommandLine.Builder; + using System.CommandLine.Help; using System.CommandLine.Invocation; using System.CommandLine.IO; diff --git a/src/System.CommandLine.Tests/Invocation/TypoCorrectionTests.cs b/src/System.CommandLine.Tests/Invocation/TypoCorrectionTests.cs index 8885eca78f..38b051ee3b 100644 --- a/src/System.CommandLine.Tests/Invocation/TypoCorrectionTests.cs +++ b/src/System.CommandLine.Tests/Invocation/TypoCorrectionTests.cs @@ -1,4 +1,4 @@ -using System.CommandLine.Builder; + using System.CommandLine.IO; using System.CommandLine.Parsing; using System.Threading.Tasks; diff --git a/src/System.CommandLine.Tests/ParseDirectiveTests.cs b/src/System.CommandLine.Tests/ParseDirectiveTests.cs index e23f38733c..271fb5888a 100644 --- a/src/System.CommandLine.Tests/ParseDirectiveTests.cs +++ b/src/System.CommandLine.Tests/ParseDirectiveTests.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using FluentAssertions; -using System.CommandLine.Builder; + using System.CommandLine.IO; using System.CommandLine.Parsing; using System.Threading.Tasks; diff --git a/src/System.CommandLine.Tests/ParserTests.DoubleDash.cs b/src/System.CommandLine.Tests/ParserTests.DoubleDash.cs index c4546dc25a..fd71cdd9b5 100644 --- a/src/System.CommandLine.Tests/ParserTests.DoubleDash.cs +++ b/src/System.CommandLine.Tests/ParserTests.DoubleDash.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.CommandLine.Builder; + using System.CommandLine.Parsing; using System.CommandLine.Tests.Utility; using FluentAssertions; diff --git a/src/System.CommandLine.Tests/ParserTests.cs b/src/System.CommandLine.Tests/ParserTests.cs index 88c35796b1..eb84d7d41d 100644 --- a/src/System.CommandLine.Tests/ParserTests.cs +++ b/src/System.CommandLine.Tests/ParserTests.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using System.CommandLine.Builder; + using System.CommandLine.Parsing; using System.CommandLine.Tests.Utility; using System.IO; diff --git a/src/System.CommandLine.Tests/ResourceLocalizationTests.cs b/src/System.CommandLine.Tests/ResourceLocalizationTests.cs index 0504d86e3d..36446293ef 100644 --- a/src/System.CommandLine.Tests/ResourceLocalizationTests.cs +++ b/src/System.CommandLine.Tests/ResourceLocalizationTests.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using System.CommandLine.Builder; + using System.CommandLine.Parsing; using FluentAssertions; using System.Linq; diff --git a/src/System.CommandLine.Tests/ResponseFileTests.cs b/src/System.CommandLine.Tests/ResponseFileTests.cs index f50ac20f11..8ad456f716 100644 --- a/src/System.CommandLine.Tests/ResponseFileTests.cs +++ b/src/System.CommandLine.Tests/ResponseFileTests.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using System.CommandLine.Builder; + using System.CommandLine.Parsing; using System.CommandLine.Tests.Utility; using System.IO; diff --git a/src/System.CommandLine.Tests/SuggestDirectiveTests.cs b/src/System.CommandLine.Tests/SuggestDirectiveTests.cs index 4849ce2cb3..219c1fe0fb 100644 --- a/src/System.CommandLine.Tests/SuggestDirectiveTests.cs +++ b/src/System.CommandLine.Tests/SuggestDirectiveTests.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.CommandLine.Builder; + using System.CommandLine.IO; using System.CommandLine.Parsing; using System.Threading.Tasks; diff --git a/src/System.CommandLine.Tests/TestApps/NativeAOT/Program.cs b/src/System.CommandLine.Tests/TestApps/NativeAOT/Program.cs index ca773abbde..6fb0e9ef14 100644 --- a/src/System.CommandLine.Tests/TestApps/NativeAOT/Program.cs +++ b/src/System.CommandLine.Tests/TestApps/NativeAOT/Program.cs @@ -1,6 +1,6 @@ using System; using System.CommandLine; -using System.CommandLine.Builder; + using System.CommandLine.Invocation; using System.CommandLine.Parsing; diff --git a/src/System.CommandLine.Tests/TokenReplacementTests.cs b/src/System.CommandLine.Tests/TokenReplacementTests.cs index 7bc72ea020..816b2e38e4 100644 --- a/src/System.CommandLine.Tests/TokenReplacementTests.cs +++ b/src/System.CommandLine.Tests/TokenReplacementTests.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using System.CommandLine.Builder; + using System.CommandLine.Parsing; using FluentAssertions; using Xunit; diff --git a/src/System.CommandLine.Tests/UseExceptionHandlerTests.cs b/src/System.CommandLine.Tests/UseExceptionHandlerTests.cs index 5346d2df49..7a62385777 100644 --- a/src/System.CommandLine.Tests/UseExceptionHandlerTests.cs +++ b/src/System.CommandLine.Tests/UseExceptionHandlerTests.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.CommandLine.Builder; + using System.CommandLine.IO; using System.CommandLine.Parsing; using System.Threading.Tasks; diff --git a/src/System.CommandLine.Tests/UseHelpTests.cs b/src/System.CommandLine.Tests/UseHelpTests.cs index 489228f411..0bfea3593b 100644 --- a/src/System.CommandLine.Tests/UseHelpTests.cs +++ b/src/System.CommandLine.Tests/UseHelpTests.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using System.CommandLine.Builder; + using System.CommandLine.Help; using System.CommandLine.IO; using System.CommandLine.Parsing; diff --git a/src/System.CommandLine.Tests/UseParseErrorReportingTests.cs b/src/System.CommandLine.Tests/UseParseErrorReportingTests.cs index 7947d601b9..45717b2a36 100644 --- a/src/System.CommandLine.Tests/UseParseErrorReportingTests.cs +++ b/src/System.CommandLine.Tests/UseParseErrorReportingTests.cs @@ -4,7 +4,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.CommandLine.Builder; + using System.CommandLine.Parsing; using FluentAssertions; using Xunit; diff --git a/src/System.CommandLine.Tests/VersionOptionTests.cs b/src/System.CommandLine.Tests/VersionOptionTests.cs index 4671567a3b..310e23d10f 100644 --- a/src/System.CommandLine.Tests/VersionOptionTests.cs +++ b/src/System.CommandLine.Tests/VersionOptionTests.cs @@ -1,7 +1,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.CommandLine.Builder; + using System.CommandLine.Invocation; using System.CommandLine.IO; using System.CommandLine.Parsing; diff --git a/src/System.CommandLine/Builder/CommandLineBuilder.cs b/src/System.CommandLine/Builder/CommandLineBuilder.cs index 7fd52454af..96f079f8c2 100644 --- a/src/System.CommandLine/Builder/CommandLineBuilder.cs +++ b/src/System.CommandLine/Builder/CommandLineBuilder.cs @@ -7,7 +7,7 @@ using System.CommandLine.Invocation; using System.CommandLine.Parsing; -namespace System.CommandLine.Builder +namespace System.CommandLine { /// /// Enables composition of command line configurations. diff --git a/src/System.CommandLine/Builder/CommandLineBuilderExtensions.cs b/src/System.CommandLine/Builder/CommandLineBuilderExtensions.cs index 40cc593b75..c205d321ec 100644 --- a/src/System.CommandLine/Builder/CommandLineBuilderExtensions.cs +++ b/src/System.CommandLine/Builder/CommandLineBuilderExtensions.cs @@ -14,7 +14,7 @@ using static System.Environment; using Process = System.CommandLine.Invocation.Process; -namespace System.CommandLine.Builder +namespace System.CommandLine { /// /// Provides extension methods for . @@ -685,7 +685,7 @@ public static CommandLineBuilder UseVersionOption( return builder; } - /// + /// /// One or more aliases to use instead of the default to signal that version information should be displayed. /// A command line builder. public static CommandLineBuilder UseVersionOption( diff --git a/src/System.CommandLine/Help/VersionOption.cs b/src/System.CommandLine/Help/VersionOption.cs index 602478797e..85b6675320 100644 --- a/src/System.CommandLine/Help/VersionOption.cs +++ b/src/System.CommandLine/Help/VersionOption.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.CommandLine.Builder; using System.CommandLine.Parsing; using System.Linq; diff --git a/src/System.CommandLine/SymbolExtensions.cs b/src/System.CommandLine/SymbolExtensions.cs index 6739fb2e4c..036e4e3237 100644 --- a/src/System.CommandLine/SymbolExtensions.cs +++ b/src/System.CommandLine/SymbolExtensions.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using System.CommandLine.Builder; using System.CommandLine.Parsing; namespace System.CommandLine From b2d28f33a51d08dc10e67198b71b47a3a0178bed Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Thu, 30 Jun 2022 23:49:00 -0700 Subject: [PATCH 2/6] Move System.CommandLine.Parsing.ParseResult to System.CommandLine --- ...ne_Hosting_api_is_not_changed.approved.txt | 2 +- ...ommandLine_api_is_not_changed.approved.txt | 76 +++++++++---------- .../WellKnownTypes.cs | 2 +- .../{Parsing => }/ParseResult.cs | 3 +- 4 files changed, 42 insertions(+), 41 deletions(-) rename src/System.CommandLine/{Parsing => }/ParseResult.cs (99%) diff --git a/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_Hosting_api_is_not_changed.approved.txt b/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_Hosting_api_is_not_changed.approved.txt index a1123b8bd8..2cbc0bafdb 100644 --- a/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_Hosting_api_is_not_changed.approved.txt +++ b/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_Hosting_api_is_not_changed.approved.txt @@ -1,6 +1,6 @@ System.CommandLine.Hosting public static class DirectiveConfigurationExtensions - public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCommandLineDirectives(this Microsoft.Extensions.Configuration.IConfigurationBuilder config, System.CommandLine.Parsing.ParseResult commandline, System.String name) + public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCommandLineDirectives(this Microsoft.Extensions.Configuration.IConfigurationBuilder config, System.CommandLine.ParseResult commandline, System.String name) public static class HostingExtensions public static OptionsBuilder BindCommandLine(this OptionsBuilder optionsBuilder) public static Microsoft.Extensions.Hosting.IHost GetHost(this System.CommandLine.Invocation.InvocationContext invocationContext) diff --git a/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt b/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt index 04ddf5a833..0b08a528f9 100644 --- a/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt +++ b/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt @@ -43,8 +43,8 @@ System.CommandLine public static TArgument FromAmong(this TArgument argument, System.String[] values) public static TArgument LegalFileNamesOnly(this TArgument argument) public static TArgument LegalFilePathsOnly(this TArgument argument) - public static System.CommandLine.Parsing.ParseResult Parse(this Argument argument, System.String commandLine) - public static System.CommandLine.Parsing.ParseResult Parse(this Argument argument, System.String[] args) + public static ParseResult Parse(this Argument argument, System.String commandLine) + public static ParseResult Parse(this Argument argument, System.String[] args) public class Command : IdentifierSymbol, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable, System.CommandLine.Completions.ICompletionSource .ctor(System.String name, System.String description = null) public System.Collections.Generic.IReadOnlyList Arguments { get; } @@ -68,8 +68,8 @@ System.CommandLine public static System.Int32 Invoke(this Command command, System.String commandLine, IConsole console = null) public static System.Threading.Tasks.Task InvokeAsync(this Command command, System.String[] args, IConsole console = null) public static System.Threading.Tasks.Task InvokeAsync(this Command command, System.String commandLine, IConsole console = null) - public static System.CommandLine.Parsing.ParseResult Parse(this Command command, System.String[] args) - public static System.CommandLine.Parsing.ParseResult Parse(this Command command, System.String commandLine) + public static ParseResult Parse(this Command command, System.String[] args) + public static ParseResult Parse(this Command command, System.String commandLine) public class CommandLineBuilder .ctor(Command rootCommand = null) public Command Command { get; } @@ -223,8 +223,28 @@ System.CommandLine public static TOption FromAmong(this TOption option, System.String[] values) public static TOption LegalFileNamesOnly(this TOption option) public static TOption LegalFilePathsOnly(this TOption option) - public static System.CommandLine.Parsing.ParseResult Parse(this Option option, System.String commandLine) - public static System.CommandLine.Parsing.ParseResult Parse(this Option option, System.String[] args) + public static ParseResult Parse(this Option option, System.String commandLine) + public static ParseResult Parse(this Option option, System.String[] args) + public class ParseResult + public System.CommandLine.Parsing.CommandResult CommandResult { get; } + public DirectiveCollection Directives { get; } + public System.Collections.Generic.IReadOnlyList Errors { get; } + public System.CommandLine.Parsing.Parser Parser { get; } + public System.CommandLine.Parsing.CommandResult RootCommandResult { get; } + public System.Collections.Generic.IReadOnlyList Tokens { get; } + public System.Collections.Generic.IReadOnlyList UnmatchedTokens { get; } + public System.Collections.Generic.IReadOnlyList UnparsedTokens { get; } + public System.CommandLine.Parsing.ArgumentResult FindResultFor(Argument argument) + public System.CommandLine.Parsing.CommandResult FindResultFor(Command command) + public System.CommandLine.Parsing.OptionResult FindResultFor(Option option) + public System.CommandLine.Parsing.SymbolResult FindResultFor(Symbol symbol) + public System.CommandLine.Completions.CompletionContext GetCompletionContext() + public System.Collections.Generic.IEnumerable GetCompletions(System.Nullable position = null) + public System.Object GetValueForArgument(Argument argument) + public T GetValueForArgument(Argument argument) + public System.Object GetValueForOption(Option option) + public T GetValueForOption(Option option) + public System.String ToString() public class RootCommand : Command, System.Collections.Generic.IEnumerable, System.Collections.IEnumerable, System.CommandLine.Completions.ICompletionSource public static System.String ExecutableName { get; } public static System.String ExecutablePath { get; } @@ -242,7 +262,7 @@ System.CommandLine.Binding protected T GetBoundValue(BindingContext bindingContext) public class BindingContext, System.IServiceProvider public System.CommandLine.IConsole Console { get; } - public System.CommandLine.Parsing.ParseResult ParseResult { get; } + public System.CommandLine.ParseResult ParseResult { get; } public System.Void AddService(System.Type serviceType, System.Func factory) public System.Void AddService(Func factory) public System.Object GetService(System.Type serviceType) @@ -261,7 +281,7 @@ System.CommandLine.Binding public System.Boolean TryGetValue(IValueDescriptor valueDescriptor, BindingContext bindingContext, ref System.Object& boundValue) System.CommandLine.Completions public abstract class CompletionContext - public System.CommandLine.Parsing.ParseResult ParseResult { get; } + public System.CommandLine.ParseResult ParseResult { get; } public System.String WordToComplete { get; } public delegate CompletionDelegate : System.MulticastDelegate, System.ICloneable, System.Runtime.Serialization.ISerializable .ctor(System.Object object, System.IntPtr method) @@ -314,11 +334,11 @@ System.CommandLine.Help public static System.Void CustomizeSymbol(this HelpBuilder builder, System.CommandLine.Symbol symbol, System.String firstColumnText = null, System.String secondColumnText = null, System.String defaultValue = null) public static System.Void Write(this HelpBuilder helpBuilder, System.CommandLine.Command command, System.IO.TextWriter writer) public class HelpContext - .ctor(HelpBuilder helpBuilder, System.CommandLine.Command command, System.IO.TextWriter output, System.CommandLine.Parsing.ParseResult parseResult = null) + .ctor(HelpBuilder helpBuilder, System.CommandLine.Command command, System.IO.TextWriter output, System.CommandLine.ParseResult parseResult = null) public System.CommandLine.Command Command { get; } public HelpBuilder HelpBuilder { get; } public System.IO.TextWriter Output { get; } - public System.CommandLine.Parsing.ParseResult ParseResult { get; } + public System.CommandLine.ParseResult ParseResult { get; } public delegate HelpSectionDelegate : System.MulticastDelegate, System.ICloneable, System.Runtime.Serialization.ISerializable .ctor(System.Object object, System.IntPtr method) public System.IAsyncResult BeginInvoke(HelpContext context, System.AsyncCallback callback, System.Object object) @@ -338,7 +358,7 @@ System.CommandLine.Invocation public interface IInvocationResult public System.Void Apply(InvocationContext context) public class InvocationContext - .ctor(System.CommandLine.Parsing.ParseResult parseResult, System.CommandLine.IConsole console = null) + .ctor(System.CommandLine.ParseResult parseResult, System.CommandLine.IConsole console = null) public System.CommandLine.Binding.BindingContext BindingContext { get; } public System.CommandLine.IConsole Console { get; set; } public System.Int32 ExitCode { get; set; } @@ -346,7 +366,7 @@ System.CommandLine.Invocation public IInvocationResult InvocationResult { get; set; } public System.CommandLine.LocalizationResources LocalizationResources { get; } public System.CommandLine.Parsing.Parser Parser { get; } - public System.CommandLine.Parsing.ParseResult ParseResult { get; set; } + public System.CommandLine.ParseResult ParseResult { get; set; } public System.Threading.CancellationToken GetCancellationToken() public delegate InvocationMiddleware : System.MulticastDelegate, System.ICloneable, System.Runtime.Serialization.ISerializable .ctor(System.Object object, System.IntPtr method) @@ -425,38 +445,18 @@ System.CommandLine.Parsing .ctor(System.CommandLine.Command command) .ctor() public System.CommandLine.CommandLineConfiguration Configuration { get; } - public ParseResult Parse(System.Collections.Generic.IReadOnlyList arguments, System.String rawInput = null) - public class ParseResult - public CommandResult CommandResult { get; } - public System.CommandLine.DirectiveCollection Directives { get; } - public System.Collections.Generic.IReadOnlyList Errors { get; } - public Parser Parser { get; } - public CommandResult RootCommandResult { get; } - public System.Collections.Generic.IReadOnlyList Tokens { get; } - public System.Collections.Generic.IReadOnlyList UnmatchedTokens { get; } - public System.Collections.Generic.IReadOnlyList UnparsedTokens { get; } - public ArgumentResult FindResultFor(System.CommandLine.Argument argument) - public CommandResult FindResultFor(System.CommandLine.Command command) - public OptionResult FindResultFor(System.CommandLine.Option option) - public SymbolResult FindResultFor(System.CommandLine.Symbol symbol) - public System.CommandLine.Completions.CompletionContext GetCompletionContext() - public System.Collections.Generic.IEnumerable GetCompletions(System.Nullable position = null) - public System.Object GetValueForArgument(System.CommandLine.Argument argument) - public T GetValueForArgument(Argument argument) - public System.Object GetValueForOption(System.CommandLine.Option option) - public T GetValueForOption(Option option) - public System.String ToString() + public System.CommandLine.ParseResult Parse(System.Collections.Generic.IReadOnlyList arguments, System.String rawInput = null) public static class ParseResultExtensions - public static System.String Diagram(this ParseResult parseResult) - public static System.Boolean HasOption(this ParseResult parseResult, System.CommandLine.Option option) - public static System.Int32 Invoke(this ParseResult parseResult, System.CommandLine.IConsole console = null) - public static System.Threading.Tasks.Task InvokeAsync(this ParseResult parseResult, System.CommandLine.IConsole console = null) + public static System.String Diagram(this System.CommandLine.ParseResult parseResult) + public static System.Boolean HasOption(this System.CommandLine.ParseResult parseResult, System.CommandLine.Option option) + public static System.Int32 Invoke(this System.CommandLine.ParseResult parseResult, System.CommandLine.IConsole console = null) + public static System.Threading.Tasks.Task InvokeAsync(this System.CommandLine.ParseResult parseResult, System.CommandLine.IConsole console = null) public static class ParserExtensions public static System.Int32 Invoke(this Parser parser, System.String commandLine, System.CommandLine.IConsole console = null) public static System.Int32 Invoke(this Parser parser, System.String[] args, System.CommandLine.IConsole console = null) public static System.Threading.Tasks.Task InvokeAsync(this Parser parser, System.String commandLine, System.CommandLine.IConsole console = null) public static System.Threading.Tasks.Task InvokeAsync(this Parser parser, System.String[] args, System.CommandLine.IConsole console = null) - public static ParseResult Parse(this Parser parser, System.String commandLine) + public static System.CommandLine.ParseResult Parse(this Parser parser, System.String commandLine) public abstract class SymbolResult public System.Collections.Generic.IReadOnlyList Children { get; } public System.String ErrorMessage { get; set; } diff --git a/src/System.CommandLine.Generator/WellKnownTypes.cs b/src/System.CommandLine.Generator/WellKnownTypes.cs index 34235a1a4d..fda81b51ad 100644 --- a/src/System.CommandLine.Generator/WellKnownTypes.cs +++ b/src/System.CommandLine.Generator/WellKnownTypes.cs @@ -19,7 +19,7 @@ internal class WellKnownTypes public WellKnownTypes(Compilation compilation, IEqualityComparer comparer) { Console = GetType("System.CommandLine.IConsole"); - ParseResult = GetType("System.CommandLine.Parsing.ParseResult"); + ParseResult = GetType("System.CommandLine.ParseResult"); InvocationContext = GetType("System.CommandLine.Invocation.InvocationContext"); HelpBuilder = GetType("System.CommandLine.Help.HelpBuilder"); BindingContext = GetType("System.CommandLine.Binding.BindingContext"); diff --git a/src/System.CommandLine/Parsing/ParseResult.cs b/src/System.CommandLine/ParseResult.cs similarity index 99% rename from src/System.CommandLine/Parsing/ParseResult.cs rename to src/System.CommandLine/ParseResult.cs index de226f453d..25ef494f2a 100644 --- a/src/System.CommandLine/Parsing/ParseResult.cs +++ b/src/System.CommandLine/ParseResult.cs @@ -4,10 +4,11 @@ using System.Collections.Generic; using System.CommandLine.Binding; using System.CommandLine.Completions; +using System.CommandLine.Parsing; using System.Diagnostics.CodeAnalysis; using System.Linq; -namespace System.CommandLine.Parsing +namespace System.CommandLine { /// /// Describes the results of parsing a command line input based on a specific parser configuration. From 2922607555473b3fe4c2516f21cf5301952fd9da Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Fri, 1 Jul 2022 00:19:23 -0700 Subject: [PATCH 3/6] Move System.CommandLine.Invocation.ICommandHandler to System.CommandLine --- ...tionBinder_api_is_not_changed.approved.txt | 136 +++++++++--------- ...ommandLine_api_is_not_changed.approved.txt | 8 +- .../CommandHandlerSourceGenerator.cs | 2 +- .../HostingHandlerTest.cs | 3 +- .../ParameterBindingTests.cs | 1 + .../DelegateHandlerDescriptor.cs | 1 - .../HandlerDescriptor.cs | 1 - .../MethodInfoHandlerDescriptor.cs | 1 - .../Builder/CommandLineBuilderExtensions.cs | 1 + src/System.CommandLine/Command.cs | 1 - .../{Invocation => }/ICommandHandler.cs | 3 +- 11 files changed, 79 insertions(+), 79 deletions(-) rename src/System.CommandLine/{Invocation => }/ICommandHandler.cs (94%) diff --git a/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_NamingConventionBinder_api_is_not_changed.approved.txt b/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_NamingConventionBinder_api_is_not_changed.approved.txt index d01b397a21..b509ade0c0 100644 --- a/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_NamingConventionBinder_api_is_not_changed.approved.txt +++ b/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_NamingConventionBinder_api_is_not_changed.approved.txt @@ -3,72 +3,72 @@ public static System.Void AddModelBinder(this System.CommandLine.Binding.BindingContext bindingContext, ModelBinder binder) public static ModelBinder GetOrCreateModelBinder(this System.CommandLine.Binding.BindingContext bindingContext, System.CommandLine.Binding.IValueDescriptor valueDescriptor) public static class CommandHandler - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(System.Delegate delegate) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Action action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(Func> action) - public static System.CommandLine.Invocation.ICommandHandler Create(System.Reflection.MethodInfo method, System.Object target = null) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(System.Delegate delegate) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Action action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(Func> action) + public static System.CommandLine.ICommandHandler Create(System.Reflection.MethodInfo method, System.Object target = null) public class ConstructorDescriptor, IMethodDescriptor public System.Collections.Generic.IReadOnlyList ParameterDescriptors { get; } public ModelDescriptor Parent { get; } @@ -78,7 +78,7 @@ public static HandlerDescriptor FromMethodInfo(System.Reflection.MethodInfo methodInfo, System.Object target = null) public System.Collections.Generic.IReadOnlyList ParameterDescriptors { get; } public ModelDescriptor Parent { get; } - public System.CommandLine.Invocation.ICommandHandler GetCommandHandler() + public System.CommandLine.ICommandHandler GetCommandHandler() public System.String ToString() public interface IMethodDescriptor public System.Collections.Generic.IReadOnlyList ParameterDescriptors { get; } @@ -95,7 +95,7 @@ .ctor() public System.Void BindMemberFromValue(Expression> property, System.CommandLine.Binding.IValueDescriptor valueDescriptor) public System.Void BindMemberFromValue(Expression> property, Func getValue) - public class ModelBindingCommandHandler, System.CommandLine.Invocation.ICommandHandler + public class ModelBindingCommandHandler, System.CommandLine.ICommandHandler public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.Argument argument) public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.Option option) public System.Int32 Invoke(System.CommandLine.Invocation.InvocationContext context) diff --git a/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt b/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt index 0b08a528f9..6b42819629 100644 --- a/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt +++ b/src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_api_is_not_changed.approved.txt @@ -49,7 +49,7 @@ System.CommandLine .ctor(System.String name, System.String description = null) public System.Collections.Generic.IReadOnlyList Arguments { get; } public System.Collections.Generic.IEnumerable Children { get; } - public System.CommandLine.Invocation.ICommandHandler Handler { get; set; } + public ICommandHandler Handler { get; set; } public System.Collections.Generic.IReadOnlyList