Skip to content

Commit 5618b2d

Browse files
Clean up files a bit (#1790)
* Remove unnecessary using statements * Simplify to new(...) * Minor Fixes
1 parent a1958c0 commit 5618b2d

File tree

76 files changed

+101
-154
lines changed

Some content is hidden

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

76 files changed

+101
-154
lines changed

src/System.CommandLine.ApiCompatibility.Tests/ApiCompatibilityApprovalTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.CommandLine.Hosting;
55
using System.CommandLine.NamingConventionBinder;
6-
using System.CommandLine.Parsing;
76
using ApprovalTests;
87
using ApprovalTests.Reporters;
98
using Xunit;

src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Directives_Suggest.cs

-1
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.CommandLine.Benchmarks.Helpers;
5-
using System.CommandLine.Invocation;
65
using System.CommandLine.Parsing;
76
using System.Threading.Tasks;
87
using BenchmarkDotNet.Attributes;

src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_NestedCommands.cs

+2-3
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.CommandLine.Parsing;
5-
using System.Linq;
65
using BenchmarkDotNet.Attributes;
76

87
namespace System.CommandLine.Benchmarks.CommandLine
@@ -40,7 +39,7 @@ private void GenerateTestNestedCommands(Command parent, int depth, int countPerL
4039
for (int i = 0; i < countPerLevel; i++)
4140
{
4241
string cmdName = $"{parent.Name}_{depth}.{i}";
43-
Command cmd = new Command(cmdName);
42+
Command cmd = new(cmdName);
4443
parent.AddCommand(cmd);
4544
GenerateTestNestedCommands(cmd, depth - 1, countPerLevel);
4645
}
@@ -73,7 +72,7 @@ public void SetupParser()
7372
}
7473

7574
[Benchmark]
76-
public Parser ParserFromNestedCommands_Ctor() => new Parser(_rootCommand);
75+
public Parser ParserFromNestedCommands_Ctor() => new(_rootCommand);
7776

7877
[Benchmark]
7978
public ParseResult Parser_Parse() => _testParser.Parse(_testSymbolsAsString);

src/System.CommandLine.Benchmarks/CommandLine/Perf_Parser_Simple.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using BenchmarkDotNet.Attributes;
2-
using System.CommandLine.Invocation;
32
using System.CommandLine.Parsing;
43
using System.Threading.Tasks;
54

@@ -25,10 +24,10 @@ public class Perf_Parser_Simple
2524

2625
private static RootCommand BuildCommand()
2726
{
28-
Option<bool> boolOption = new Option<bool>(new[] { "--bool", "-b" }, "Bool option");
29-
Option<string> stringOption = new Option<string>(new[] { "--string", "-s" }, "String option");
27+
Option<bool> boolOption = new(new[] { "--bool", "-b" }, "Bool option");
28+
Option<string> stringOption = new(new[] { "--string", "-s" }, "String option");
3029

31-
RootCommand command = new RootCommand
30+
RootCommand command = new()
3231
{
3332
boolOption,
3433
stringOption

src/System.CommandLine.Benchmarks/CommandLine/Perf_Suggestions.cs

-1
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.Linq;
76
using BenchmarkDotNet.Attributes;
87
using BenchmarkDotNet.Engines;

src/System.CommandLine.Benchmarks/DragonFruit/Perf_CommandLine_EntryPoint.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace System.CommandLine.Benchmarks.DragonFruit
2020
[InvocationCount(3000)]
2121
public class Perf_CommandLine_EntryPoint
2222
{
23-
private readonly NullConsole _nullConsole = new NullConsole();
23+
private readonly NullConsole _nullConsole = new();
2424
private Assembly _testAssembly;
2525
private string _testAssemblyFilePath;
2626
private string _testAssemblyXmlDocsFilePath;

src/System.CommandLine.Benchmarks/DragonFruit/Perf_CommandLine_Help.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace System.CommandLine.Benchmarks.DragonFruit
1717
[InvocationCount(3000)]
1818
public class Perf_CommandLine_Help
1919
{
20-
private readonly NullConsole _nullConsole = new NullConsole();
20+
private readonly NullConsole _nullConsole = new();
2121
private Assembly _testAssembly;
2222
private string _testAssemblyFilePath;
2323
private string _testAssemblyXmlDocsFilePath;

src/System.CommandLine.Benchmarks/Helpers/NullConsole.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace System.CommandLine.Benchmarks.Helpers
77
{
88
class NullConsole : IConsole
99
{
10-
readonly NullStreamWriter _nullWriter = new NullStreamWriter();
10+
readonly NullStreamWriter _nullWriter = new();
1111

1212
public IStandardStreamWriter Out => _nullWriter;
1313
public IStandardStreamWriter Error => _nullWriter;

src/System.CommandLine.Benchmarks/Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
using System.Collections.Immutable;
5-
using System.IO;
64
using BenchmarkDotNet.Running;
75
using System.Linq;
86
using BenchmarkDotNet.Configs;
7+
using System.Collections.Immutable;
8+
using System.IO;
99

1010
namespace System.CommandLine.Benchmarks
1111
{

src/System.CommandLine.DragonFruit.Tests/CommandLineTests.cs

-1
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.CommandLine.Rendering;
5-
using System.ComponentModel;
65
using System.Threading.Tasks;
76
using FluentAssertions;
87
using Xunit;

src/System.CommandLine.DragonFruit.Tests/ConfigureFromMethodTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace System.CommandLine.DragonFruit.Tests
2020
public class ConfigureFromMethodTests
2121
{
2222
private object[] _receivedValues;
23-
private readonly TestConsole _testConsole = new TestConsole();
23+
private readonly TestConsole _testConsole = new();
2424

2525
[Fact]
2626
public async Task Generated_boolean_parameters_will_accept_zero_arguments()

src/System.CommandLine.DragonFruit.Tests/XmlDocReaderTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.IO;
55
using FluentAssertions;
6-
using System.Linq;
76
using Xunit;
87

98
namespace System.CommandLine.DragonFruit.Tests

src/System.CommandLine.Generator.Tests/GeneratedCommandHandlerTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.CommandLine.Help;
66
using System.CommandLine.Invocation;
77
using System.CommandLine.IO;
8-
using System.CommandLine.Parsing;
98
using System.Threading.Tasks;
109
using FluentAssertions;
1110
using Xunit;

src/System.CommandLine.Hosting.Tests/HostingHandlerTest.cs

-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
using System.CommandLine;
2-
using System.CommandLine.Binding;
32
using System.CommandLine.Invocation;
4-
using System.CommandLine.IO;
53
using System.CommandLine.Parsing;
6-
using System.Linq;
74
using System.Threading.Tasks;
85
using FluentAssertions;
9-
10-
using Microsoft.Extensions.Configuration;
116
using Microsoft.Extensions.DependencyInjection;
127
using Microsoft.Extensions.Hosting;
13-
using Microsoft.Extensions.Options;
148
using Xunit;
159

1610

src/System.CommandLine.Hosting/DirectiveConfigurationExtensions.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Collections.Generic;
2-
using System.CommandLine.Parsing;
32
using System.Linq;
43

54
using Microsoft.Extensions.Configuration;

src/System.CommandLine.NamingConventionBinder.Tests/HandlerDescriptorTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
using System.CommandLine.Binding;
54
using System.CommandLine.Tests.Utility;
65
using System.IO;
76
using System.Linq;

src/System.CommandLine.NamingConventionBinder.Tests/ModelDescriptorTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
using System.CommandLine.Binding;
54
using System.CommandLine.Tests.Binding;
65
using System.CommandLine.Tests.Utility;
76
using System.Linq;

src/System.CommandLine.NamingConventionBinder.Tests/ParameterDescriptorTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
using System.CommandLine.Binding;
54
using System.CommandLine.Tests.Binding;
65
using System.Linq;
76
using FluentAssertions;

src/System.CommandLine.NamingConventionBinder.Tests/PropertyDescriptorTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
using System.CommandLine.Binding;
54
using System.CommandLine.Tests.Binding;
65
using System.Linq;
76
using FluentAssertions;

src/System.CommandLine.NamingConventionBinder/ConstructorDescriptor.cs

-1
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.Binding;
65
using System.Linq;
76
using System.Reflection;
87

src/System.CommandLine.NamingConventionBinder/DelegateHandlerDescriptor.cs

-1
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.Binding;
65
using System.Linq;
76

87
namespace System.CommandLine.NamingConventionBinder;

src/System.CommandLine.NamingConventionBinder/HandlerDescriptor.cs

-1
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.Binding;
65
using System.Reflection;
76

87
namespace System.CommandLine.NamingConventionBinder;

src/System.CommandLine.NamingConventionBinder/IMethodDescriptor.cs

-1
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.Binding;
65

76
namespace System.CommandLine.NamingConventionBinder;
87

src/System.CommandLine.NamingConventionBinder/MethodInfoHandlerDescriptor.cs

-1
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.Binding;
65
using System.Linq;
76
using System.Reflection;
87

src/System.CommandLine.Rendering.Tests/ConsoleRendererTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace System.CommandLine.Rendering.Tests
1717
{
1818
public class ConsoleRendererTests
1919
{
20-
private readonly TestTerminal _terminal = new TestTerminal();
20+
private readonly TestTerminal _terminal = new();
2121

2222
private readonly ITestOutputHelper _output;
2323

src/System.CommandLine.Rendering.Tests/ContainerSpanTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
using System.IO;
54
using FluentAssertions;
65
using Xunit;
76

src/System.CommandLine.Rendering.Tests/RenderingTestCase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace System.CommandLine.Rendering.Tests
55
{
66
public class RenderingTestCase
77
{
8-
private static readonly TextSpanFormatter _formatter = new TextSpanFormatter();
8+
private static readonly TextSpanFormatter _formatter = new();
99

1010
public RenderingTestCase(
1111
string name,

src/System.CommandLine.Rendering.Tests/TableRenderingTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void Column_widths_are_aligned_to_the_longest_cell_in_file_mode()
118118
.Be(lines[2].IndexOf("an option"));
119119
}
120120

121-
private TextRendered Cell(string text, int left, int top) => new TextRendered(text, new Point(left, top));
121+
private TextRendered Cell(string text, int left, int top) => new(text, new Point(left, top));
122122
}
123123

124124
public class OptionsHelpView : TableView<Option>

src/System.CommandLine.Rendering.Tests/TerminalModeTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
using System.CommandLine.Invocation;
54
using System.CommandLine.IO;
65
using System.CommandLine.Parsing;
76
using System.CommandLine.Tests.Utility;

src/System.CommandLine.Rendering.Tests/TestTerminalTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace System.CommandLine.Rendering.Tests
1111
{
1212
public class TestTerminalTests : TerminalTests
1313
{
14-
protected TestTerminal _terminal = new TestTerminal();
14+
protected TestTerminal _terminal = new();
1515

1616
protected override ITerminal GetTerminal() => _terminal;
1717

src/System.CommandLine.Rendering.Tests/TextStyleRenderingTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ namespace System.CommandLine.Rendering.Tests
1111
{
1212
public class TextStyleRenderingTests
1313
{
14-
private readonly TextSpanFormatter _textSpanFormatter = new TextSpanFormatter();
15-
private readonly TestTerminal _terminal = new TestTerminal();
14+
private readonly TextSpanFormatter _textSpanFormatter = new();
15+
private readonly TestTerminal _terminal = new();
1616

1717
[Fact]
1818
public void BackgroundColorSpans_are_replaced_with_ANSI_codes_during_ANSI_rendering()

src/System.CommandLine.Rendering.Tests/Views/ScreenViewTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void BeforeRenderAction()
161161

162162
private class TestSynchronizationContext : SynchronizationContext
163163
{
164-
private readonly List<Action> _postActions = new List<Action>();
164+
private readonly List<Action> _postActions = new();
165165
public void InvokePostCallbacks()
166166
{
167167
while (_postActions.FirstOrDefault() is Action postAction)

src/System.CommandLine.Rendering.Tests/WordWrappingTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace System.CommandLine.Rendering.Tests
1111
{
1212
public class WordWrappingTests
1313
{
14-
private readonly TestTerminal _terminal = new TestTerminal();
14+
private readonly TestTerminal _terminal = new();
1515

1616
[Theory]
1717
[MemberData(nameof(TestCases))]
@@ -185,6 +185,6 @@ IEnumerable<RenderingTestCase> TestCases()
185185
}
186186

187187
private static TextRendered Line(int left, int top, string text) =>
188-
new TextRendered(text, new Point(left, top));
188+
new(text, new Point(left, top));
189189
}
190190
}

src/System.CommandLine.Rendering/AnsiRenderingSpanVisitor.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public override void VisitCursorControlSpan(CursorControlSpan cursorControlSpan)
8282
}
8383

8484
private static readonly Dictionary<string, AnsiControlCode> _foregroundColorControlCodeMappings =
85-
new Dictionary<string, AnsiControlCode>
85+
new()
8686
{
8787
[nameof(ForegroundColorSpan.Reset)] = Color.Foreground.Default,
8888
[nameof(ForegroundColorSpan.Black)] = Color.Foreground.Black,
@@ -104,7 +104,7 @@ public override void VisitCursorControlSpan(CursorControlSpan cursorControlSpan)
104104
};
105105

106106
private static readonly Dictionary<string, AnsiControlCode> _backgroundColorControlCodeMappings =
107-
new Dictionary<string, AnsiControlCode>
107+
new()
108108
{
109109
[nameof(BackgroundColorSpan.Reset)] = Color.Background.Default,
110110
[nameof(BackgroundColorSpan.Black)] = Color.Background.Black,
@@ -126,7 +126,7 @@ public override void VisitCursorControlSpan(CursorControlSpan cursorControlSpan)
126126
};
127127

128128
private static readonly Dictionary<string, AnsiControlCode> _styleControlCodeMappings =
129-
new Dictionary<string, AnsiControlCode>
129+
new()
130130
{
131131
[nameof(StyleSpan.AttributesOff)] = Ansi.Text.AttributesOff,
132132
[nameof(StyleSpan.BlinkOff)] = Ansi.Text.BlinkOff,

0 commit comments

Comments
 (0)