From 92a8a42ef188f4236322f5288415c38f0e23e2b6 Mon Sep 17 00:00:00 2001 From: Zafer Balkan Date: Thu, 5 Jun 2025 11:27:06 +0300 Subject: [PATCH 1/5] Bumped up to LTS version, .NET 8.0 --- src/System.CommandLine.Tests/CompletionTests.cs | 8 ++++---- src/System.CommandLine/ArgumentValidation.cs | 2 +- src/System.CommandLine/Argument{T}.cs | 2 +- src/System.CommandLine/Binding/ArgumentConverter.cs | 2 +- src/System.CommandLine/ConsoleHelpers.cs | 2 +- .../Invocation/ProcessTerminationHandler.cs | 8 ++++---- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/System.CommandLine.Tests/CompletionTests.cs b/src/System.CommandLine.Tests/CompletionTests.cs index 9f13327c05..84d931f863 100644 --- a/src/System.CommandLine.Tests/CompletionTests.cs +++ b/src/System.CommandLine.Tests/CompletionTests.cs @@ -784,12 +784,12 @@ public void When_parsing_from_text_if_the_proximate_option_is_completed_then_com { var command = new RootCommand { - CreateOptionWithAcceptOnlyFromAmong(name: "--framework", "net7.0"), + CreateOptionWithAcceptOnlyFromAmong(name: "--framework", "net8.0"), CreateOptionWithAcceptOnlyFromAmong(name: "--language", "C#"), new Option("--langVersion") }; var configuration = new CommandLineConfiguration(command); - var completions = command.Parse("--framework net7.0 --l", configuration).GetCompletions(); + var completions = command.Parse("--framework net8.0 --l", configuration).GetCompletions(); completions.Select(item => item.Label) .Should() @@ -801,12 +801,12 @@ public void When_parsing_from_array_if_the_proximate_option_is_completed_then_co { var command = new RootCommand { - CreateOptionWithAcceptOnlyFromAmong(name: "--framework", "net7.0"), + CreateOptionWithAcceptOnlyFromAmong(name: "--framework", "net8.0"), CreateOptionWithAcceptOnlyFromAmong(name: "--language", "C#"), new Option("--langVersion") }; var configuration = new CommandLineConfiguration(command); - var completions = command.Parse(new[]{"--framework","net7.0","--l"}, configuration).GetCompletions(); + var completions = command.Parse(new[]{"--framework","net8.0","--l"}, configuration).GetCompletions(); completions.Select(item => item.Label) .Should() diff --git a/src/System.CommandLine/ArgumentValidation.cs b/src/System.CommandLine/ArgumentValidation.cs index 80a94a7bb5..fdd6eb7fa7 100644 --- a/src/System.CommandLine/ArgumentValidation.cs +++ b/src/System.CommandLine/ArgumentValidation.cs @@ -171,7 +171,7 @@ private static void FileOrDirectoryExists(ArgumentResult result) if (checkFile && checkDirectory) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER if (!Path.Exists(token.Value)) #else if (!Directory.Exists(token.Value) && !File.Exists(token.Value)) diff --git a/src/System.CommandLine/Argument{T}.cs b/src/System.CommandLine/Argument{T}.cs index 42263f819e..a3e5346c83 100644 --- a/src/System.CommandLine/Argument{T}.cs +++ b/src/System.CommandLine/Argument{T}.cs @@ -88,7 +88,7 @@ public Argument(string name) : base(name) { if (default(T) is null && typeof(T) != typeof(string)) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER if (typeof(T).IsSZArray) #else if (typeof(T).IsArray && typeof(T).GetArrayRank() == 1) diff --git a/src/System.CommandLine/Binding/ArgumentConverter.cs b/src/System.CommandLine/Binding/ArgumentConverter.cs index 6f494bdd08..300763511d 100644 --- a/src/System.CommandLine/Binding/ArgumentConverter.cs +++ b/src/System.CommandLine/Binding/ArgumentConverter.cs @@ -61,7 +61,7 @@ private static ArgumentConversionResult ConvertToken( if (type.IsEnum) { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER if (Enum.TryParse(type, value, ignoreCase: true, out var converted)) { return Success(argumentResult, converted); diff --git a/src/System.CommandLine/ConsoleHelpers.cs b/src/System.CommandLine/ConsoleHelpers.cs index 2684413c89..606eba1c3e 100644 --- a/src/System.CommandLine/ConsoleHelpers.cs +++ b/src/System.CommandLine/ConsoleHelpers.cs @@ -10,7 +10,7 @@ internal static class ConsoleHelpers private static readonly bool ColorsAreSupported = GetColorsAreSupported(); private static bool GetColorsAreSupported() -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER => !(OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS()) #else => !(RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")) diff --git a/src/System.CommandLine/Invocation/ProcessTerminationHandler.cs b/src/System.CommandLine/Invocation/ProcessTerminationHandler.cs index ead35b4eb0..17a848b6de 100644 --- a/src/System.CommandLine/Invocation/ProcessTerminationHandler.cs +++ b/src/System.CommandLine/Invocation/ProcessTerminationHandler.cs @@ -16,7 +16,7 @@ internal sealed class ProcessTerminationHandler : IDisposable private readonly CancellationTokenSource _handlerCancellationTokenSource; private readonly Task _startedHandler; private readonly TimeSpan _processTerminationTimeout; -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER private readonly IDisposable? _sigIntRegistration, _sigTermRegistration; #endif @@ -30,7 +30,7 @@ internal ProcessTerminationHandler( _startedHandler = startedHandler; _processTerminationTimeout = processTerminationTimeout; -#if NET7_0_OR_GREATER // we prefer the new API as they allow for cancelling SIGTERM +#if NET8_0_OR_GREATER // we prefer the new API as they allow for cancelling SIGTERM if (!OperatingSystem.IsAndroid() && !OperatingSystem.IsIOS() && !OperatingSystem.IsTvOS() @@ -48,7 +48,7 @@ internal ProcessTerminationHandler( public void Dispose() { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER if (_sigIntRegistration is not null) { _sigIntRegistration.Dispose(); @@ -61,7 +61,7 @@ public void Dispose() AppDomain.CurrentDomain.ProcessExit -= OnProcessExit; } -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER void OnPosixSignal(PosixSignalContext context) { context.Cancel = true; From 4fbed1e292efa83fa21c78ae8c44dab87cb4ff23 Mon Sep 17 00:00:00 2001 From: Zafer Balkan Date: Thu, 5 Jun 2025 11:32:04 +0300 Subject: [PATCH 2/5] Bumped up dependencies --- Directory.Packages.props | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index db3de58147..cdc107a5a5 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,12 +1,10 @@ - true false $(NoWarn);NU1507 - @@ -14,24 +12,22 @@ - + - + - + - - - + + + - - - + \ No newline at end of file From 1645b71272f0ef4176afcebe7e2aee4281fc75f0 Mon Sep 17 00:00:00 2001 From: Zafer Balkan Date: Thu, 5 Jun 2025 12:21:53 +0300 Subject: [PATCH 3/5] Rolled back dependency versions to 8 Signed-off-by: Zafer Balkan --- Directory.Packages.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index cdc107a5a5..40b3d4ab6e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -12,9 +12,9 @@ - + - + From ffea4e6a2a765706975677208d1c2c6f40cebb49 Mon Sep 17 00:00:00 2001 From: Zafer Balkan Date: Thu, 5 Jun 2025 12:22:39 +0300 Subject: [PATCH 4/5] Rolled back NET8_0_OR_GREATER Signed-off-by: Zafer Balkan --- src/System.CommandLine/ArgumentValidation.cs | 2 +- src/System.CommandLine/Argument{T}.cs | 2 +- src/System.CommandLine/Binding/ArgumentConverter.cs | 2 +- src/System.CommandLine/ConsoleHelpers.cs | 2 +- .../Invocation/ProcessTerminationHandler.cs | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/System.CommandLine/ArgumentValidation.cs b/src/System.CommandLine/ArgumentValidation.cs index fdd6eb7fa7..80a94a7bb5 100644 --- a/src/System.CommandLine/ArgumentValidation.cs +++ b/src/System.CommandLine/ArgumentValidation.cs @@ -171,7 +171,7 @@ private static void FileOrDirectoryExists(ArgumentResult result) if (checkFile && checkDirectory) { -#if NET8_0_OR_GREATER +#if NET7_0_OR_GREATER if (!Path.Exists(token.Value)) #else if (!Directory.Exists(token.Value) && !File.Exists(token.Value)) diff --git a/src/System.CommandLine/Argument{T}.cs b/src/System.CommandLine/Argument{T}.cs index a3e5346c83..42263f819e 100644 --- a/src/System.CommandLine/Argument{T}.cs +++ b/src/System.CommandLine/Argument{T}.cs @@ -88,7 +88,7 @@ public Argument(string name) : base(name) { if (default(T) is null && typeof(T) != typeof(string)) { -#if NET8_0_OR_GREATER +#if NET7_0_OR_GREATER if (typeof(T).IsSZArray) #else if (typeof(T).IsArray && typeof(T).GetArrayRank() == 1) diff --git a/src/System.CommandLine/Binding/ArgumentConverter.cs b/src/System.CommandLine/Binding/ArgumentConverter.cs index 300763511d..6f494bdd08 100644 --- a/src/System.CommandLine/Binding/ArgumentConverter.cs +++ b/src/System.CommandLine/Binding/ArgumentConverter.cs @@ -61,7 +61,7 @@ private static ArgumentConversionResult ConvertToken( if (type.IsEnum) { -#if NET8_0_OR_GREATER +#if NET7_0_OR_GREATER if (Enum.TryParse(type, value, ignoreCase: true, out var converted)) { return Success(argumentResult, converted); diff --git a/src/System.CommandLine/ConsoleHelpers.cs b/src/System.CommandLine/ConsoleHelpers.cs index 606eba1c3e..2684413c89 100644 --- a/src/System.CommandLine/ConsoleHelpers.cs +++ b/src/System.CommandLine/ConsoleHelpers.cs @@ -10,7 +10,7 @@ internal static class ConsoleHelpers private static readonly bool ColorsAreSupported = GetColorsAreSupported(); private static bool GetColorsAreSupported() -#if NET8_0_OR_GREATER +#if NET7_0_OR_GREATER => !(OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS()) #else => !(RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")) diff --git a/src/System.CommandLine/Invocation/ProcessTerminationHandler.cs b/src/System.CommandLine/Invocation/ProcessTerminationHandler.cs index 17a848b6de..ead35b4eb0 100644 --- a/src/System.CommandLine/Invocation/ProcessTerminationHandler.cs +++ b/src/System.CommandLine/Invocation/ProcessTerminationHandler.cs @@ -16,7 +16,7 @@ internal sealed class ProcessTerminationHandler : IDisposable private readonly CancellationTokenSource _handlerCancellationTokenSource; private readonly Task _startedHandler; private readonly TimeSpan _processTerminationTimeout; -#if NET8_0_OR_GREATER +#if NET7_0_OR_GREATER private readonly IDisposable? _sigIntRegistration, _sigTermRegistration; #endif @@ -30,7 +30,7 @@ internal ProcessTerminationHandler( _startedHandler = startedHandler; _processTerminationTimeout = processTerminationTimeout; -#if NET8_0_OR_GREATER // we prefer the new API as they allow for cancelling SIGTERM +#if NET7_0_OR_GREATER // we prefer the new API as they allow for cancelling SIGTERM if (!OperatingSystem.IsAndroid() && !OperatingSystem.IsIOS() && !OperatingSystem.IsTvOS() @@ -48,7 +48,7 @@ internal ProcessTerminationHandler( public void Dispose() { -#if NET8_0_OR_GREATER +#if NET7_0_OR_GREATER if (_sigIntRegistration is not null) { _sigIntRegistration.Dispose(); @@ -61,7 +61,7 @@ public void Dispose() AppDomain.CurrentDomain.ProcessExit -= OnProcessExit; } -#if NET8_0_OR_GREATER +#if NET7_0_OR_GREATER void OnPosixSignal(PosixSignalContext context) { context.Cancel = true; From 94fd62fd6fa15d048ca0e6f046894c21c2d9400d Mon Sep 17 00:00:00 2001 From: Zafer Balkan Date: Wed, 18 Jun 2025 16:18:05 +0300 Subject: [PATCH 5/5] Fixed newline issue --- Directory.Packages.props | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Directory.Packages.props b/Directory.Packages.props index 40b3d4ab6e..dac4c8084a 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,10 +1,12 @@ + true false $(NoWarn);NU1507 + @@ -25,9 +27,11 @@ + + \ No newline at end of file