XstarS.GuidModule
2.13.0
dotnet add package XstarS.GuidModule --version 2.13.0
NuGet\Install-Package XstarS.GuidModule -Version 2.13.0
<PackageReference Include="XstarS.GuidModule" Version="2.13.0" />
<PackageVersion Include="XstarS.GuidModule" Version="2.13.0" />
<PackageReference Include="XstarS.GuidModule" />
paket add XstarS.GuidModule --version 2.13.0
#r "nuget: XstarS.GuidModule, 2.13.0"
#:package XstarS.GuidModule@2.13.0
#addin nuget:?package=XstarS.GuidModule&version=2.13.0
#tool nuget:?package=XstarS.GuidModule&version=2.13.0
F# GUID Module
Provides RFC 4122 (UUID) and RFC 9562 (UUIDREV) compliant GUID operations for F#. The orders of input parameters are adjusted to match F# pipeline patterns.
Features:
- Full support for generating GUID version 1 through 8.
- Support for getting and setting fields of GUID version 1 through 8.
- Fully compatible with Native AOT (including reflection-free mode).
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.
RFC 9562 UUID Standard
RFC 9562 defines the following three versions of UUID:
- Version 6: The reordered time-based version, field-compatible with Version 1 except that the timestamp is reordered to big-endian order.
- Version 7: The Unix Epoch time-based version, contains a 48-bit timestamp and a 74-bit random number, field-compatible with ULID.
- Version 8: Reserved for custom UUID formats, fields except the variant and version are user-defined.
There is also a special Max UUID whose bytes are all 0xffs, which is equivalent to Guid.AllBitsSet in .NET 9.0 or greater.
F# GUID Module Usage
Core module: XNetEx.FSharp.Core.Guid.
RFC-compliant GUID Generation
open System
open XNetEx.FSharp.Core
// Load generator state from file.
let loadResult = Guid.loadState "state.bin"
// Generate time-based GUID.
let guidV1 = Guid.newV1 () // 3944a871-aa14-11ed-8791-a9a9a46de54f
// Generate randomized GUID.
let guidV4 = Guid.newV4 () // 0658f02d-45a4-4c25-b9d0-8ddbda3c3e08
// Generate Unix time-based GUID.
let guidV7 = Guid.newV7 () // 018640c6-0dc9-7189-a644-31acdba4cabc
// Generate name-based GUID.
let guidV3 = Guid.newV3S Guid.nsDns "github.com"
// 7f4771a0-1982-373d-928f-d31140a51652
let guidV5 = "github.com" |> Guid.newV5S Guid.nsDns
// 6fca3dd2-d61d-58de-9363-1574b382ea68
// Build custom state time-based GUID sequence.
let guidV1CSeq =
Guid.customStateSeq Guid.Version.Version1 {
timeFunc (fun () -> DateTime.UtcNow + TimeSpan.FromHours(8))
clockSeq 0x0123s
nodeId (Array.init 6 (((+) 1) >> byte))
}
let guidV1C = guidV1CSeq |> Seq.head
// 2a85a1d1-14c5-11f0-8123-010203040506
// Build time-based GUID.
let guid6 =
Guid.emptyOf Guid.Version.Version6
|> Guid.replaceTime DateTime.UtcNow
|> Guid.replaceClockSeq 0x0123s
|> Guid.replaceNodeId (Array.init 6 (((+) 1) >> byte))
// 1edaa178-dec2-6054-8123-010203040506
// Build Unix time-based GUID.
let guid7 =
Guid.newV4 ()
|> Guid.replaceVersion Guid.Version.Version7
|> Guid.replaceTime DateTime.UtcNow
// 018640db-de47-7ab9-bf00-6119a1033265
Common GUID Operations
open XNetEx.FSharp.Core
// GUID parsing and formatting.
let guid1 = Guid.parse "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
let guid2 = "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}" |> Guid.parseExact "B"
printfn "%s" (guid2 |> Guid.format "X")
// GUID construction and deconstruction.
let guid3 =
Guid.ofFields
0x00112233 0x4455s 0x6677s (0x88uy, 0x99uy)
(0xAAuy, 0xBBuy, 0xCCuy, 0xDDuy, 0xEEuy, 0xFFuy)
let guid3Fields = guid3 |> Guid.toFields
let guid4 =
Array.map byte
[| 0x00; 0x11; 0x22; 0x33; 0x44; 0x55; 0x66; 0x77
0x88; 0x99; 0xAA; 0xBB; 0xCC; 0xDD; 0xEE; 0xFF |]
|> Guid.ofBytesUuid
let guid4Bytes = Guid.toBytes guid4
assert (guid3 = guid4)
let guid5 =
Array.map byte
[| 0x33; 0x22; 0x11; 0x00; 0x55; 0x44; 0x77; 0x66
0x88; 0x99; 0xAA; 0xBB; 0xCC; 0xDD; 0xEE; 0xFF |]
|> Guid.ofBytes
let guid5Bytes = Guid.toBytesUuid guid5
assert (guid3 = guid5)
| 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 is compatible. 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 is compatible. |
| .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
- FSharp.Core (>= 6.0.0)
- XstarS.GuidGenerators (>= 2.13.0)
-
.NETStandard 2.1
- FSharp.Core (>= 6.0.0)
- XstarS.GuidGenerators (>= 2.13.0)
-
net8.0
- FSharp.Core (>= 6.0.0)
- XstarS.GuidGenerators (>= 2.13.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.13.0 | 82 | 2/6/2026 |
| 2.12.0 | 140 | 12/13/2025 |
| 2.11.0 | 220 | 11/25/2025 |
| 2.10.0 | 223 | 11/22/2025 |
| 2.10.0-preview | 418 | 11/20/2025 |
| 2.9.0 | 231 | 6/21/2025 |
| 2.8.0 | 275 | 4/30/2025 |
| 2.7.0 | 221 | 4/25/2025 |
| 2.6.1 | 234 | 4/12/2025 |
| 2.6.0 | 247 | 4/11/2025 |
| 1.23.0 | 79 | 2/6/2026 |
| 1.22.0 | 129 | 12/13/2025 |
| 1.21.0 | 202 | 11/25/2025 |
| 1.20.0 | 220 | 11/22/2025 |
| 1.20.0-preview | 410 | 11/20/2025 |
| 1.19.0 | 194 | 6/21/2025 |
| 1.18.0 | 251 | 4/30/2025 |
| 1.17.0 | 211 | 4/25/2025 |
| 1.16.1 | 218 | 4/12/2025 |
| 1.16.0 | 238 | 4/11/2025 |