XstarS.GuidGenerators 1.7.8

There is a newer version of this package available.
See the version list below for details.
dotnet add package XstarS.GuidGenerators --version 1.7.8                
NuGet\Install-Package XstarS.GuidGenerators -Version 1.7.8                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XstarS.GuidGenerators" Version="1.7.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add XstarS.GuidGenerators --version 1.7.8                
#r "nuget: XstarS.GuidGenerators, 1.7.8"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install XstarS.GuidGenerators as a Cake Addin
#addin nuget:?package=XstarS.GuidGenerators&version=1.7.8

// Install XstarS.GuidGenerators as a Cake Tool
#tool nuget:?package=XstarS.GuidGenerators&version=1.7.8                

.NET GUID Generator

Provides RFC 4122 UUID compliant GUID generators for .NET platform.

RFC 4122 UUID Standard

RFC 4122 defines the following five versions of UUID:

  • Version 1: The time-based version, contains a 60-bit timestamp and a 12-bit MAC address
  • Version 2: DCE Security version, contains a 28-bit timestamp, a 12-bit MAC address and a 32-bit local ID
  • Version 3: The name-based version, using MD5 hashing to compute the hash of the namespace and name
  • Version 4: The randomly or pseudo-randomly generated version, equivalent to Guid.NewGuid() in .NET
  • Version 5: The name-based version, using SHA-1 hashing to compute the hash of the namespace and name

There is also a special Nil UUID whose bytes are all 0x00s, which is equivalent to Guid.Empty in .NET.

GUID Generator Library Usage

Get Generator Instance by Static Properties

using XNetEx.Guids;
using XNetEx.Guids.Generators;

// time-based GUID generation.
var guidV1 = GuidGenerator.Version1.NewGuid();
// 3944a871-aa14-11ed-8791-a9a9a46de54f

// name-based GUID generation.
var guidV5 = GuidGenerator.Version5.NewGuid(GuidNamespaces.Dns, "github.com");
// 6fca3dd2-d61d-58de-9363-1574b382ea68s

Get Generator Instance by the Factory Method

using XNetEx.Guids;
using XNetEx.Guids.Generators;

// generate time-based GUID generation.
var guidV1 = GuidGenerator.OfVersion(1).NewGuid();
// 3944a871-aa14-11ed-8791-a9a9a46de54f

// generate name-based GUID.
var guidV5 = GuidGenerator.OfVersion(5).NewGuid(GuidNamespaces.Dns, "github.com");
// 6fca3dd2-d61d-58de-9363-1574b382ea68s

GUID Generator State Storage

RFC 4122 Section 4.2.1

Optional support and requires configuration to enable:

using System;
using System.IO;
using XNetEx.Guids.Generators;

// listen state storage exceptions.
GuidGenerator.StateStorageException += (sender, e) =>
{
    if ((e.OperationType != FileAccess.Read) ||
        (e.Exception is not FileNotFoundException))
    {
        Console.Error.WriteLine(e.Exception);
    }
};
// set storage file path and load state.
var loadResult = GuidGenerator.SetStateStorageFile("state.bin");

Component-Based GUID Building

using System;
using XNetEx.Guids;

// build time-based GUID.
var guidV1 = Guid.Empty
    .ReplaceVariant(GuidVariant.Rfc4122)
    .ReplaceVersion(GuidVersion.Version1)
    .ReplaceTimestamp(new DateTime(0x08BEFFD14FDBF810, DateTimeKind.Utc))
    .ReplaceClockSequence((short)0x00b4)
    .ReplaceNodeId(new byte[] { 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8 });
    // 6ba7b810-9dad-11d1-80b4-00c04fd430c8
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on XstarS.GuidGenerators:

Package Downloads
XstarS.GuidModule

Provides RFC 4122/9562 compliant GUID operations for F#.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.4.3 68 11/13/2024
2.4.2 132 11/9/2024 2.4.2 is deprecated because it is no longer maintained.
2.4.1 113 10/10/2024
2.4.0 190 5/12/2024
2.4.0-preview 143 4/20/2024
2.3.1 170 3/24/2024
2.3.0 327 2/24/2024
2.2.1 294 2/8/2024
2.2.0 144 1/26/2024
2.1.2 156 1/22/2024
2.1.1 159 1/20/2024
2.1.0 165 1/12/2024
2.0.0 208 12/24/2023
2.0.0-rc-19 170 12/22/2023
2.0.0-rc-16 191 12/12/2023
2.0.0-rc-15 164 12/6/2023
2.0.0-rc-14 185 11/26/2023
2.0.0-rc-12.5 103 10/15/2023
2.0.0-rc-12 142 10/15/2023 2.0.0-rc-12 is deprecated because it has critical bugs.
2.0.0-rc-00 186 7/15/2023
2.0.0-preview-04.5 88 6/4/2023
2.0.0-preview-04 199 5/28/2023
2.0.0-preview-03.8 78 5/20/2023
2.0.0-preview-03.5 76 5/14/2023
2.0.0-preview-03 205 4/15/2023
2.0.0-preview-02.5 102 3/26/2023
2.0.0-preview-02 203 3/4/2023
2.0.0-preview-01 218 2/12/2023
1.14.3 68 11/13/2024
1.14.2 106 11/9/2024
1.14.1 106 10/10/2024
1.14.0 154 5/12/2024
1.14.0-preview 135 4/20/2024
1.13.0 171 2/24/2024
1.12.1 166 2/8/2024
1.12.0 141 1/26/2024
1.11.2 145 1/22/2024
1.11.1 138 1/20/2024
1.11.0 137 1/12/2024
1.10.0 181 12/24/2023
1.9.5 172 12/22/2023
1.9.1 221 12/12/2023
1.9.0 201 12/6/2023
1.8.0 202 11/26/2023
1.7.8 209 10/15/2023
1.7.5 252 6/4/2023
1.7.1 224 5/28/2023
1.7.0 215 5/20/2023
1.6.0 219 5/13/2023
1.5.0 449 2/5/2023
1.4.0 477 1/21/2023
1.3.1 480 1/15/2023
1.3.0 483 12/31/2022
1.2.0 696 9/30/2022
1.1.0 692 8/5/2022
1.0.1 967 7/5/2022
1.0.0 532 7/3/2022