From 5945d19b8154497d23f9e0d950b0a684c416982f Mon Sep 17 00:00:00 2001 From: Adam Ralph Date: Thu, 26 Dec 2024 20:40:25 +0000 Subject: [PATCH] switch from net6 to net9 and update SDKs --- .github/workflows/ci.yml | 4 ++-- .github/workflows/infer-sharp.yml | 2 +- .github/workflows/lint.yml | 3 +++ .github/workflows/release.yml | 2 +- SimpleExec/Command.cs | 21 --------------------- SimpleExec/ExitCodeException.cs | 20 -------------------- SimpleExec/SimpleExec.csproj | 2 +- SimpleExecTester/SimpleExecTester.csproj | 2 +- SimpleExecTests/CancellingCommands.cs | 12 ------------ SimpleExecTests/Infra/Tester.cs | 12 ++++++------ SimpleExecTests/SimpleExecTests.csproj | 4 +++- global.json | 2 +- 12 files changed, 19 insertions(+), 67 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17f4773..df42ff1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,8 +26,8 @@ jobs: - uses: actions/setup-dotnet@v4.0.1 with: dotnet-version: | - 6.0.425 - 8.0.401 + 8.0.404 + 9.0.101 - uses: actions/checkout@v4.1.7 with: fetch-depth: 0 diff --git a/.github/workflows/infer-sharp.yml b/.github/workflows/infer-sharp.yml index 8aa6097..4fa5a9c 100644 --- a/.github/workflows/infer-sharp.yml +++ b/.github/workflows/infer-sharp.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/setup-dotnet@v4.0.1 with: - dotnet-version: '8.0.401' + dotnet-version: '9.0.101' - uses: actions/checkout@v4.1.7 - run: dotnet build - run: ls -al diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0c0d0a4..f639087 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,6 +12,9 @@ jobs: packages: read statuses: write steps: + - uses: actions/setup-dotnet@v4.0.1 + with: + dotnet-version: 9.0.101 - uses: actions/checkout@v4.1.7 with: fetch-depth: 0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index af7827c..72b9095 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/setup-dotnet@v4.0.1 with: - dotnet-version: 8.0.401 + dotnet-version: 9.0.101 - uses: actions/checkout@v4.1.7 - run: dotnet build --configuration Release --nologo - name: push diff --git a/SimpleExec/Command.cs b/SimpleExec/Command.cs index 09a4086..4fd86d3 100644 --- a/SimpleExec/Command.cs +++ b/SimpleExec/Command.cs @@ -55,11 +55,7 @@ public static void Run( .Create( Resolve(Validate(name)), args, -#if NET8_0_OR_GREATER [], -#else - Enumerable.Empty(), -#endif workingDirectory, false, configureEnvironment ?? defaultAction, @@ -176,11 +172,7 @@ public static Task RunAsync( .Create( Resolve(Validate(name)), args, -#if NET8_0_OR_GREATER [], -#else - Enumerable.Empty(), -#endif workingDirectory, false, configureEnvironment ?? defaultAction, @@ -296,11 +288,7 @@ private static async Task RunAsync( .Create( Resolve(Validate(name)), args, -#if NET8_0_OR_GREATER [], -#else - Enumerable.Empty(), -#endif workingDirectory, true, configureEnvironment ?? defaultAction, @@ -388,13 +376,8 @@ private static async Task RunAsync( await process.StandardInput.WriteAsync(standardInput).ConfigureAwait(false); process.StandardInput.Close(); -#if NET8_0_OR_GREATER readOutput = process.StandardOutput.ReadToEndAsync(cancellationToken); readError = process.StandardError.ReadToEndAsync(cancellationToken); -#else - readOutput = process.StandardOutput.ReadToEndAsync(); - readError = process.StandardError.ReadToEndAsync(); -#endif } catch (Exception) { @@ -443,11 +426,7 @@ private static string Resolve(string name) var searchFileNames = string.IsNullOrEmpty(extension) ? windowsExecutableExtensions.Select(ex => Path.ChangeExtension(name, ex)).ToList() -#if NET8_0_OR_GREATER : [name]; -#else - : new List { name, }; -#endif var path = GetSearchDirectories().SelectMany(_ => searchFileNames, Path.Combine) .FirstOrDefault(File.Exists); diff --git a/SimpleExec/ExitCodeException.cs b/SimpleExec/ExitCodeException.cs index 11f6392..b32347d 100644 --- a/SimpleExec/ExitCodeException.cs +++ b/SimpleExec/ExitCodeException.cs @@ -1,6 +1,5 @@ namespace SimpleExec; -#if NET8_0_OR_GREATER /// /// The command exited with an unexpected exit code. /// @@ -13,25 +12,6 @@ public class ExitCodeException(int exitCode) : Exception /// Gets the exit code of the command. /// public int ExitCode { get; } = exitCode; -#else -/// -/// The command exited with an unexpected exit code. -/// -#pragma warning disable CA1032 // Implement standard exception constructors -public class ExitCodeException : Exception -#pragma warning restore CA1032 // Implement standard exception constructors -{ - /// - /// Constructs an instance of a . - /// - /// The exit code of the command. - public ExitCodeException(int exitCode) => this.ExitCode = exitCode; - - /// - /// Gets the exit code of the command. - /// - public int ExitCode { get; } -#endif /// public override string Message => $"The command exited with code {this.ExitCode}."; diff --git a/SimpleExec/SimpleExec.csproj b/SimpleExec/SimpleExec.csproj index 42aaf32..56c1971 100644 --- a/SimpleExec/SimpleExec.csproj +++ b/SimpleExec/SimpleExec.csproj @@ -11,7 +11,7 @@ README.md https://github.com/adamralph/simple-exec/blob/main/CHANGELOG.md true - net6.0;net8.0 + net8.0;net9.0 diff --git a/SimpleExecTester/SimpleExecTester.csproj b/SimpleExecTester/SimpleExecTester.csproj index 729ebe8..2c0b366 100644 --- a/SimpleExecTester/SimpleExecTester.csproj +++ b/SimpleExecTester/SimpleExecTester.csproj @@ -5,7 +5,7 @@ default Exe major - net6.0;net8.0 + net8.0;net9.0 diff --git a/SimpleExecTests/CancellingCommands.cs b/SimpleExecTests/CancellingCommands.cs index ffa8325..c00526a 100644 --- a/SimpleExecTests/CancellingCommands.cs +++ b/SimpleExecTests/CancellingCommands.cs @@ -31,11 +31,7 @@ public static async Task RunningACommandAsync() // use a cancellation token source to ensure value type equality comparison in assertion is meaningful var cancellationToken = cancellationTokenSource.Token; -#if NET8_0_OR_GREATER await cancellationTokenSource.CancelAsync(); -#else - cancellationTokenSource.Cancel(); -#endif // act var exception = await Record.ExceptionAsync(() => Command.RunAsync("dotnet", $"exec {Tester.Path} sleep", cancellationToken: cancellationToken)); @@ -52,11 +48,7 @@ public static async Task ReadingACommandAsync() // use a cancellation token source to ensure value type equality comparison in assertion is meaningful var cancellationToken = cancellationTokenSource.Token; -#if NET8_0_OR_GREATER await cancellationTokenSource.CancelAsync(); -#else - cancellationTokenSource.Cancel(); -#endif // act var exception = await Record.ExceptionAsync(() => Command.ReadAsync("dotnet", $"exec {Tester.Path} sleep", cancellationToken: cancellationToken)); @@ -80,11 +72,7 @@ public static async Task RunningACommandAsyncWithCreateNoWindow(bool createNoWin "dotnet", $"exec {Tester.Path} sleep", createNoWindow: createNoWindow, cancellationToken: cancellationToken); // act -#if NET8_0_OR_GREATER await cancellationTokenSource.CancelAsync(); -#else - cancellationTokenSource.Cancel(); -#endif // assert var exception = await Record.ExceptionAsync(() => command); diff --git a/SimpleExecTests/Infra/Tester.cs b/SimpleExecTests/Infra/Tester.cs index 24afb50..4785c80 100644 --- a/SimpleExecTests/Infra/Tester.cs +++ b/SimpleExecTests/Infra/Tester.cs @@ -3,16 +3,16 @@ namespace SimpleExecTests.Infra; internal static class Tester { public static string Path => -#if NET6_0 && DEBUG - "../../../../SimpleExecTester/bin/Debug/net6.0/SimpleExecTester.dll"; -#endif -#if NET6_0 && RELEASE - "../../../../SimpleExecTester/bin/Release/net6.0/SimpleExecTester.dll"; -#endif #if NET8_0 && DEBUG $"../../../../SimpleExecTester/bin/Debug/net8.0/SimpleExecTester.dll"; #endif #if NET8_0 && RELEASE $"../../../../SimpleExecTester/bin/Release/net8.0/SimpleExecTester.dll"; #endif +#if NET9_0 && DEBUG + "../../../../SimpleExecTester/bin/Debug/net9.0/SimpleExecTester.dll"; +#endif +#if NET9_0 && RELEASE + "../../../../SimpleExecTester/bin/Release/net9.0/SimpleExecTester.dll"; +#endif } diff --git a/SimpleExecTests/SimpleExecTests.csproj b/SimpleExecTests/SimpleExecTests.csproj index 2bf88b6..2eff25e 100644 --- a/SimpleExecTests/SimpleExecTests.csproj +++ b/SimpleExecTests/SimpleExecTests.csproj @@ -2,8 +2,10 @@ default + + $(NoWarn);CA1515 major - net6.0;net8.0 + net8.0;net9.0 diff --git a/global.json b/global.json index fb5108f..aad16d8 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.100", + "version": "9.0.100", "rollForward": "latestMajor" } }