From 079f492238666aa58fbdd51cba994f6dbd319c44 Mon Sep 17 00:00:00 2001 From: Adam Ralph Date: Sun, 21 Jul 2024 14:48:03 +0200 Subject: [PATCH] update lang versions and address warnings --- Directory.Build.props | 1 + MinVer.Lib/Git.cs | 2 +- MinVer.Lib/MinVer.Lib.csproj | 1 - MinVer.Lib/PreReleaseIdentifiers.cs | 2 +- MinVer/MinVer.csproj | 1 - MinVerTests.Infra/CommandEx.cs | 2 +- MinVerTests.Infra/Configuration.cs | 2 +- MinVerTests.Infra/MinVerCli.cs | 2 +- MinVerTests.Infra/StringExtensions.cs | 4 ---- MinVerTests.Lib/Infra/TestLogger.cs | 4 ---- MinVerTests.Packages/MinVerTests.Packages.csproj | 1 - minver-cli/Program.cs | 2 +- minver-cli/minver-cli.csproj | 1 - targets/Targets.csproj | 1 - 14 files changed, 7 insertions(+), 19 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index ac4f9bd7..10522257 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -7,6 +7,7 @@ true true enable + default EnableGenerateDocumentationFile enable diff --git a/MinVer.Lib/Git.cs b/MinVer.Lib/Git.cs index f4aaeebf..eef16294 100644 --- a/MinVer.Lib/Git.cs +++ b/MinVer.Lib/Git.cs @@ -44,7 +44,7 @@ public static bool TryGetHead(string directory, [NotNullWhen(returnValue: true)] .Split(newLineChars, StringSplitOptions.RemoveEmptyEntries) .Select(line => line.Split(" ", 2)) .Select(tokens => (tokens[1][10..].RemoveFromEnd("^{}"), tokens[0])) - : Enumerable.Empty<(string, string)>(); + : []; private static string RemoveFromEnd(this string text, string value) => text.EndsWith(value, StringComparison.OrdinalIgnoreCase) ? text[..^value.Length] : text; diff --git a/MinVer.Lib/MinVer.Lib.csproj b/MinVer.Lib/MinVer.Lib.csproj index 37bd6a0d..db0a35b6 100644 --- a/MinVer.Lib/MinVer.Lib.csproj +++ b/MinVer.Lib/MinVer.Lib.csproj @@ -3,7 +3,6 @@ false net6.0;net8.0 - default diff --git a/MinVer.Lib/PreReleaseIdentifiers.cs b/MinVer.Lib/PreReleaseIdentifiers.cs index b3d8cf4e..98e5afb0 100644 --- a/MinVer.Lib/PreReleaseIdentifiers.cs +++ b/MinVer.Lib/PreReleaseIdentifiers.cs @@ -2,5 +2,5 @@ namespace MinVer.Lib; public static class PreReleaseIdentifiers { - public static readonly IReadOnlyCollection Default = new List { "alpha", "0", }; + public static readonly IReadOnlyCollection Default = ["alpha", "0",]; } diff --git a/MinVer/MinVer.csproj b/MinVer/MinVer.csproj index 4996ba3c..263a10c6 100644 --- a/MinVer/MinVer.csproj +++ b/MinVer/MinVer.csproj @@ -19,7 +19,6 @@ major true net6.0;net8.0 - default diff --git a/MinVerTests.Infra/CommandEx.cs b/MinVerTests.Infra/CommandEx.cs index 64a575af..a4913cd5 100644 --- a/MinVerTests.Infra/CommandEx.cs +++ b/MinVerTests.Infra/CommandEx.cs @@ -9,7 +9,7 @@ internal static class CommandEx public static async Task<(string StandardOutput, string StandardError)> ReadLoggedAsync(string name, string args = "", string workingDirectory = "", IEnumerable>? envVars = null, Func? handleExitCode = null) { - envVars = (envVars ?? Enumerable.Empty>()).ToList(); + envVars = (envVars ?? []).ToList(); var result = await Command.ReadAsync( name, diff --git a/MinVerTests.Infra/Configuration.cs b/MinVerTests.Infra/Configuration.cs index 28bca368..b9eb490b 100644 --- a/MinVerTests.Infra/Configuration.cs +++ b/MinVerTests.Infra/Configuration.cs @@ -6,6 +6,6 @@ internal static class Configuration #if DEBUG "Debug"; #elif RELEASE - "Release"; + "Release"; #endif } diff --git a/MinVerTests.Infra/MinVerCli.cs b/MinVerTests.Infra/MinVerCli.cs index 7ffa7d5d..e3eccf27 100644 --- a/MinVerTests.Infra/MinVerCli.cs +++ b/MinVerTests.Infra/MinVerCli.cs @@ -15,6 +15,6 @@ public static string GetPath(string configuration) => Solution.GetFullPath($"minver-cli/bin/{configuration}/net6.0/minver-cli.dll"); #endif #if NET8_0 - Solution.GetFullPath($"minver-cli/bin/{configuration}/net8.0/minver-cli.dll"); + Solution.GetFullPath($"minver-cli/bin/{configuration}/net8.0/minver-cli.dll"); #endif } diff --git a/MinVerTests.Infra/StringExtensions.cs b/MinVerTests.Infra/StringExtensions.cs index 96cfe274..2e5375ee 100644 --- a/MinVerTests.Infra/StringExtensions.cs +++ b/MinVerTests.Infra/StringExtensions.cs @@ -2,11 +2,7 @@ namespace MinVerTests.Infra; public static class StringExtensions { -#if NET8_0_OR_GREATER private static readonly char[] newLineChars = ['\r', '\n',]; -#else - private static readonly char[] newLineChars = { '\r', '\n', }; -#endif public static string[] ToNonEmptyLines(this string text) => #pragma warning disable CA1062 // Validate arguments of public methods diff --git a/MinVerTests.Lib/Infra/TestLogger.cs b/MinVerTests.Lib/Infra/TestLogger.cs index e91f1ef4..158206a5 100644 --- a/MinVerTests.Lib/Infra/TestLogger.cs +++ b/MinVerTests.Lib/Infra/TestLogger.cs @@ -4,11 +4,7 @@ namespace MinVerTests.Lib.Infra; internal sealed class TestLogger : ILogger { -#if NET8_0_OR_GREATER private readonly List messages = []; -#else - private readonly List messages = new(); -#endif public bool IsTraceEnabled => true; diff --git a/MinVerTests.Packages/MinVerTests.Packages.csproj b/MinVerTests.Packages/MinVerTests.Packages.csproj index b74a03ad..023259b5 100644 --- a/MinVerTests.Packages/MinVerTests.Packages.csproj +++ b/MinVerTests.Packages/MinVerTests.Packages.csproj @@ -3,7 +3,6 @@ major net8.0 - default diff --git a/minver-cli/Program.cs b/minver-cli/Program.cs index 27b0d877..594484e2 100644 --- a/minver-cli/Program.cs +++ b/minver-cli/Program.cs @@ -80,7 +80,7 @@ { log.Warn(1008, "MinVerDefaultPreReleasePhase is deprecated and will be removed in the next major version. Use MinVerDefaultPreReleaseIdentifiers instead, with an additional \"0\" identifier. For example, if you are setting MinVerDefaultPreReleasePhase to \"preview\", set MinVerDefaultPreReleaseIdentifiers to \"preview.0\" instead."); - defaultPreReleaseIdentifiers ??= new[] { options.DefaultPreReleasePhase, "0", }; + defaultPreReleaseIdentifiers ??= [options.DefaultPreReleasePhase, "0",]; } Version version; diff --git a/minver-cli/minver-cli.csproj b/minver-cli/minver-cli.csproj index 0911a9a8..ea2acb5e 100644 --- a/minver-cli/minver-cli.csproj +++ b/minver-cli/minver-cli.csproj @@ -16,7 +16,6 @@ MinVer net6.0;net8.0 minver - default diff --git a/targets/Targets.csproj b/targets/Targets.csproj index d22b9263..4a261336 100644 --- a/targets/Targets.csproj +++ b/targets/Targets.csproj @@ -5,7 +5,6 @@ Exe major net8.0 - default