Skip to content

Repository files navigation

CICodeQLNuGet (with prereleases)

libanvl.UUID

libanvl.UUID is an immutable, endian-aware UUID library for .NET. It supports generating Version IV (4), Version V (5), Version VII (7), and Version VIII (8) UUIDs. This library is designed to be highly performant and easy to use, providing seamless integration with .NET applications.

Requirements

Installation

You can install the libanvl.UUID library via NuGet:

dotnet add package libanvl.uuid

For CI builds, you can use the GitHub feed:

dotnet nuget add source --username USERNAME --password TOKEN --store-password-in-clear-text --name github "https://nuget.pkg.github.com/libanvl/index.json" dotnet add package libanvl.uuid --prerelease

Releases

  • NuGet packages are available on NuGet.org
    • Embedded debug symbols
    • Source Link enabled
  • NuGet packages from CI builds are available on the libanvl GitHub feed

Features

  • Immutable
  • Endian-aware
  • Generates Version IV (4) "Random" UUIDs
  • Generates Version V (5) Namespaced UUIDs
  • Generates Version VII (7) "Unix Timestamp" UUIDs
  • Generates Version VIII (8) "Custom" UUIDs
  • Implicit conversion to and from System.Guid
    • Conversion to System.Guid always follows platform endianess
  • Implicit conversion from byte[] and ReadOnlyMemory<byte>
  • Copy to new byte[]
  • Property access to all five UUID records
  • No signed ints in the API
  • Enumerable as a sequence of bytes
  • More constructors than you can shake a stick at

Usage

Here are some examples of how to use the libanvl.UUID library:

Generate a Namespaced UUID

publicGuidGetWindowsTerminalNamespacedProfileGuid(stringprofileName){GuidterminalNamespace=new("2BDE4A90-D05F-401C-9492-E40884EAD1D8");returnUUID.V(terminalNamespace,profileName);}

Generate a Fragmented Namespaced UUID

publicGuidGetWindowsTerminalNamespacedFragmentProfileGuid(stringfragmentName,stringprofileName){GuidfragmentNamespace=new("f65ddb7e-706b-4499-8a50-40313caf510a");// Guid can be implicitly converted to UUID with endianess that matches the platformUUIDfragmentUUID=UUID.V(fragmentNamespace,fragmentName);returnUUID.V(fragmentUUID,profileName);}

Convert to Big Endian UUID

publicUUIDGetBigEndianUUID(UUIDvalue){if(value.IsLittleEndian){value=value.EndianSwap()}returnvalue;}

About

Immutable, endian-aware UUID library for .NET. Also generates Version V (5) and Version IV (4) UUIDs.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages