Skip to content

Commit 2fade35

Browse files
committed
minor refactoring
1 parent 5044a13 commit 2fade35

File tree

5 files changed

+13
-17
lines changed

5 files changed

+13
-17
lines changed

MinVer.Lib/Versioner.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private static (Version Version, int? Height) GetVersion(string workDir, string
7777
return (selectedCandidate.Version, selectedCandidate.Height);
7878
}
7979

80-
private static List<Candidate> GetCandidates(Commit head, IEnumerable<(string Name, string Sha)> tags, string tagPrefix, List<string> defaultPreReleaseIdentifiers, ILogger log)
80+
private static List<Candidate> GetCandidates(Commit head, IEnumerable<(string Name, string Sha)> tags, string tagPrefix, IReadOnlyCollection<string> defaultPreReleaseIdentifiers, ILogger log)
8181
{
8282
var tagsAndVersions = new List<(string Name, string Sha, Version Version)>();
8383

@@ -97,7 +97,7 @@ private static List<Candidate> GetCandidates(Commit head, IEnumerable<(string Na
9797
[
9898
.. tagsAndVersions
9999
.OrderBy(tagAndVersion => tagAndVersion.Version)
100-
.ThenBy(tagsAndVersion => tagsAndVersion.Name)
100+
.ThenBy(tagsAndVersion => tagsAndVersion.Name),
101101
];
102102

103103
var itemsToCheck = new Stack<(Commit Commit, int Height, Commit? Child)>();

MinVer/Logger.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ namespace MinVer;
55

66
internal sealed class Logger(Verbosity verbosity) : ILogger
77
{
8-
private readonly Verbosity verbosity = verbosity;
8+
public bool IsTraceEnabled => verbosity >= Verbosity.Diagnostic;
99

10-
public bool IsTraceEnabled => this.verbosity >= Verbosity.Diagnostic;
10+
public bool IsDebugEnabled => verbosity >= Verbosity.Detailed;
1111

12-
public bool IsDebugEnabled => this.verbosity >= Verbosity.Detailed;
13-
14-
public bool IsInfoEnabled => this.verbosity >= Verbosity.Normal;
12+
public bool IsInfoEnabled => verbosity >= Verbosity.Normal;
1513

1614
// warnings are deliberately shown at quiet level
17-
public bool IsWarnEnabled => this.verbosity >= Verbosity.Quiet;
15+
public bool IsWarnEnabled => verbosity >= Verbosity.Quiet;
1816

1917
public bool Trace(string message) => this.IsTraceEnabled && Message(message);
2018

MinVerTests.Packages/SourceLink.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static async Task HasCommitSha()
2020
int.Parse(Sdk.Version.Split(".")[0], NumberStyles.None, CultureInfo.InvariantCulture) < 8)
2121
{
2222
_ = await Sdk.DotNet(
23-
$"add package Microsoft.SourceLink.GitHub --version 1.1.1 --package-directory packages", path);
23+
"add package Microsoft.SourceLink.GitHub --version 1.1.1 --package-directory packages", path);
2424
_ = await Sdk.DotNet("restore --packages packages", path);
2525
}
2626

minver-cli/Logger.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ namespace MinVer;
55

66
internal sealed class Logger(Verbosity verbosity) : ILogger
77
{
8-
private readonly Verbosity verbosity = verbosity;
8+
public bool IsTraceEnabled => verbosity >= Verbosity.Trace;
99

10-
public bool IsTraceEnabled => this.verbosity >= Verbosity.Trace;
10+
public bool IsDebugEnabled => verbosity >= Verbosity.Debug;
1111

12-
public bool IsDebugEnabled => this.verbosity >= Verbosity.Debug;
12+
public bool IsInfoEnabled => verbosity >= Verbosity.Info;
1313

14-
public bool IsInfoEnabled => this.verbosity >= Verbosity.Info;
15-
16-
public bool IsWarnEnabled => this.verbosity >= Verbosity.Warn;
14+
public bool IsWarnEnabled => verbosity >= Verbosity.Warn;
1715

1816
public bool Trace(string message) => this.IsTraceEnabled && Message(message);
1917

targets/Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
"test-lib",
2121
"test the MinVer.Lib library",
2222
DependsOn("build"),
23-
() => RunAsync("dotnet", ["test", "./MinVerTests.Lib", "--framework", testFx, "--configuration", "Release", "--no-build", "--nologo", .. testLoggerArgs]));
23+
() => RunAsync("dotnet", ["test", "./MinVerTests.Lib", "--framework", testFx, "--configuration", "Release", "--no-build", "--nologo", .. testLoggerArgs,]));
2424

2525
Target(
2626
"test-packages",
2727
"test the MinVer package and the minver-cli console app",
2828
DependsOn("build"),
29-
() => RunAsync("dotnet", ["test", "./MinVerTests.Packages", "--configuration", "Release", "--no-build", "--nologo", .. testLoggerArgs]));
29+
() => RunAsync("dotnet", ["test", "./MinVerTests.Packages", "--configuration", "Release", "--no-build", "--nologo", .. testLoggerArgs,]));
3030

3131
Target(
3232
"eyeball-minver-logs",

0 commit comments

Comments
 (0)