From e50a32d93ab745ffe3d5893ac587fd1d7ee8b148 Mon Sep 17 00:00:00 2001 From: Mykhailo Matviiv Date: Tue, 20 Jan 2026 01:00:45 +0100 Subject: [PATCH 1/3] Use .NET10 UUIDv7 generation in .NET10 builds --- src/FastIDs.TypeId/TypeId.Core/TypeId.Core.csproj | 2 +- src/FastIDs.TypeId/TypeId.Core/TypeIdDecoded.cs | 2 ++ src/FastIDs.TypeId/TypeId.Core/Uuid/UuidGenerator.cs | 11 ++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/FastIDs.TypeId/TypeId.Core/TypeId.Core.csproj b/src/FastIDs.TypeId/TypeId.Core/TypeId.Core.csproj index f430549..8835d48 100644 --- a/src/FastIDs.TypeId/TypeId.Core/TypeId.Core.csproj +++ b/src/FastIDs.TypeId/TypeId.Core/TypeId.Core.csproj @@ -1,7 +1,6 @@ - net8.0 enable enable Nullable @@ -22,6 +21,7 @@ true snupkg Copyright (c) Mykhailo Matviiv 2023. + net8.0;net10.0 diff --git a/src/FastIDs.TypeId/TypeId.Core/TypeIdDecoded.cs b/src/FastIDs.TypeId/TypeId.Core/TypeIdDecoded.cs index e66d928..fdf8078 100644 --- a/src/FastIDs.TypeId/TypeId.Core/TypeIdDecoded.cs +++ b/src/FastIDs.TypeId/TypeId.Core/TypeIdDecoded.cs @@ -9,7 +9,9 @@ namespace FastIDs.TypeId; [StructLayout(LayoutKind.Auto)] public readonly struct TypeIdDecoded : IEquatable, ISpanFormattable, IUtf8SpanFormattable, IComparable, IComparable { +#if !NET10_0_OR_GREATER private static readonly UuidGenerator UuidGenerator = new(); +#endif /// /// The type part of the TypeId. diff --git a/src/FastIDs.TypeId/TypeId.Core/Uuid/UuidGenerator.cs b/src/FastIDs.TypeId/TypeId.Core/Uuid/UuidGenerator.cs index 21bf13b..35e5211 100644 --- a/src/FastIDs.TypeId/TypeId.Core/Uuid/UuidGenerator.cs +++ b/src/FastIDs.TypeId/TypeId.Core/Uuid/UuidGenerator.cs @@ -4,6 +4,14 @@ namespace FastIDs.TypeId.Uuid; +#if NET10_0_OR_GREATER +internal static class UuidGenerator +{ + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Guid New() => Guid.CreateVersion7(); +} +#else + // The UUIDv7 implementation is extracted from https://github.com/mareek/UUIDNext to prevent transient dependency. // TypeID doesn't require any UUID implementations except UUIDv7. @@ -114,4 +122,5 @@ private static ushort GetSequenceSeed() buffer[0] &= 0b0000_0111; return BinaryPrimitives.ReadUInt16BigEndian(buffer); } -} \ No newline at end of file +} +#endif \ No newline at end of file From 2246e79701a2327f69498c20377780bf0360c11b Mon Sep 17 00:00:00 2001 From: Mykhailo Matviiv Date: Tue, 20 Jan 2026 05:19:38 +0100 Subject: [PATCH 2/3] Optimize ID alphabet check --- src/FastIDs.TypeId/TypeId.Core/Base32.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/FastIDs.TypeId/TypeId.Core/Base32.cs b/src/FastIDs.TypeId/TypeId.Core/Base32.cs index f4af985..4927217 100644 --- a/src/FastIDs.TypeId/TypeId.Core/Base32.cs +++ b/src/FastIDs.TypeId/TypeId.Core/Base32.cs @@ -111,12 +111,6 @@ public static bool IsValid(ReadOnlySpan input) private static bool IsValidAlphabet(ReadOnlySpan chars) { - foreach (var c in chars) - { - if (!Base32Constants.AlphabetValues.Contains(c)) - return false; - } - - return true; + return !chars.ContainsAnyExcept(Base32Constants.AlphabetValues); } } \ No newline at end of file From 0d7e7fbee722443f0d2ef9aaff1e5cab4c5ebe5f Mon Sep 17 00:00:00 2001 From: Mykhailo Matviiv Date: Sat, 24 Jan 2026 15:09:07 +0100 Subject: [PATCH 3/3] Multitarget builds in GH action script --- .github/workflows/build-core.yml | 62 +++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-core.yml b/.github/workflows/build-core.yml index aad541b..d84f488 100644 --- a/.github/workflows/build-core.yml +++ b/.github/workflows/build-core.yml @@ -5,38 +5,58 @@ name: Build Core on: push: - branches: - - main - tags: + branches: [ main ] + tags: - 'typeid-core-v*' paths: - 'src/FastIDs.TypeId/**' pull_request: - branches: - - main + branches: [ main ] paths: - 'src/FastIDs.TypeId/**' jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + dotnet-version: [8, 10] defaults: run: working-directory: ./src/FastIDs.TypeId steps: - - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8 - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --no-restore --configuration Release - - name: Test - run: dotnet test --no-restore --no-build --configuration Release - - name: Publish to NuGet - if: startsWith(github.ref, 'refs/tags/') - run: | - dotnet pack --no-build -c Release ./TypeId.Core -o . - dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} --skip-duplicate + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ matrix.dotnet-version }} + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore --configuration Release + - name: Test + run: dotnet test --no-restore --no-build --configuration Release + + pack-and-push: + runs-on: ubuntu-latest + needs: build + if: startsWith(github.ref, 'refs/tags/') + defaults: + run: + working-directory: ./src/FastIDs.TypeId + steps: + - uses: actions/checkout@v3 + - name: Setup .NET 10 (for packing) + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10 + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore --configuration Release + - name: Pack + run: dotnet pack --no-build -c Release -o ./artifacts + - name: Publish to NuGet + env: + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + run: dotnet nuget push ./artifacts/*.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_API_KEY --skip-duplicate