Skip to content
/ uuid Public

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

License

Notifications You must be signed in to change notification settings

libanvl/uuid

Repository files navigation

.NET 6 CodeQL Nuget (with prereleases)

libanvl.UUID

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

Requirements

.NET 6

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 V (5) Namespaced UUIDs
  • Generates Version IV (4) "Random" 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

Examples

public Guid GetWindowsTerminalNamespacedProfileGuid(string profileName)
{
    Guid terminalNamespace = new("2BDE4A90-D05F-401C-9492-E40884EAD1D8");
    return UUID.V(terminalNamespace, profileName);
}

public Guid GetWindowsTerminalNamespacedFragmentProfileGuid(string fragmentName, string profileName)
{
    Guid fragmentNamespace = new("f65ddb7e-706b-4499-8a50-40313caf510a");
    // Guid can be implicitly converted to UUID with endianess that matches the platform
    UUID fragmentUUID = UUID.V(fragmentNamespace, fragmentName);
    return UUID.V(fragmentUUID, profileName);
}

public UUID GetBigEndianUUID(UUID value)
{
    if (value.IsLittleEndian)
    {
        value = value.EndianSwap()
    }

    return value;
}

About

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

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages