Skip to content

Commit 833e9c2

Browse files
committed
style: run dotnet-format
1 parent 1ef731a commit 833e9c2

17 files changed

+40
-36
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dotnet_sort_system_directives_first = true
2525
# Stuff that is usually best
2626
csharp_style_inlined_variable_declaration = true
2727
csharp_style_var_elsewhere = true
28-
csharp_space_after_cast = true
28+
csharp_space_after_cast = false
2929
csharp_style_pattern_matching_over_as_with_null_check = true
3030
csharp_style_pattern_matching_over_is_with_cast_check = true
3131
csharp_style_var_for_built_in_types = true

src/CommandLineUtils/Conventions/ConstructorInjectionConvention.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private void ApplyImpl<TModel>(ConventionContext context)
6262

6363
if (factory != null)
6464
{
65-
((CommandLineApplication<TModel>) context.Application).ModelFactory = factory;
65+
((CommandLineApplication<TModel>)context.Application).ModelFactory = factory;
6666
}
6767
}
6868

@@ -104,11 +104,11 @@ private void ApplyImpl<TModel>(ConventionContext context)
104104
args[i] = service;
105105
if (i == parameters.Length - 1)
106106
{
107-
return () => (TModel) ctorCandidate.Invoke(args);
107+
return () => (TModel)ctorCandidate.Invoke(args);
108108
}
109109
}
110110

111-
nextCtor: ;
111+
nextCtor:;
112112
}
113113

114114
return () => throw new InvalidOperationException(Strings.NoMatchedConstructorFound(typeof(TModel)));

src/CommandLineUtils/Conventions/ExecuteMethodConvention.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private async Task<int> InvokeAsync(MethodInfo method, object instance, object[]
8080
{
8181
try
8282
{
83-
var result = (Task) method.Invoke(instance, arguments);
83+
var result = (Task)method.Invoke(instance, arguments);
8484
if (result is Task<int> intResult)
8585
{
8686
return await intResult;
@@ -103,7 +103,7 @@ private int Invoke(MethodInfo method, object instance, object[] arguments)
103103
var result = method.Invoke(instance, arguments);
104104
if (method.ReturnType == typeof(int))
105105
{
106-
return (int) result;
106+
return (int)result;
107107
}
108108
}
109109
catch (TargetInvocationException e)

src/CommandLineUtils/Internal/AnsiConsole.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void WriteLine(string message)
6262
}
6363

6464
var escapeScan = 0;
65-
for (; ;)
65+
for (; ; )
6666
{
6767
var escapeIndex = message.IndexOf("\x1b[", escapeScan);
6868
if (escapeIndex == -1)

src/CommandLineUtils/Internal/CommandLineProcessor.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,12 @@ public CommandOrParameterArgument(string raw) : base(raw)
399399

400400
private class OptionArgument : Argument
401401
{
402+
private static readonly char[] NameValueSeparators = { ':', '=' };
403+
402404
public OptionArgument(string raw, bool isShortOption) : base(raw)
403405
{
404406
IsShortOption = isShortOption;
405-
var parts = Raw.Split(new[] { ':', '=' }, 2);
407+
var parts = Raw.Split(NameValueSeparators, 2);
406408
if (parts.Length > 1)
407409
{
408410
Value = parts[1];
@@ -414,8 +416,8 @@ public OptionArgument(string raw, bool isShortOption) : base(raw)
414416
Name = parts[0].Substring(sublen);
415417
}
416418

417-
public string Name { get; set; }
418-
public string? Value { get; set; }
419+
public string Name { get; }
420+
public string? Value { get; }
419421
public bool IsShortOption { get; }
420422
}
421423

src/CommandLineUtils/Internal/StringDistance.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ internal static double NormalizeDistance(int distance, int length)
123123
return 1;
124124
}
125125

126-
return 1.0d - distance / (double) length;
126+
return 1.0d - distance / (double)length;
127127
}
128128

129129
/// <summary>

src/CommandLineUtils/Internal/ValueParsers/StockValueParsers.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,23 @@ private static IValueParser<T> FloatingPointParser<T>(NumberParser<T> parser) =>
5858
(argName, value) => InvalidValueException(argName, $"'{value}' is not a valid floating-point number."));
5959

6060
public static readonly IValueParser<double> Double = FloatingPointParser<double>(double.TryParse);
61-
public static readonly IValueParser<float> Float = FloatingPointParser<float> (float.TryParse );
61+
public static readonly IValueParser<float> Float = FloatingPointParser<float>(float.TryParse);
6262

6363
private static IValueParser<T> IntegerParser<T>(NumberParser<T> parser) =>
6464
Create(parser, NumberStyles.Integer, (argName, value) => InvalidValueException(argName, $"'{value}' is not a valid number."));
6565

6666
public static readonly IValueParser<short> Int16 = IntegerParser<short>(short.TryParse);
67-
public static readonly IValueParser<int> Int32 = IntegerParser<int> (int.TryParse );
68-
public static readonly IValueParser<long> Int64 = IntegerParser<long> (long.TryParse );
67+
public static readonly IValueParser<int> Int32 = IntegerParser<int>(int.TryParse);
68+
public static readonly IValueParser<long> Int64 = IntegerParser<long>(long.TryParse);
6969

7070
private static IValueParser<T> NonNegativeIntegerParser<T>(NumberParser<T> parser) =>
7171
Create(parser, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite,
7272
(argName, value) => InvalidValueException(argName, $"'{value}' is not a valid, non-negative number."));
7373

74-
public static readonly IValueParser<byte> Byte = NonNegativeIntegerParser<byte> (byte.TryParse );
74+
public static readonly IValueParser<byte> Byte = NonNegativeIntegerParser<byte>(byte.TryParse);
7575
public static readonly IValueParser<ushort> UInt16 = NonNegativeIntegerParser<ushort>(ushort.TryParse);
76-
public static readonly IValueParser<uint> UInt32 = NonNegativeIntegerParser<uint> (uint.TryParse );
77-
public static readonly IValueParser<ulong> UInt64 = NonNegativeIntegerParser<ulong> (ulong.TryParse );
76+
public static readonly IValueParser<uint> UInt32 = NonNegativeIntegerParser<uint>(uint.TryParse);
77+
public static readonly IValueParser<ulong> UInt64 = NonNegativeIntegerParser<ulong>(ulong.TryParse);
7878

7979
private delegate bool DateTimeParser<T>(string s, IFormatProvider provider, DateTimeStyles styles, out T result);
8080

src/CommandLineUtils/Utilities/ArgumentEscaper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,6 @@ private static bool IsSurroundedWithQuotes(string argument)
9393
}
9494

9595
private static bool ContainsWhitespace(string argument)
96-
=> argument.IndexOfAny(new [] { ' ', '\t', '\n' }) >= 0;
96+
=> argument.IndexOfAny(new[] { ' ', '\t', '\n' }) >= 0;
9797
}
9898
}

test/CommandLineUtils.Tests/CommandLineApplicationTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public void CommandNameCanBeMatched()
4444
public void CommandsNamesAreCaseInsensitive()
4545
{
4646
var app = new CommandLineApplication();
47-
var cmd = app.Command("TEST", c => {
47+
var cmd = app.Command("TEST", c =>
48+
{
4849
c.OnExecute(() => 5);
4950
});
5051
cmd.AddName("TE");
@@ -106,10 +107,10 @@ public void ItThrowsIfAnotherSubcommandHasNameName()
106107
c.AddName("s");
107108
});
108109

109-
var ex = Assert.Throws<InvalidOperationException>(() => app.Command("sub1", _ => {}));
110+
var ex = Assert.Throws<InvalidOperationException>(() => app.Command("sub1", _ => { }));
110111
Assert.Equal(Strings.DuplicateSubcommandName("sub1"), ex.Message);
111112

112-
ex = Assert.Throws<InvalidOperationException>(() => app.Command("s", _ => {}));
113+
ex = Assert.Throws<InvalidOperationException>(() => app.Command("s", _ => { }));
113114
Assert.Equal(Strings.DuplicateSubcommandName("s"), ex.Message);
114115
}
115116

@@ -947,7 +948,7 @@ public void LongOptionsCanBeCaseInsensitive()
947948
public void CommandNamesMatchingIsCaseInsensitive()
948949
{
949950
var app = new CommandLineApplication(throwOnUnexpectedArg: false);
950-
var cmd = app.Command("CMD1", _ => {});
951+
var cmd = app.Command("CMD1", _ => { });
951952

952953
Assert.Same(cmd, app.Parse("CMD1").SelectedCommand);
953954
Assert.Same(cmd, app.Parse("cmd1").SelectedCommand);

test/CommandLineUtils.Tests/CommandNameFromTypeConventionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public void ItInfersCommandName(string typeName, string commandName)
1919

2020
[Subcommand(typeof(AddCommand))]
2121
private class Program
22-
{}
22+
{ }
2323

2424
private class AddCommand
25-
{}
25+
{ }
2626

2727
[Fact]
2828
public void ItInfersSubcommandNameFromTypeName()

0 commit comments

Comments
 (0)