diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..09d7c60 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +# Store text files with LF in the repository and check them out with the platform's line ending (CRLF on Windows). +* text=auto + +*.png binary diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 7ba4c31..12d55e1 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -4,26 +4,24 @@ on: push: branches: - master - pull_request: - branches: - - master -defaults: - run: - working-directory: src +permissions: + contents: read jobs: - build-test-publish: + build-test: runs-on: ubuntu-latest + defaults: + run: + working-directory: src steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: Setup .NET - uses: actions/setup-dotnet@v5 + uses: actions/setup-dotnet@v6 with: - dotnet-version: | - 8.0.x - 9.0.x + dotnet-version: | 10.0.x + 11.0.x - name: Restore dependencies run: dotnet restore @@ -38,14 +36,34 @@ jobs: run: dotnet pack -c Release --no-restore --no-build --output ~/nuget-packages - name: Upload Build Artifact(s) - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: nuget-packages path: ~/nuget-packages + # A separate job, so restore, build and tests never run with the OIDC token permission. + publish: + needs: build-test + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - name: Download Build Artifact(s) + uses: actions/download-artifact@v8 + with: + name: nuget-packages + path: nuget-packages + + # Exchanges the GitHub OIDC token for an API key that is valid for one hour. + - name: NuGet Login + id: login + uses: NuGet/login@v1 + with: + user: Fortnite-API + - name: Push NuGet Package(s) run: | - dotnet nuget push ~/nuget-packages/*.nupkg \ + dotnet nuget push nuget-packages/*.nupkg \ --source https://api.nuget.org/v3/index.json \ - --api-key ${{ secrets.NUGET_API_KEY }} \ + --api-key ${{ steps.login.outputs.NUGET_API_KEY }} \ --skip-duplicate diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0799d81 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,34 @@ +name: Test + +on: + pull_request: + branches: + - master + +permissions: + contents: read + +defaults: + run: + working-directory: src + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - name: Setup .NET + uses: actions/setup-dotnet@v6 + with: + dotnet-version: | + 10.0.x + 11.0.x + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build -c Release --no-restore + + - name: Run Tests + run: dotnet test -c Release --no-restore --no-build -v normal diff --git a/LICENSE b/LICENSE index d30311f..7f97c0a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2025 NotOfficer +Copyright (c) 2026 NotOfficer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Directory.Build.props b/src/Directory.Build.props index fe3e645..facde53 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,6 +1,6 @@ - net10.0;net9.0;net8.0 + net10.0;net11.0 enable enable true @@ -14,7 +14,7 @@ en NotOfficer - Copyright (c) 2025 NotOfficer + Copyright (c) 2026 NotOfficer diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 6f88828..795ae2f 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -3,9 +3,9 @@ true - - - - + + + + \ No newline at end of file diff --git a/src/GenericReader.Tests/GenericReader.Tests.csproj b/src/GenericReader.Tests/GenericReader.Tests.csproj index edaf586..383cc7f 100644 --- a/src/GenericReader.Tests/GenericReader.Tests.csproj +++ b/src/GenericReader.Tests/GenericReader.Tests.csproj @@ -6,7 +6,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/GenericReader.Tests/Tests.cs b/src/GenericReader.Tests/Tests.cs index 0f112f2..dae51bd 100644 --- a/src/GenericReader.Tests/Tests.cs +++ b/src/GenericReader.Tests/Tests.cs @@ -5,7 +5,6 @@ namespace GenericReader.Tests; -#if NET9_0_OR_GREATER public class SpanReaderTests : IClassFixture> { private readonly BinaryDataGenerator _gen; @@ -22,7 +21,6 @@ public void ReadAll() _gen.Test(ref reader); } } -#endif public class BufferReaderTests : IClassFixture> { @@ -91,10 +89,7 @@ public void Dispose() } } -public class BinaryDataGenerator where TReader : IGenericReader -#if NET9_0_OR_GREATER - , allows ref struct -#endif +public class BinaryDataGenerator where TReader : IGenericReader, allows ref struct { public byte[] Data { get; } @@ -129,16 +124,9 @@ public void Test(ref TReader reader) } } -public delegate bool VerifyFunc(ref TReader reader) where TReader : IGenericReader -#if NET9_0_OR_GREATER - , allows ref struct -#endif -; +public delegate bool VerifyFunc(ref TReader reader) where TReader : IGenericReader, allows ref struct; -public class BinaryDataValues where TReader : IGenericReader -#if NET9_0_OR_GREATER - , allows ref struct -#endif +public class BinaryDataValues where TReader : IGenericReader, allows ref struct { public List Values { get; } public List> VerifyOperations { get; } diff --git a/src/GenericReader/GenericSpanReader.cs b/src/GenericReader/GenericSpanReader.cs index f19585e..f554dd2 100644 --- a/src/GenericReader/GenericSpanReader.cs +++ b/src/GenericReader/GenericSpanReader.cs @@ -1,5 +1,4 @@ -#if NET9_0_OR_GREATER -using System.Numerics; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; @@ -442,4 +441,3 @@ public Span ReadSpan(int length) where T : struct public void Dispose() { } } -#endif diff --git a/src/GenericReader/IGenericReader.cs b/src/GenericReader/IGenericReader.cs index 3f84f70..19f3b0f 100644 --- a/src/GenericReader/IGenericReader.cs +++ b/src/GenericReader/IGenericReader.cs @@ -12,10 +12,8 @@ public interface IGenericReader : IDisposable public static GenericBufferReader Create(ReadOnlyMemory memory) => new(memory); public static GenericBufferReader Create(Memory memory) => new(memory); -#if NET9_0_OR_GREATER public static GenericSpanReader Create(ReadOnlySpan span) => new(span); public static GenericSpanReader Create(Span span) => new(span); -#endif public static GenericFileReader Create(string filePath) => new(filePath); public static GenericFileReader Create(SafeFileHandle handle) => new(handle); diff --git a/src/global.json b/src/global.json new file mode 100644 index 0000000..3140116 --- /dev/null +++ b/src/global.json @@ -0,0 +1,5 @@ +{ + "test": { + "runner": "Microsoft.Testing.Platform" + } +}