Skip to content

Commit

Permalink
switch from net6 to net9 and update SDKs
Browse files Browse the repository at this point in the history
  • Loading branch information
adamralph committed Dec 27, 2024
1 parent a18aaf5 commit 5945d19
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 67 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/infer-sharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 0 additions & 21 deletions SimpleExec/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ public static void Run(
.Create(
Resolve(Validate(name)),
args,
#if NET8_0_OR_GREATER
[],
#else
Enumerable.Empty<string>(),
#endif
workingDirectory,
false,
configureEnvironment ?? defaultAction,
Expand Down Expand Up @@ -176,11 +172,7 @@ public static Task RunAsync(
.Create(
Resolve(Validate(name)),
args,
#if NET8_0_OR_GREATER
[],
#else
Enumerable.Empty<string>(),
#endif
workingDirectory,
false,
configureEnvironment ?? defaultAction,
Expand Down Expand Up @@ -296,11 +288,7 @@ private static async Task RunAsync(
.Create(
Resolve(Validate(name)),
args,
#if NET8_0_OR_GREATER
[],
#else
Enumerable.Empty<string>(),
#endif
workingDirectory,
true,
configureEnvironment ?? defaultAction,
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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<string> { name, };
#endif

var path = GetSearchDirectories().SelectMany(_ => searchFileNames, Path.Combine)
.FirstOrDefault(File.Exists);
Expand Down
20 changes: 0 additions & 20 deletions SimpleExec/ExitCodeException.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace SimpleExec;

#if NET8_0_OR_GREATER
/// <summary>
/// The command exited with an unexpected exit code.
/// </summary>
Expand All @@ -13,25 +12,6 @@ public class ExitCodeException(int exitCode) : Exception
/// Gets the exit code of the command.
/// </summary>
public int ExitCode { get; } = exitCode;
#else
/// <summary>
/// The command exited with an unexpected exit code.
/// </summary>
#pragma warning disable CA1032 // Implement standard exception constructors
public class ExitCodeException : Exception
#pragma warning restore CA1032 // Implement standard exception constructors
{
/// <summary>
/// Constructs an instance of a <see cref="ExitCodeException"/>.
/// </summary>
/// <param name="exitCode">The exit code of the command.</param>
public ExitCodeException(int exitCode) => this.ExitCode = exitCode;

/// <summary>
/// Gets the exit code of the command.
/// </summary>
public int ExitCode { get; }
#endif

/// <inheritdoc/>
public override string Message => $"The command exited with code {this.ExitCode}.";
Expand Down
2 changes: 1 addition & 1 deletion SimpleExec/SimpleExec.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReleaseNotes>https://github.com/adamralph/simple-exec/blob/main/CHANGELOG.md</PackageReleaseNotes>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion SimpleExecTester/SimpleExecTester.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<LangVersion>default</LangVersion>
<OutputType>Exe</OutputType>
<RollForward>major</RollForward>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

</Project>
12 changes: 0 additions & 12 deletions SimpleExecTests/CancellingCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions SimpleExecTests/Infra/Tester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 3 additions & 1 deletion SimpleExecTests/SimpleExecTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

<PropertyGroup>
<LangVersion>default</LangVersion>
<!-- https://github.com/dotnet/roslyn-analyzers/issues/7192 -->
<NoWarn>$(NoWarn);CA1515</NoWarn>
<RollForward>major</RollForward>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"version": "9.0.100",
"rollForward": "latestMajor"
}
}

0 comments on commit 5945d19

Please sign in to comment.