Skip to content

Commit 6d61efa

Browse files
committed
cleanup
1 parent de9f2cf commit 6d61efa

Some content is hidden

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

42 files changed

+163
-258
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace GitVersion.App.Tests;
88
public sealed class ProgramFixture
99
{
1010
private readonly IEnvironment environment;
11-
private List<Action<IServiceCollection>> Overrides { get; } = new();
11+
private List<Action<IServiceCollection>> Overrides { get; } = [];
1212
private readonly Lazy<string> logger;
1313
private readonly Lazy<string?> output;
1414

src/GitVersion.App/OverrideConfigurationOptionParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace GitVersion;
44

55
internal class OverrideConfigurationOptionParser
66
{
7-
private readonly Dictionary<object, object?> overrideConfiguration = new();
7+
private readonly Dictionary<object, object?> overrideConfiguration = [];
88

99
private static readonly Lazy<ILookup<string?, PropertyInfo>> _lazySupportedProperties =
1010
new(GetSupportedProperties, true);

src/GitVersion.BuildAgents.Tests/Agents/BuildServerBaseTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void BuildNumberIsFullSemVer()
4343

4444
writes[1].ShouldBe("1.2.3-beta.1+5");
4545

46-
writes = new List<string?>();
46+
writes = [];
4747
buildAgent.WriteIntegration(writes.Add, variables, false);
4848
writes.ShouldNotContain(x => x != null && x.StartsWith("Executing GenerateSetVersionMessage for "));
4949
}

src/GitVersion.BuildAgents/Agents/BuildKite.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public override string[] GenerateSetParameterMessage(string name, string? value)
2727

2828
// For pull requests BUILDKITE_BRANCH refers to the head, so adjust the
2929
// branch name for pull request versioning to function as expected
30-
return string.Format("refs/pull/{0}/head", pullRequest);
30+
return $"refs/pull/{pullRequest}/head";
3131
}
3232

3333
public override bool PreventFetch() => true;

src/GitVersion.Configuration/BranchConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ internal record BranchConfiguration : IBranchConfiguration
5353

5454
[JsonPropertyName("source-branches")]
5555
[JsonPropertyDescription("The source branches for this branch.")]
56-
public HashSet<string> SourceBranches { get; internal set; } = new();
56+
public HashSet<string> SourceBranches { get; internal set; } = [];
5757

5858
[JsonIgnore]
5959
IReadOnlyCollection<string> IBranchConfiguration.SourceBranches => SourceBranches;
6060

6161
[JsonPropertyName("is-source-branch-for")]
6262
[JsonPropertyDescription("The branches that this branch is a source branch.")]
63-
public HashSet<string> IsSourceBranchFor { get; internal set; } = new();
63+
public HashSet<string> IsSourceBranchFor { get; internal set; } = [];
6464

6565
[JsonIgnore]
6666
IReadOnlyCollection<string> IBranchConfiguration.IsSourceBranchFor => IsSourceBranchFor;

src/GitVersion.Configuration/ConfigurationBuilderBase.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ internal abstract class ConfigurationBuilderBase<TConfigurationBuilder> : IConfi
2525
private bool updateBuildNumber;
2626
private SemanticVersionFormat semanticVersionFormat;
2727
private VersionStrategies[] versionStrategies;
28-
private Dictionary<string, string> mergeMessageFormats = new();
29-
private readonly List<IReadOnlyDictionary<object, object?>> overrides = new();
30-
private readonly Dictionary<string, BranchConfigurationBuilder> branchConfigurationBuilders = new();
28+
private Dictionary<string, string> mergeMessageFormats = [];
29+
private readonly List<IReadOnlyDictionary<object, object?>> overrides = [];
30+
private readonly Dictionary<string, BranchConfigurationBuilder> branchConfigurationBuilders = [];
3131
private DeploymentMode? versioningMode;
3232
private string? label;
3333
private IncrementStrategy increment = IncrementStrategy.Inherit;
@@ -384,7 +384,7 @@ public void AddOverride(IReadOnlyDictionary<object, object?> value)
384384

385385
public virtual IGitVersionConfiguration Build()
386386
{
387-
Dictionary<string, BranchConfiguration> branches = new();
387+
Dictionary<string, BranchConfiguration> branches = [];
388388
foreach (var (name, branchConfigurationBuilder) in this.branchConfigurationBuilders)
389389
{
390390
branches.Add(name, (BranchConfiguration)branchConfigurationBuilder.Build());

src/GitVersion.Configuration/ConfigurationHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private static void Merge(IDictionary<object, object?> dictionary, IReadOnlyDict
7272
{
7373
if (!dictionary.ContainsKey(item.Key))
7474
{
75-
Dictionary<object, object?> anotherDictionaryValue = new();
75+
Dictionary<object, object?> anotherDictionaryValue = [];
7676
Merge(anotherDictionaryValue, dictionaryValue);
7777
dictionary.Add(item.Key, anotherDictionaryValue);
7878
}

src/GitVersion.Configuration/ConfigurationSerializer.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ public static IGitVersionConfiguration Read(TextReader reader)
2828

2929
public static void Write(IGitVersionConfiguration configuration, TextWriter writer)
3030
=> Serializer.Serialize(writer, configuration);
31-
}
3231

33-
internal sealed class JsonPropertyNameInspector(ITypeInspector innerTypeDescriptor) : TypeInspectorSkeleton
34-
{
35-
public override IEnumerable<IPropertyDescriptor> GetProperties(Type type, object? container) =>
36-
innerTypeDescriptor.GetProperties(type, container)
37-
.Where(p => p.GetCustomAttribute<JsonIgnoreAttribute>() == null)
38-
.Select(p =>
39-
{
40-
var descriptor = new PropertyDescriptor(p);
41-
var member = p.GetCustomAttribute<JsonPropertyNameAttribute>();
42-
if (member is { Name: not null })
32+
private sealed class JsonPropertyNameInspector(ITypeInspector innerTypeDescriptor) : TypeInspectorSkeleton
33+
{
34+
public override IEnumerable<IPropertyDescriptor> GetProperties(Type type, object? container) =>
35+
innerTypeDescriptor.GetProperties(type, container)
36+
.Where(p => p.GetCustomAttribute<JsonIgnoreAttribute>() == null)
37+
.Select(p =>
4338
{
44-
descriptor.Name = member.Name;
45-
}
46-
47-
return (IPropertyDescriptor)descriptor;
48-
})
49-
.OrderBy(p => p.Order);
39+
var descriptor = new PropertyDescriptor(p);
40+
var member = p.GetCustomAttribute<JsonPropertyNameAttribute>();
41+
if (member is { Name: not null })
42+
{
43+
descriptor.Name = member.Name;
44+
}
45+
46+
return (IPropertyDescriptor)descriptor;
47+
})
48+
.OrderBy(p => p.Order);
49+
}
5050
}

src/GitVersion.Configuration/GitVersionCacheKeyFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public GitVersionCacheKey Create(IReadOnlyDictionary<object, object?>? overrideC
3232
var overrideConfigHash = GetOverrideConfigHash(overrideConfiguration);
3333

3434
var compositeHash = GetHash(gitSystemHash, configFileHash, repositorySnapshotHash, overrideConfigHash);
35-
return new GitVersionCacheKey(compositeHash);
35+
return new(compositeHash);
3636
}
3737

3838
private string GetGitSystemHash()

src/GitVersion.Configuration/GitVersionConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public string? NextVersion
109109

110110
[JsonPropertyName("merge-message-formats")]
111111
[JsonPropertyDescription("Custom merge message formats to enable identification of merge messages that do not follow the built-in conventions.")]
112-
public Dictionary<string, string> MergeMessageFormats { get; internal set; } = new();
112+
public Dictionary<string, string> MergeMessageFormats { get; internal set; } = [];
113113

114114
[JsonIgnore]
115115
IReadOnlyDictionary<string, string> IGitVersionConfiguration.MergeMessageFormats => MergeMessageFormats;
@@ -138,7 +138,7 @@ IReadOnlyDictionary<string, IBranchConfiguration> IGitVersionConfiguration.Branc
138138

139139
[JsonPropertyName("branches")]
140140
[JsonPropertyDescription("The header for all the individual branch configuration.")]
141-
public Dictionary<string, BranchConfiguration> Branches { get; internal set; } = new();
141+
public Dictionary<string, BranchConfiguration> Branches { get; internal set; } = [];
142142

143143
[JsonIgnore]
144144
IIgnoreConfiguration IGitVersionConfiguration.Ignore => Ignore;

0 commit comments

Comments
 (0)