Skip to content

Commit 403234a

Browse files
authored
rename symbol types with Cli prefix; some property renames and file moves (#2132)
1 parent 6706d65 commit 403234a

File tree

125 files changed

+2271
-2259
lines changed

Some content is hidden

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

125 files changed

+2271
-2259
lines changed

samples/HostingPlayground/Program.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ static Task Main(string[] args) => BuildCommandLine()
2424

2525
private static CommandLineConfiguration BuildCommandLine()
2626
{
27-
var root = new RootCommand(@"$ dotnet run --name 'Joe'"){
28-
new Option<string>("--name"){
29-
IsRequired = true
27+
var root = new CliRootCommand(@"$ dotnet run --name 'Joe'"){
28+
new CliOption<string>("--name"){
29+
Required = true
3030
}
3131
};
3232
root.Action = CommandHandler.Create<GreeterOptions, IHost>(Run);

src/Common/ArgumentBuilder.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ internal static class ArgumentBuilder
99

1010
static ArgumentBuilder()
1111
{
12-
_ctor = typeof(Argument<string>).GetConstructor(new[] { typeof(string) });
12+
_ctor = typeof(CliArgument<string>).GetConstructor(new[] { typeof(string) });
1313
}
1414

15-
public static Argument CreateArgument(Type valueType, string name = "value")
15+
public static CliArgument CreateArgument(Type valueType, string name = "value")
1616
{
17-
var argumentType = typeof(Argument<>).MakeGenericType(valueType);
17+
var argumentType = typeof(CliArgument<>).MakeGenericType(valueType);
1818

1919
#if NET6_0_OR_GREATER
2020
var ctor = (ConstructorInfo)argumentType.GetMemberWithSameMetadataDefinitionAs(_ctor);
2121
#else
2222
var ctor = argumentType.GetConstructor(new[] { typeof(string) });
2323
#endif
2424

25-
return (Argument)ctor.Invoke(new object[] { name });
25+
return (CliArgument)ctor.Invoke(new object[] { name });
2626
}
2727

28-
internal static Argument CreateArgument(ParameterInfo argsParam)
28+
internal static CliArgument CreateArgument(ParameterInfo argsParam)
2929
{
3030
if (!argsParam.HasDefaultValue)
3131
{
@@ -36,10 +36,10 @@ internal static Argument CreateArgument(ParameterInfo argsParam)
3636

3737
var ctor = argumentType.GetConstructor(new[] { typeof(string), argsParam.ParameterType });
3838

39-
return (Argument)ctor.Invoke(new object[] { argsParam.Name, argsParam.DefaultValue });
39+
return (CliArgument)ctor.Invoke(new object[] { argsParam.Name, argsParam.DefaultValue });
4040
}
4141

42-
private sealed class Bridge<T> : Argument<T>
42+
private sealed class Bridge<T> : CliArgument<T>
4343
{
4444
public Bridge(string name, T defaultValue)
4545
: base(name)

src/Common/OptionBuilder.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ internal static class OptionBuilder
1111

1212
static OptionBuilder()
1313
{
14-
_ctor = typeof(Option<string>).GetConstructor(new[] { typeof(string), typeof(string[]) });
14+
_ctor = typeof(CliOption<string>).GetConstructor(new[] { typeof(string), typeof(string[]) });
1515
}
1616

17-
internal static Option CreateOption(string name, Type valueType, string description = null)
17+
internal static CliOption CreateOption(string name, Type valueType, string description = null)
1818
{
19-
var optionType = typeof(Option<>).MakeGenericType(valueType);
19+
var optionType = typeof(CliOption<>).MakeGenericType(valueType);
2020

2121
#if NET6_0_OR_GREATER
2222
var ctor = (ConstructorInfo)optionType.GetMemberWithSameMetadataDefinitionAs(_ctor);
2323
#else
2424
var ctor = optionType.GetConstructor(new[] { typeof(string), typeof(string[]) });
2525
#endif
2626

27-
var option = (Option)ctor.Invoke(new object[] { name, Array.Empty<string>() });
27+
var option = (CliOption)ctor.Invoke(new object[] { name, Array.Empty<string>() });
2828

2929
option.Description = description;
3030

3131
return option;
3232
}
3333

34-
internal static Option CreateOption(string name, Type valueType, string description, Func<object> defaultValueFactory)
34+
internal static CliOption CreateOption(string name, Type valueType, string description, Func<object> defaultValueFactory)
3535
{
3636
if (defaultValueFactory == null)
3737
{
@@ -42,12 +42,12 @@ internal static Option CreateOption(string name, Type valueType, string descript
4242

4343
var ctor = optionType.GetConstructor(new[] { typeof(string), typeof(Func<object>), typeof(string) });
4444

45-
var option = (Option)ctor.Invoke(new object[] { name, defaultValueFactory, description });
45+
var option = (CliOption)ctor.Invoke(new object[] { name, defaultValueFactory, description });
4646

4747
return option;
4848
}
4949

50-
private sealed class Bridge<T> : Option<T>
50+
private sealed class Bridge<T> : CliOption<T>
5151
{
5252
public Bridge(string name, Func<object> defaultValueFactory, string description)
5353
: base(name)

src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_Hosting_api_is_not_changed.approved.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
System.CommandLine.Hosting
22
public static class DirectiveConfigurationExtensions
3-
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCommandLineDirectives(this Microsoft.Extensions.Configuration.IConfigurationBuilder config, System.CommandLine.ParseResult commandline, System.CommandLine.Directive directive)
3+
public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCommandLineDirectives(this Microsoft.Extensions.Configuration.IConfigurationBuilder config, System.CommandLine.ParseResult commandline, System.CommandLine.CliDirective directive)
44
public static class HostingExtensions
55
public static OptionsBuilder<TOptions> BindCommandLine<TOptions>(this OptionsBuilder<TOptions> optionsBuilder)
66
public static Microsoft.Extensions.Hosting.IHost GetHost(this System.CommandLine.ParseResult parseResult)
77
public static System.CommandLine.ParseResult GetParseResult(this Microsoft.Extensions.Hosting.IHostBuilder hostBuilder)
88
public static System.CommandLine.ParseResult GetParseResult(this Microsoft.Extensions.Hosting.HostBuilderContext context)
9-
public static System.CommandLine.Command UseCommandHandler<THandler>(this System.CommandLine.Command command)
9+
public static System.CommandLine.CliCommand UseCommandHandler<THandler>(this System.CommandLine.CliCommand command)
1010
public static System.CommandLine.CommandLineConfiguration UseHost(this System.CommandLine.CommandLineConfiguration builder, System.Action<Microsoft.Extensions.Hosting.IHostBuilder> configureHost = null)
1111
public static System.CommandLine.CommandLineConfiguration UseHost(this System.CommandLine.CommandLineConfiguration builder, System.Func<System.String[],Microsoft.Extensions.Hosting.IHostBuilder> hostBuilderFactory, System.Action<Microsoft.Extensions.Hosting.IHostBuilder> configureHost = null)
1212
public static Microsoft.Extensions.Hosting.IHostBuilder UseInvocationLifetime(this Microsoft.Extensions.Hosting.IHostBuilder host, System.Action<InvocationLifetimeOptions> configureOptions = null)

src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.System_CommandLine_NamingConventionBinder_api_is_not_changed.approved.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,16 @@ System.CommandLine.NamingConventionBinder
109109
public System.Boolean EnforceExplicitBinding { get; set; }
110110
public ModelDescriptor ModelDescriptor { get; }
111111
public System.CommandLine.Binding.IValueDescriptor ValueDescriptor { get; }
112-
public System.Void BindMemberFromValue(System.Reflection.PropertyInfo property, System.CommandLine.Symbol symbol)
112+
public System.Void BindMemberFromValue(System.Reflection.PropertyInfo property, System.CommandLine.CliSymbol symbol)
113113
public System.Object CreateInstance(System.CommandLine.Binding.BindingContext bindingContext)
114114
public System.Void UpdateInstance<T>(T instance, System.CommandLine.Binding.BindingContext bindingContext)
115115
public class ModelBinder<TModel> : ModelBinder
116116
.ctor()
117-
public System.Void BindMemberFromValue<TValue>(Expression<Func<TModel,TValue>> property, System.CommandLine.Symbol symbol)
117+
public System.Void BindMemberFromValue<TValue>(Expression<Func<TModel,TValue>> property, System.CommandLine.CliSymbol symbol)
118118
public System.Void BindMemberFromValue<TValue>(Expression<Func<TModel,TValue>> property, Func<System.CommandLine.Binding.BindingContext,TValue> getValue)
119119
public class ModelBindingCommandHandler : BindingHandler
120-
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.Argument argument)
121-
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.Option option)
120+
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.CliArgument argument)
121+
public System.Void BindParameter(System.Reflection.ParameterInfo param, System.CommandLine.CliOption option)
122122
public System.Int32 Invoke(System.CommandLine.ParseResult parseResult)
123123
public System.Threading.Tasks.Task<System.Int32> InvokeAsync(System.CommandLine.ParseResult parseResult, System.Threading.CancellationToken cancellationToken = null)
124124
public class ModelDescriptor

0 commit comments

Comments
 (0)