Skip to content

Commit

Permalink
Update testing to include .NET 7 and .NET 8 and add AOT annotations (#12
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Shane32 committed Jan 9, 2024
1 parent 6c72c2e commit 43ad68a
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 19 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use .NET Core 6.0 SDK
uses: actions/setup-dotnet@v3
- uses: actions/checkout@v4
- name: Use .NET Core 8.0 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'
source-url: https://nuget.pkg.github.com/Shane32/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand All @@ -27,7 +27,7 @@ jobs:
- name: Pack solution [Release]
run: dotnet pack --no-restore --no-build -c Release -p:VersionSuffix=$GITHUB_RUN_NUMBER -o out
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Nuget packages
path: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Check github.ref starts with 'refs/tags/'
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: |
Expand All @@ -23,10 +23,10 @@ jobs:
version="${github_ref:10}"
echo version=$version
echo "version=$version" >> $GITHUB_ENV
- name: Use .NET Core 6.0 SDK
uses: actions/setup-dotnet@v3
- name: Use .NET Core 8.0 SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'
source-url: https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.NUGET_AUTH_TOKEN}}
Expand All @@ -37,15 +37,15 @@ jobs:
- name: Pack solution [Release]
run: dotnet pack --no-restore --no-build -c Release -p:Version=$version -o out
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Nuget packages
path: |
out/*
- name: Publish Nuget packages to Nuget registry
run: dotnet nuget push "out/*" -k ${{secrets.NUGET_AUTH_TOKEN}}
- name: Upload nuget packages as release artifacts
uses: actions/github-script@v2
uses: actions/github-script@v4
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ jobs:
- windows-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Use .NET Core SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
2.1.x
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
source-url: https://nuget.pkg.github.com/Shane32/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down Expand Up @@ -58,7 +60,8 @@ jobs:
reporttypes: 'Html'
tag: 'test_${{ github.run_number }}'
- name: Upload artifacts
uses: actions/upload-artifact@v2
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v4
with:
name: Code coverage artifacts
path: |
Expand Down
4 changes: 4 additions & 0 deletions src/AsyncResetEvents/AsyncAutoResetEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ public Task WaitAsync(CancellationToken cancellationToken = default)
public Task<bool> WaitAsync(int millisecondsTimeout, CancellationToken cancellationToken = default)
{
// validate arguments
#if NET8_0_OR_GREATER
ArgumentOutOfRangeException.ThrowIfLessThan(millisecondsTimeout, -1);
#else
if (millisecondsTimeout < -1)
throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout));
#endif

// if the cancellation token is signaled, throw immediately
#if NETSTANDARD1_0
Expand Down
10 changes: 10 additions & 0 deletions src/AsyncResetEvents/AsyncMessagePump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,13 @@ private static async Task ExecuteDelegateAsync(Task<T> executeDelegate, Func<T,
/// </summary>
public AsyncMessagePump(Func<T, Task> callback)
{
#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(callback);
#else
if (callback == null)
throw new ArgumentNullException(nameof(callback));
#endif
_wrappedCallback = async obj => {
try {
await callback(obj).ConfigureAwait(false);
Expand All @@ -103,8 +108,13 @@ public AsyncMessagePump(Action<T> callback)

private static Func<T, Task> ConvertCallback(Action<T> callback)
{
#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(callback);
#else
if (callback == null)
throw new ArgumentNullException(nameof(callback));
#endif

return message => {
callback(message);
#if NETSTANDARD1_0
Expand Down
11 changes: 10 additions & 1 deletion src/AsyncResetEvents/Shane32.AsyncResetEvents.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard1.0;netstandard1.3;netstandard2.0;netstandard2.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard1.0;netstandard1.3;netstandard2.0;netstandard2.1;net5.0;net6.0;net8.0</TargetFrameworks>
<Description>
Task-based implementations of ManualResetEvent and AutoResetEvent
</Description>
Expand All @@ -11,6 +11,15 @@
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<IsAotCompatible>true</IsAotCompatible>
<AnalysisLevel>8.0-recommended</AnalysisLevel>
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="Tests"/>
</ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/AsyncResetEvents/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ internal static class TaskExtensions

public static Task<bool> WaitOrFalseAsync(this Task<bool> task, int millisecondsTimeout, CancellationToken cancellationToken)
{
#if NET8_0_OR_GREATER
ArgumentOutOfRangeException.ThrowIfLessThan(millisecondsTimeout, -1);
#else
if (millisecondsTimeout < -1)
throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout));
#endif
if (task.IsCompleted || (millisecondsTimeout == -1 && !cancellationToken.CanBeCanceled))
return task;
if (millisecondsTimeout == 0)
Expand Down
8 changes: 4 additions & 4 deletions src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsPackable>false</IsPackable>
<LangVersion>10.0</LangVersion>
<NoWarn>$(NoWarn);1701;1702;1591;IDE1006;IDE0060;0618;CS1998</NoWarn>
<NoWarn>$(NoWarn);1701;1702;1591;IDE1006;IDE0060;0618;CS1998;NU1902;NU1903</NoWarn>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' != 'true'">
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net48;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net48;net461;net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 43ad68a

Please sign in to comment.