Skip to content

Commit caa4457

Browse files
Code cleanup
1 parent a8eab7e commit caa4457

File tree

96 files changed

+148
-210
lines changed

Some content is hidden

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

96 files changed

+148
-210
lines changed

Build/Tools.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,9 @@ private static string GetNextRelease(SemanticVersion curVersion, string release)
3333
return release;
3434
}
3535

36-
if (int.TryParse(string.Concat(curVersion.Release.Where(char.IsNumber)), out var num))
37-
{
38-
return $"{string.Concat(curVersion.Release.Where(i => !char.IsNumber(i)))}{num + 1}";
39-
}
40-
41-
return release;
36+
return int.TryParse(string.Concat(curVersion.Release.Where(char.IsNumber)), out var num)
37+
? $"{string.Concat(curVersion.Release.Where(i => !char.IsNumber(i)))}{num + 1}"
38+
: release;
4239
}
4340

4441
public static string GetProperty(string name, string defaultProp, bool showWarning = false)

CSharpInteractive.HostApi/Internal/HostComponents.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// ReSharper disable ClassNeverInstantiated.Global
22
namespace HostApi.Internal;
33

4-
using HostApi.Internal.Cmd;
5-
using HostApi.Internal.Docker;
6-
using HostApi.Internal.DotNet;
4+
using Cmd;
5+
using Docker;
6+
using DotNet;
77

88
internal record HostComponents(
99
// Settings

CSharpInteractive.Tests/AddNuGetReferenceCommandFactoryTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ namespace CSharpInteractive.Tests;
22

33
using System.Diagnostics.CodeAnalysis;
44
using Core;
5-
using CSharpInteractive;
65
using NuGet.Versioning;
76

87
[SuppressMessage("Usage", "xUnit1042:The member referenced by the MemberData attribute returns untyped data rows")]

CSharpInteractive.Tests/AddNuGetReferenceCommandRunnerTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace CSharpInteractive.Tests;
22

33
using Core;
4-
using CSharpInteractive;
54
using NuGet.Versioning;
65

76
public class AddNuGetReferenceCommandRunnerTests
@@ -56,7 +55,7 @@ public void ShouldRegisterAssemblies()
5655
{
5756
// Given
5857
var runner = CreateInstance();
59-
IReadOnlyCollection<ReferencingAssembly> assemblies = new []{_referencingAssembly1, _referencingAssembly2};
58+
IReadOnlyCollection<ReferencingAssembly> assemblies = [_referencingAssembly1, _referencingAssembly2];
6059
_nuGetReferenceResolver.Setup(i => i.TryResolveAssemblies(_command.PackageId, _command.VersionRange, out assemblies)).Returns(true);
6160
var description = string.Empty;
6261
_referenceRegistry.Setup(i => i.TryRegisterAssembly(_referencingAssembly1.FilePath, out description)).Returns(true);
@@ -74,7 +73,7 @@ public void ShouldReturnFailWhenSomeAssemblyWasNotRegistered()
7473
{
7574
// Given
7675
var runner = CreateInstance();
77-
IReadOnlyCollection<ReferencingAssembly> assemblies = new []{_referencingAssembly1, _referencingAssembly2};
76+
IReadOnlyCollection<ReferencingAssembly> assemblies = [_referencingAssembly1, _referencingAssembly2];
7877
_nuGetReferenceResolver.Setup(i => i.TryResolveAssemblies(_command.PackageId, _command.VersionRange, out assemblies)).Returns(true);
7978
var description = string.Empty;
8079
_referenceRegistry.Setup(i => i.TryRegisterAssembly(_referencingAssembly1.FilePath, out description)).Returns(true);

CSharpInteractive.Tests/AssembliesScriptOptionsProviderTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ namespace CSharpInteractive.Tests;
44
using System.Diagnostics.CodeAnalysis;
55
using System.Reflection;
66
using Core;
7-
using CSharpInteractive;
87
using Microsoft.CodeAnalysis.Scripting;
98
using Microsoft.Extensions.DependencyInjection;
109

@@ -20,7 +19,7 @@ public void ShouldAddReferencesForAssembliesWithLocation()
2019
var assembly1 = new Mock<Assembly>();
2120
var assembly2 = new Mock<Assembly>();
2221
assembly2.SetupGet(i => i.Location).Returns(Assembly.GetCallingAssembly().Location);
23-
_assembliesProvider.Setup(i => i.GetAssemblies(It.IsAny<IEnumerable<Type>>())).Returns(new[] {assembly1.Object, assembly2.Object});
22+
_assembliesProvider.Setup(i => i.GetAssemblies(It.IsAny<IEnumerable<Type>>())).Returns([assembly1.Object, assembly2.Object]);
2423
var provider = CreateInstance();
2524

2625
// When

CSharpInteractive.Tests/BuildContextTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void ShouldProcessStdOutput()
2222
var buildResult = result.Create(_commandLineResult.Object);
2323

2424
// Then
25-
messages.ShouldBe(new[] {msg});
25+
messages.ShouldBe([msg]);
2626
buildResult.Errors.ShouldNotContain(msg);
2727
}
2828

@@ -39,7 +39,7 @@ public void ShouldProcessErrOutput()
3939
var buildResult = result.Create(_commandLineResult.Object);
4040

4141
// Then
42-
messages.ShouldBe(new[] { msg });
42+
messages.ShouldBe([msg]);
4343
buildResult.Errors.ShouldContain(msg);
4444
}
4545

@@ -96,7 +96,7 @@ public void ShouldProcessTestFinished()
9696
test.State.ShouldBe(TestState.Finished);
9797
test.Message.ShouldBeEmpty();
9898
test.Details.ShouldBeEmpty();
99-
test.Output.ShouldBe(new[] {stdOutput, errOutput});
99+
test.Output.ShouldBe([stdOutput, errOutput]);
100100
test.ExecutorUri.ShouldBe(new Uri("executor://mstestadapter/v2", UriKind.RelativeOrAbsolute));
101101
test.LineNumber.ShouldBe(23);
102102
}
@@ -144,7 +144,7 @@ public void ShouldProcessTestFailed()
144144
test.State.ShouldBe(TestState.Failed);
145145
test.Message.ShouldBe("Some message");
146146
test.Details.ShouldBe("Error details");
147-
test.Output.ShouldBe(new[] {new Output(_startInfo.Object, false, "Some output", 11)});
147+
test.Output.ShouldBe([new Output(_startInfo.Object, false, "Some output", 11)]);
148148
}
149149

150150
[Fact]
@@ -187,7 +187,7 @@ public void ShouldProcessTestIgnored()
187187
test.State.ShouldBe(TestState.Ignored);
188188
test.Message.ShouldBe("Some message");
189189
test.Details.ShouldBeEmpty();
190-
test.Output.ShouldBe(new[] {new Output(_startInfo.Object, false, "Some output", 11)});
190+
test.Output.ShouldBe([new Output(_startInfo.Object, false, "Some output", 11)]);
191191
}
192192

193193
[Theory]
@@ -243,7 +243,7 @@ public void ShouldProcessMessage(string status, BuildMessageState state)
243243
DotNetMessageImportance.High);
244244

245245
// When
246-
result.ProcessMessage(output, message).ShouldBe(new[] {buildMessage});
246+
result.ProcessMessage(output, message).ShouldBe([buildMessage]);
247247
var buildResult = result.Create(_commandLineResult.Object);
248248

249249
// Then
@@ -258,13 +258,13 @@ public void ShouldProcessMessage(string status, BuildMessageState state)
258258
break;
259259

260260
case BuildMessageState.Warning:
261-
buildResult.Warnings.ShouldBe(new[] {buildMessage});
261+
buildResult.Warnings.ShouldBe([buildMessage]);
262262
break;
263263

264264
case BuildMessageState.Failure:
265265
case BuildMessageState.StdError:
266266
case BuildMessageState.BuildProblem:
267-
buildResult.Errors.ShouldBe(new[] {buildMessage});
267+
buildResult.Errors.ShouldBe([buildMessage]);
268268
break;
269269
}
270270
}
@@ -309,12 +309,12 @@ public void ShouldBuildProblem()
309309
DotNetMessageImportance.High);
310310

311311
// When
312-
result.ProcessMessage(output, buildProblem).ShouldBe(new[] {buildMessage});
312+
result.ProcessMessage(output, buildProblem).ShouldBe([buildMessage]);
313313
var buildResult = result.Create(_commandLineResult.Object);
314314

315315
// Then
316316
buildResult.Tests.Count.ShouldBe(0);
317-
buildResult.Errors.ShouldBe(new[] {buildMessage});
317+
buildResult.Errors.ShouldBe([buildMessage]);
318318
}
319319

320320
private static BuildContext CreateInstance() => new();

CSharpInteractive.Tests/BuildOutputProcessorTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public void ShouldConvertMessages()
2121
BuildMessage buildMsg1 = new(output, BuildMessageState.StdOut);
2222
BuildMessage buildMsg2 = new(output, BuildMessageState.StdOut);
2323
BuildMessage buildMsg3 = new(output, BuildMessageState.StdOut);
24-
_serviceMessageParser.Setup(i => i.ParseServiceMessages("Messages")).Returns(new[] {msg1.Object, msg2.Object});
25-
_buildResult.Setup(i => i.ProcessMessage(output, msg1.Object)).Returns(new[] {buildMsg1, buildMsg2});
26-
_buildResult.Setup(i => i.ProcessMessage(output, msg2.Object)).Returns(new[] {buildMsg3});
24+
_serviceMessageParser.Setup(i => i.ParseServiceMessages("Messages")).Returns([msg1.Object, msg2.Object]);
25+
_buildResult.Setup(i => i.ProcessMessage(output, msg1.Object)).Returns([buildMsg1, buildMsg2]);
26+
_buildResult.Setup(i => i.ProcessMessage(output, msg2.Object)).Returns([buildMsg3]);
2727
var processor = CreateInstance();
2828

2929
// When
@@ -50,7 +50,7 @@ public void ShouldConvertWhenHasNoServiceMessages(bool isError)
5050
_serviceMessageParser.Setup(i => i.ParseServiceMessages("some output")).Returns([]);
5151
_buildResult.Setup(i => i.ProcessMessage(output, It.IsAny<IServiceMessage>())).Returns(Array.Empty<BuildMessage>());
5252
BuildMessage buildMsg = new(output, BuildMessageState.StdOut);
53-
_buildResult.Setup(i => i.ProcessOutput(output)).Returns(new[] {buildMsg});
53+
_buildResult.Setup(i => i.ProcessOutput(output)).Returns([buildMsg]);
5454
var processor = CreateInstance();
5555

5656
// When

CSharpInteractive.Tests/BuildResultTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class BuildResultTests
1919
public void ShouldSupportToString(int errors, int warnings, int failedTests, int ignoredTests, int passedTests, string expected)
2020
{
2121
// Given
22-
var result = new BuildResult(_commandLineResult.Object) with
22+
var result = new BuildResult(_commandLineResult.Object)
2323
{
2424
Errors = Enumerable.Repeat(new BuildMessage(Output, BuildMessageState.StdError), errors).ToArray(),
2525
Warnings = Enumerable.Repeat(new BuildMessage(Output, BuildMessageState.Warning), warnings).ToArray(),

CSharpInteractive.Tests/CISettingsTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
namespace CSharpInteractive.Tests;
33

44
using Core;
5-
using CSharpInteractive;
65

76
public class CISettingsTests
87
{

CSharpInteractive.Tests/CISpecificTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
namespace CSharpInteractive.Tests;
33

44
using Core;
5-
using CSharpInteractive;
65

76
public class CISpecificTests
87
{

0 commit comments

Comments
 (0)