Skip to content

Commit

Permalink
Merge pull request #1030 from adamralph/lang-versions-warnings
Browse files Browse the repository at this point in the history
update lang versions and address warnings
  • Loading branch information
adamralph authored Jul 21, 2024
2 parents 46aa9bb + 079f492 commit 2e48c6e
Show file tree
Hide file tree
Showing 14 changed files with 7 additions and 19 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>default</LangVersion>
<!-- workaround for https://github.com/dotnet/roslyn/issues/41640 -->
<NoWarn>EnableGenerateDocumentationFile</NoWarn>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion MinVer.Lib/Git.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion MinVer.Lib/MinVer.Lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<IsPackable>false</IsPackable>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<LangVersion>default</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion MinVer.Lib/PreReleaseIdentifiers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ namespace MinVer.Lib;

public static class PreReleaseIdentifiers
{
public static readonly IReadOnlyCollection<string> Default = new List<string> { "alpha", "0", };
public static readonly IReadOnlyCollection<string> Default = ["alpha", "0",];
}
1 change: 0 additions & 1 deletion MinVer/MinVer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<RollForward>major</RollForward>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<LangVersion>default</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion MinVerTests.Infra/CommandEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal static class CommandEx

public static async Task<(string StandardOutput, string StandardError)> ReadLoggedAsync(string name, string args = "", string workingDirectory = "", IEnumerable<KeyValuePair<string, string>>? envVars = null, Func<int, bool>? handleExitCode = null)
{
envVars = (envVars ?? Enumerable.Empty<KeyValuePair<string, string>>()).ToList();
envVars = (envVars ?? []).ToList();

var result = await Command.ReadAsync(
name,
Expand Down
2 changes: 1 addition & 1 deletion MinVerTests.Infra/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ internal static class Configuration
#if DEBUG
"Debug";
#elif RELEASE
"Release";
"Release";
#endif
}
2 changes: 1 addition & 1 deletion MinVerTests.Infra/MinVerCli.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 0 additions & 4 deletions MinVerTests.Infra/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions MinVerTests.Lib/Infra/TestLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ namespace MinVerTests.Lib.Infra;

internal sealed class TestLogger : ILogger
{
#if NET8_0_OR_GREATER
private readonly List<LogMessage> messages = [];
#else
private readonly List<LogMessage> messages = new();
#endif

public bool IsTraceEnabled => true;

Expand Down
1 change: 0 additions & 1 deletion MinVerTests.Packages/MinVerTests.Packages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<RollForward>major</RollForward>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>default</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion minver-cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion minver-cli/minver-cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<RootNamespace>MinVer</RootNamespace>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ToolCommandName>minver</ToolCommandName>
<LangVersion>default</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion targets/Targets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<OutputType>Exe</OutputType>
<RollForward>major</RollForward>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>default</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 2e48c6e

Please sign in to comment.