Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 41 additions & 21 deletions .github/workflows/build-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 1 addition & 7 deletions src/FastIDs.TypeId/TypeId.Core/Base32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,6 @@ public static bool IsValid(ReadOnlySpan<char> input)

private static bool IsValidAlphabet(ReadOnlySpan<char> chars)
{
foreach (var c in chars)
{
if (!Base32Constants.AlphabetValues.Contains(c))
return false;
}

return true;
return !chars.ContainsAnyExcept(Base32Constants.AlphabetValues);
}
}
2 changes: 1 addition & 1 deletion src/FastIDs.TypeId/TypeId.Core/TypeId.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<WarningsAsErrors>Nullable</WarningsAsErrors>
Expand All @@ -22,6 +21,7 @@
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Copyright>Copyright (c) Mykhailo Matviiv 2023.</Copyright>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/FastIDs.TypeId/TypeId.Core/TypeIdDecoded.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ namespace FastIDs.TypeId;
[StructLayout(LayoutKind.Auto)]
public readonly struct TypeIdDecoded : IEquatable<TypeIdDecoded>, ISpanFormattable, IUtf8SpanFormattable, IComparable<TypeIdDecoded>, IComparable
{
#if !NET10_0_OR_GREATER
private static readonly UuidGenerator UuidGenerator = new();
#endif

/// <summary>
/// The type part of the TypeId.
Expand Down
11 changes: 10 additions & 1 deletion src/FastIDs.TypeId/TypeId.Core/Uuid/UuidGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -114,4 +122,5 @@ private static ushort GetSequenceSeed()
buffer[0] &= 0b0000_0111;
return BinaryPrimitives.ReadUInt16BigEndian(buffer);
}
}
}
#endif
Loading