Baubit.Identity
2025.51.1
dotnet add package Baubit.Identity --version 2025.51.1
NuGet\Install-Package Baubit.Identity -Version 2025.51.1
<PackageReference Include="Baubit.Identity" Version="2025.51.1" />
<PackageVersion Include="Baubit.Identity" Version="2025.51.1" />
<PackageReference Include="Baubit.Identity" />
paket add Baubit.Identity --version 2025.51.1
#r "nuget: Baubit.Identity, 2025.51.1"
#:package Baubit.Identity@2025.51.1
#addin nuget:?package=Baubit.Identity&version=2025.51.1
#tool nuget:?package=Baubit.Identity&version=2025.51.1
Baubit.Identity
A monotonic GuidV7 (UUIDv7) generator for .NET. Generates strictly increasing unique identifiers for distributed systems.
Features
- Interface-based Design:
IIdentityGeneratorinterface for abstraction and testability - Monotonic Guarantees: Strictly increasing UUIDv7 identifiers, even at the same millisecond
- Thread-Safe: Lock-free implementation using atomic operations
- Drift Protection: Optional drift cap for clock skew handling
- Timestamp Extraction: Extract Unix milliseconds from GuidV7 values
- Zero Dependencies: No external dependencies
- RFC 9562 Compliant: Follows UUIDv7 specification
Installation
dotnet add package Baubit.Identity
Quick Start
using Baubit.Identity;
// Create a generator using the interface
IIdentityGenerator generator = IdentityGenerator.CreateNew();
// Generate monotonic GuidV7 values
var id1 = generator.GetNext();
var id2 = generator.GetNext();
// id1 < id2 (strictly increasing)
// Seed from existing GUID or timestamp
var existingId = GuidV7.CreateVersion7();
generator.InitializeFrom(existingId);
// Or seed from timestamp
generator.InitializeFrom(DateTimeOffset.UtcNow.AddHours(-1));
// Create UUIDv7 directly
var guid = GuidV7.CreateVersion7();
// Extract timestamp
if (GuidV7.TryGetUnixMs(guid, out long ms))
{
var time = DateTimeOffset.FromUnixTimeMilliseconds(ms);
}
API Reference
IIdentityGenerator (Interface)
GetNext()- Generate next monotonic GUID using current UTC timeGetNext(DateTimeOffset timestampUtc)- Generate monotonic GUID with specific timestampInitializeFrom(Guid existingV7)- Seed from existing version 7 GUIDInitializeFrom(DateTimeOffset timestampUtc)- Seed from specific UTC timestamp
IdentityGenerator
CreateNew(long? maxDriftMs = null, bool throwOnDriftCap = false)- Create generator with optional drift protectionCreateNew(Guid existingV7, long? maxDriftMs = null, bool throwOnDriftCap = false)- Create generator seeded from existing UUIDv7GetNext()- Generate next monotonic GUIDGetNext(DateTimeOffset timestampUtc)- Generate monotonic GUID with specific timestampInitializeFrom(Guid existingV7)- Seed from existing version 7 GUIDInitializeFrom(DateTimeOffset timestampUtc)- Seed from specific UTC timestamp
GuidV7 (Static)
CreateVersion7()- Create UUIDv7 with current UTC timeCreateVersion7(DateTimeOffset timestamp)- Create UUIDv7 with specific timestampIsVersion7(Guid guid)- Check if GUID is version 7TryGetUnixMs(Guid guid, out long ms)- Extract timestamp from UUIDv7
GuidV7Generator
CreateNew(long? maxDriftMs, bool throwOnDriftCap)- Create generatorCreateNew(Guid existingV7, ...)- Create generator seeded from existing UUIDv7GetNext()- Generate next monotonic GuidV7GetNext(DateTimeOffset timestampUtc)- Generate with specific timestampInitializeFrom(Guid existingV7)- Seed from existing UUIDv7InitializeFrom(DateTimeOffset timestampUtc)- Seed from timestamp
GuidV7Extensions
ExtractTimestampMs(this Guid guid)- Extension to extract timestamp
Performance
Benchmarks comparing Baubit.Identity against .NET 9's built-in Guid.CreateVersion7() (Intel Core Ultra 9 185H, Windows 11):
| Method | Mean | Ratio | Allocated |
|---|---|---|---|
| .NET 9 CreateVersion7() | 67.09 ns | -11% | 0 B |
| Baubit CreateVersion7() | 75.40 ns | baseline | 0 B |
| Baubit Generator GetNext() | 78.54 ns | +4% | 0 B |
Key Highlights:
- Zero allocations - All methods produce zero heap allocations
- Competitive performance - Within 11% of .NET 9's native implementation
- Monotonic guarantee - Generator provides strict ordering at only 4% cost
- .NET Standard 2.0 - Broad compatibility with minimal performance trade-off
For detailed benchmark results, analysis, and hardware specifications, see Performance Report.
Note: Baubit.Identity targets .NET Standard 2.0 for broad compatibility. The implementation uses cryptographically secure random number generation (RandomNumberGenerator) with thread-local caching for zero allocations.
License
MIT License - see LICENSE
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Baubit.Identity:
| Package | Downloads |
|---|---|
|
Baubit.Caching
Thread-safe insertion-ordered cache with O(1) lookups, two-tier storage (bounded L1, unbounded L2), and async enumeration. Provides deletion-resilient iteration, automatic multi-consumer memory management, and zero-latency producer-consumer coordination using GuidV7 time-ordered identifiers. Ideal for event sourcing, audit logs, message queues, and time-series caching scenarios. |
GitHub repositories
This package is not used by any popular GitHub repositories.