Skip to content

Commit 82e8198

Browse files
authored
More XML docs and cleanup (#1348)
* wip * XML comments and cleanup
1 parent bc91166 commit 82e8198

23 files changed

+64
-70
lines changed

src/System.CommandLine/Binding/ArgumentConversionResult.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ private protected ArgumentConversionResult(IArgument argument)
1414

1515
internal string? ErrorMessage { get; set; }
1616

17-
internal static FailedArgumentConversionResult Failure(IArgument argument, string error) => new FailedArgumentConversionResult(argument, error);
17+
internal static FailedArgumentConversionResult Failure(IArgument argument, string error) => new(argument, error);
1818

19-
public static SuccessfulArgumentConversionResult Success(IArgument argument, object? value) => new SuccessfulArgumentConversionResult(argument, value);
19+
public static SuccessfulArgumentConversionResult Success(IArgument argument, object? value) => new(argument, value);
2020

21-
internal static NoArgumentConversionResult None(IArgument argument) => new NoArgumentConversionResult(argument);
21+
internal static NoArgumentConversionResult None(IArgument argument) => new(argument);
2222
}
2323
}

src/System.CommandLine/Binding/ArgumentConversionResultSet.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/System.CommandLine/Binding/Binder.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,18 @@ internal static bool CanBeBoundFromScalarValue(this Type type)
6868
{
6969
return type.GetGenericTypeDefinition() switch
7070
{
71-
Type enumerable when enumerable == typeof(IEnumerable<>) => GetEmptyEnumerable(itemType),
72-
Type list when list == typeof(List<>) => GetEmptyList(itemType),
73-
Type array when array == typeof(IList<>) ||
74-
array == typeof(ICollection<>) => CreateEmptyArray(itemType),
71+
{ } enumerable when enumerable == typeof(IEnumerable<>) => GetEmptyEnumerable(itemType),
72+
{ } list when list == typeof(List<>) => GetEmptyList(itemType),
73+
{ } array when array == typeof(IList<>) ||
74+
array == typeof(ICollection<>) => CreateEmptyArray(itemType),
7575
_ => null
7676
};
7777
}
7878
}
7979

8080
return type switch
8181
{
82-
Type nonGeneric
82+
{ } nonGeneric
8383
when nonGeneric == typeof(IList) ||
8484
nonGeneric == typeof(ICollection) ||
8585
nonGeneric == typeof(IEnumerable)

src/System.CommandLine/Binding/ConstructorDescriptor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ internal object Invoke(IReadOnlyCollection<object?> parameters)
3232
return _constructorInfo.Invoke(parameters.ToArray());
3333
}
3434

35+
/// <inheritdoc />
3536
public override string ToString() =>
3637
$"{Parent} ({string.Join(", ", ParameterDescriptors)})";
3738
}

src/System.CommandLine/Binding/HandlerDescriptor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public abstract class HandlerDescriptor : IMethodDescriptor
2121

2222
protected abstract IEnumerable<ParameterDescriptor> InitializeParameterDescriptors();
2323

24+
/// <inheritdoc />
2425
public override string ToString() =>
2526
$"{Parent} ({string.Join(", ", ParameterDescriptors)})";
2627

src/System.CommandLine/Binding/ModelBinder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ internal ModelBinder(IValueDescriptor valueDescriptor)
2424
public bool EnforceExplicitBinding { get; set; }
2525

2626
internal Dictionary<IValueDescriptor, IValueSource> ConstructorArgumentBindingSources { get; } =
27-
new Dictionary<IValueDescriptor, IValueSource>();
27+
new();
2828

2929
internal Dictionary<IValueDescriptor, IValueSource> MemberBindingSources { get; } =
30-
new Dictionary<IValueDescriptor, IValueSource>();
30+
new();
3131

3232
// Consider deprecating in favor or BindingConfiguration/BindingContext attach validatation. Then make internal.
3333
// Or at least rename to "ConfigureBinding" or similar
@@ -133,7 +133,7 @@ private bool ShortCutTheBinding()
133133
{
134134
return (false, null, false);
135135
}
136-
if (!(newInstance is null))
136+
if (newInstance is not null)
137137
{
138138
nonDefaultsUsed = UpdateInstanceInternalNotifyIfNonDefaultsUsed(newInstance, bindingContext);
139139
}
@@ -333,7 +333,7 @@ protected IValueDescriptor FindModelPropertyDescriptor(Type propertyType, string
333333

334334
private ConstructorInfo FindConstructorOrThrow(ParameterInfo parameter, string message)
335335
{
336-
if (!(parameter.Member is ConstructorInfo constructor))
336+
if (parameter.Member is not ConstructorInfo constructor)
337337
{
338338
throw new ArgumentException(paramName: nameof(parameter),
339339
message: message);

src/System.CommandLine/Binding/ModelDescriptor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class ModelDescriptor
1515
| BindingFlags.Public
1616
| BindingFlags.Instance;
1717

18-
private static readonly ConcurrentDictionary<Type, ModelDescriptor> _modelDescriptors = new ConcurrentDictionary<Type, ModelDescriptor>();
18+
private static readonly ConcurrentDictionary<Type, ModelDescriptor> _modelDescriptors = new();
1919

2020
private List<PropertyDescriptor>? _propertyDescriptors;
2121
private List<ConstructorDescriptor>? _constructorDescriptors;
@@ -41,6 +41,7 @@ protected ModelDescriptor(Type modelType)
4141

4242
public Type ModelType { get; }
4343

44+
/// <inheritdoc />
4445
public override string ToString() => $"{ModelType.Name}";
4546

4647
public static ModelDescriptor FromType<T>() =>

src/System.CommandLine/Binding/PropertyDescriptor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public void SetValue(object? instance, object? value)
3434
_propertyInfo.SetValue(instance, value);
3535
}
3636

37+
/// <inheritdoc />
3738
public override string ToString() => $"{ValueType.Name} {Path}";
3839
}
3940
}

src/System.CommandLine/Binding/SpecificSymbolValueSource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public bool TryGetValue(IValueDescriptor valueDescriptor,
2323
{
2424
case IOption option:
2525
var optionResult = bindingContext?.ParseResult.FindResultFor(option);
26-
if (!(optionResult is null))
26+
if (optionResult is not null)
2727
{
2828
boundValue = optionResult.GetValueOrDefault();
2929
return true;
3030
}
3131
break;
3232
case IArgument argument:
3333
var argumentResult = bindingContext?.ParseResult.FindResultFor(argument);
34-
if (!(argumentResult is null))
34+
if (argumentResult is not null)
3535
{
3636
boundValue = argumentResult.GetValueOrDefault();
3737
return true;

src/System.CommandLine/Builder/CommandLineBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace System.CommandLine.Builder
1212
{
1313
public class CommandLineBuilder : CommandBuilder
1414
{
15-
private readonly List<(InvocationMiddleware middleware, int order)> _middlewareList = new List<(InvocationMiddleware middleware, int order)>();
15+
private readonly List<(InvocationMiddleware middleware, int order)> _middlewareList = new();
1616

1717
public CommandLineBuilder(Command? rootCommand = null)
1818
: base(rootCommand ?? new RootCommand())

0 commit comments

Comments
 (0)