Skip to content

Commit dc4028f

Browse files
arturcicBi0T1N
authored andcommitted
cleanup
1 parent 10f9d4f commit dc4028f

File tree

18 files changed

+34
-108
lines changed

18 files changed

+34
-108
lines changed

src/GitVersion.App.Tests/GitVersion.App.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
<Content Include="Approved\**\*.approved.txt" />
1616
</ItemGroup>
1717
<ItemGroup>
18-
<Compile Include="..\GitVersion.Core.Tests\Helpers\DirectoryHelper.cs" Link="Helpers\DirectoryHelper.cs" />
1918
<Compile Include="..\GitVersion.Core.Tests\Helpers\ExecutableHelper.cs" Link="Helpers\ExecutableHelper.cs" />
2019
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestConsoleAdapter.cs" Link="Helpers\TestConsoleAdapter.cs" />
2120
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestEnvironment.cs" Link="Helpers\TestEnvironment.cs" />

src/GitVersion.App.Tests/Helpers/ProgramFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void WithEnv(params KeyValuePair<string, string>[] envs)
4949

5050
public Task<ExecutionResults> Run(string arg)
5151
{
52-
var args = arg.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
52+
var args = arg.Split([' '], StringSplitOptions.RemoveEmptyEntries).ToArray();
5353
return Run(args);
5454
}
5555

src/GitVersion.App/GlobbingResolver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ public IEnumerable<string> Resolve(string workingDirectory, string pattern)
1313
return this.matcher.Execute(GetDirectoryInfoWrapper(workingDirectory)).Files.Select(file => file.Path);
1414
}
1515

16-
protected virtual DirectoryInfoBase GetDirectoryInfoWrapper(string workingDirectory) => new DirectoryInfoWrapper(new DirectoryInfo(workingDirectory));
16+
private static DirectoryInfoWrapper GetDirectoryInfoWrapper(string workingDirectory)
17+
=> new(new DirectoryInfo(workingDirectory));
1718
}

src/GitVersion.BuildAgents/Agents/AzurePipelines.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public override string GenerateSetVersionMessage(GitVersionVariables variables)
3535
if (buildNumberEnv == newBuildNumber)
3636
{
3737
var buildNumber = variables.FullSemVer.EndsWith("+0")
38-
? variables.FullSemVer.Substring(0, variables.FullSemVer.Length - 2)
38+
? variables.FullSemVer[..^2]
3939
: variables.FullSemVer;
4040

4141
return $"##vso[build.updatebuildnumber]{buildNumber}";

src/GitVersion.Configuration/VersionStrategiesConverter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ internal class VersionStrategiesConverter : IYamlTypeConverter
1212

1313
public bool Accepts(Type type) => type == typeof(VersionStrategies[]);
1414

15-
public object? ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer)
15+
public object ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer)
1616
{
17-
List<VersionStrategies> strategies = new();
17+
List<VersionStrategies> strategies = [];
1818

1919
if (parser.TryConsume<SequenceStart>(out var _))
2020
{

src/GitVersion.Core.Tests/Extensions/MockCollectionExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ private static IEnumerator<T> GetEnumerator<T>(params T[] itemsToReturn)
1111
}
1212

1313
public static void MockCollectionReturn<T>(this IEnumerable<T> items, params T[] itemsToReturn)
14-
=> items.GetEnumerator().Returns(_ => GetEnumerator(itemsToReturn));
14+
{
15+
var enumerator = items.GetEnumerator();
16+
enumerator.Returns(_ => GetEnumerator(itemsToReturn));
17+
enumerator.Dispose();
18+
}
1519
}

src/GitVersion.Core.Tests/VersionCalculation/EffectiveBranchConfigurationFinderTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void When_getting_configurations_of_a_branch_with_versioning_mode_Given_f
4646
.WithBranch("develop", builder => builder.WithDeploymentMode(null).WithIncrement(IncrementStrategy.Inherit))
4747
.Build();
4848
var repositoryStoreMock = Substitute.For<IRepositoryStore>();
49-
repositoryStoreMock.GetSourceBranches(developBranchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns(new[] { mainBranchMock });
49+
repositoryStoreMock.GetSourceBranches(developBranchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns([mainBranchMock]);
5050

5151
var unitUnderTest = new EffectiveBranchConfigurationFinder(Substitute.For<ILog>(), repositoryStoreMock);
5252

@@ -75,7 +75,7 @@ public void When_getting_configurations_of_a_branch_with_versioning_mode_Given_p
7575
.Build();
7676

7777
var repositoryStoreMock = Substitute.For<IRepositoryStore>();
78-
repositoryStoreMock.GetSourceBranches(developBranchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns(new[] { mainBranchMock });
78+
repositoryStoreMock.GetSourceBranches(developBranchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns([mainBranchMock]);
7979

8080
var unitUnderTest = new EffectiveBranchConfigurationFinder(Substitute.For<ILog>(), repositoryStoreMock);
8181

@@ -109,7 +109,7 @@ public void When_getting_configurations_of_a_branch_with_tag_alpha_Given_branch_
109109
.Build();
110110

111111
var repositoryStoreMock = Substitute.For<IRepositoryStore>();
112-
repositoryStoreMock.GetSourceBranches(developBranchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns(new[] { mainBranchMock });
112+
repositoryStoreMock.GetSourceBranches(developBranchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns([mainBranchMock]);
113113

114114
var unitUnderTest = new EffectiveBranchConfigurationFinder(Substitute.For<ILog>(), repositoryStoreMock);
115115

@@ -136,7 +136,7 @@ public void When_getting_configurations_of_a_branch_without_tag_Given_branch_whi
136136
.Build();
137137

138138
var repositoryStoreMock = Substitute.For<IRepositoryStore>();
139-
repositoryStoreMock.GetSourceBranches(developBranchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns(new[] { mainBranchMock });
139+
repositoryStoreMock.GetSourceBranches(developBranchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns([mainBranchMock]);
140140

141141
var unitUnderTest = new EffectiveBranchConfigurationFinder(Substitute.For<ILog>(), repositoryStoreMock);
142142

@@ -292,7 +292,7 @@ public void When_getting_configurations_of_an_unknown_branch_Given_fallback_conf
292292
.Build();
293293
var repositoryStoreMock = Substitute.For<IRepositoryStore>();
294294
var developBranchMock = GitToolsTestingExtensions.CreateMockBranch("develop", GitToolsTestingExtensions.CreateMockCommit());
295-
repositoryStoreMock.GetSourceBranches(unknownBranchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns(new[] { developBranchMock });
295+
repositoryStoreMock.GetSourceBranches(unknownBranchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns([developBranchMock]);
296296

297297
var unitUnderTest = new EffectiveBranchConfigurationFinder(Substitute.For<ILog>(), repositoryStoreMock);
298298

@@ -325,7 +325,7 @@ public void When_getting_configurations_of_an_unknown_branch_Given_fallback_conf
325325
.Build();
326326
var repositoryStoreMock = Substitute.For<IRepositoryStore>();
327327
var developBranchMock = GitToolsTestingExtensions.CreateMockBranch("develop", GitToolsTestingExtensions.CreateMockCommit());
328-
repositoryStoreMock.GetSourceBranches(unknownBranchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns(new[] { developBranchMock });
328+
repositoryStoreMock.GetSourceBranches(unknownBranchMock, configuration, Arg.Any<HashSet<IBranch>>()).Returns([developBranchMock]);
329329

330330
var unitUnderTest = new EffectiveBranchConfigurationFinder(Substitute.For<ILog>(), repositoryStoreMock);
331331

@@ -360,7 +360,7 @@ public void When_getting_configurations_of_an_unknown_branch_Given_fallback_and_
360360
.Build();
361361
var repositoryStoreMock = Substitute.For<IRepositoryStore>();
362362
var developBranchMock = GitToolsTestingExtensions.CreateMockBranch("develop", GitToolsTestingExtensions.CreateMockCommit());
363-
repositoryStoreMock.GetSourceBranches(Arg.Any<IBranch>(), Arg.Any<GitVersionConfiguration>(), Arg.Any<HashSet<IBranch>>()).Returns(new[] { developBranchMock });
363+
repositoryStoreMock.GetSourceBranches(Arg.Any<IBranch>(), Arg.Any<GitVersionConfiguration>(), Arg.Any<HashSet<IBranch>>()).Returns([developBranchMock]);
364364

365365
var unitUnderTest = new EffectiveBranchConfigurationFinder(Substitute.For<ILog>(), repositoryStoreMock);
366366

src/GitVersion.Core.Tests/VersionCalculation/ShaVersionFilterTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class ShaVersionFilterTests : TestBase
1010
public void VerifyNullGuard()
1111
{
1212
var commit = GitToolsTestingExtensions.CreateMockCommit();
13-
var sut = new ShaVersionFilter(new[] { commit.Sha });
13+
var sut = new ShaVersionFilter([commit.Sha]);
1414

1515
Should.Throw<ArgumentNullException>(() => sut.Exclude(null!, out _));
1616
}
@@ -20,7 +20,7 @@ public void WhenShaMatchShouldExcludeWithReason()
2020
{
2121
var commit = GitToolsTestingExtensions.CreateMockCommit();
2222
BaseVersion version = new("dummy", new SemanticVersion(1), commit);
23-
var sut = new ShaVersionFilter(new[] { commit.Sha });
23+
var sut = new ShaVersionFilter([commit.Sha]);
2424

2525
sut.Exclude(version, out var reason).ShouldBeTrue();
2626
reason.ShouldNotBeNullOrWhiteSpace();

src/GitVersion.Core.Tests/Helpers/DirectoryHelper.cs renamed to src/GitVersion.Core/Helpers/DirectoryHelper.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using GitVersion.Helpers;
1+
namespace GitVersion.Helpers;
22

3-
namespace GitVersion.Core.Tests.Helpers;
4-
5-
public static class DirectoryHelper
3+
internal static class DirectoryHelper
64
{
75
private static readonly Dictionary<string, string> ToRename = new()
86
{

src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/BaseVersion.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ public override string ToString()
5555
stringBuilder.Append($"{Source}: ");
5656
stringBuilder.Append(Operator.ForceIncrement ? "Force version increment " : "Version increment ");
5757

58-
if (SemanticVersion is not null)
59-
stringBuilder.Append($"'{SemanticVersion:f}' ");
60-
58+
stringBuilder.Append($"'{SemanticVersion:f}' ");
6159
stringBuilder.Append($"+semver '{Operator.Increment}'");
6260

6361
if (Operator.Label is null)

src/GitVersion.LibGit2Sharp/Git/Remote.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public IEnumerable<IRefSpec> RefSpecs
2323
{
2424
var refSpecs = this.innerRemote.RefSpecs;
2525
return refSpecs is null
26-
? Enumerable.Empty<IRefSpec>()
26+
? []
2727
: new RefSpecCollection((LibGit2Sharp.RefSpecCollection)refSpecs);
2828
}
2929
}

src/GitVersion.MsBuild.Tests/GitVersion.MsBuild.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<ProjectReference Include="..\GitVersion.Output\GitVersion.Output.csproj" />
2727
</ItemGroup>
2828
<ItemGroup>
29-
<Compile Include="..\GitVersion.Core.Tests\Helpers\DirectoryHelper.cs" Link="Helpers\DirectoryHelper.cs" />
3029
<Compile Include="..\GitVersion.Core.Tests\Helpers\GitVersionCoreTestModule.cs" Link="Helpers\GitVersionCoreTestModule.cs" />
3130
<Compile Include="..\GitVersion.Core.Tests\Helpers\ExecutableHelper.cs" Link="Helpers\ExecutableHelper.cs" />
3231
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestBase.cs" Link="Helpers\TestBase.cs" />

src/GitVersion.MsBuild.Tests/Tasks/GenerateGitVersionInformationTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using GitVersion.Core.Tests.Helpers;
21
using GitVersion.Helpers;
32
using GitVersion.MsBuild.Tasks;
43
using GitVersion.MsBuild.Tests.Helpers;

src/GitVersion.MsBuild.Tests/Tasks/TestTaskBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected static MsBuildTaskFixtureResult<T> ExecuteMsBuildTaskInGitHubActions<T
7171
task.SolutionDirectory = fixture.LocalRepositoryFixture.RepositoryPath;
7272
AddOverrides(task);
7373
var msbuildFixture = new MsBuildTaskFixture(fixture);
74-
msbuildFixture.WithEnv([new("GITHUB_ACTIONS", "true")]);
74+
msbuildFixture.WithEnv(new KeyValuePair<string, string?>("GITHUB_ACTIONS", "true"));
7575
var result = msbuildFixture.Execute(task);
7676
if (!result.Success)
7777
Console.WriteLine(result.Log);

src/GitVersion.MsBuild.Tests/Tasks/UpdateAssemblyInfoTaskTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using GitVersion.Core.Tests.Helpers;
21
using GitVersion.Helpers;
32
using GitVersion.MsBuild.Tasks;
43
using GitVersion.MsBuild.Tests.Helpers;

src/GitVersion.Testing/Fixtures/RepositoryFixtureBase.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using GitVersion.Helpers;
2-
using GitVersion.Testing.Internal;
32
using LibGit2Sharp;
43
using Shouldly;
54

src/GitVersion.Testing/GitVersion.Testing.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
<PackageReference Include="LibGit2Sharp" />
77
</ItemGroup>
88
<ItemGroup>
9+
<Compile Include="..\GitVersion.Core\Helpers\DirectoryHelper.cs" Link="Helpers\DirectoryHelper.cs" />
910
<Compile Include="..\GitVersion.Core\Helpers\PathHelper.cs" Link="Helpers\PathHelper.cs" />
1011
</ItemGroup>
12+
<ItemGroup>
13+
<InternalsVisibleTo Include="GitVersion.BuildAgents.Tests" />
14+
<InternalsVisibleTo Include="GitVersion.Configuration.Tests" />
15+
<InternalsVisibleTo Include="GitVersion.Core.Tests" />
16+
<InternalsVisibleTo Include="GitVersion.Output.Tests" />
17+
<InternalsVisibleTo Include="GitVersion.App.Tests" />
18+
<InternalsVisibleTo Include="GitVersion.MsBuild.Tests" />
19+
</ItemGroup>
1120
</Project>

src/GitVersion.Testing/Helpers/DirectoryHelper.cs

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

0 commit comments

Comments
 (0)