Skip to content

Commit a8e43b1

Browse files
committed
Changed ToVariant1 to ToRfc4122Variant for clarity.
Changed ToVariant2 to ToMicrosoftVariant for clarity.
1 parent 379f392 commit a8e43b1

12 files changed

Lines changed: 160 additions & 57 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [Unreleased]
1010

11+
## [v2.4.0] - 2026-01-30
12+
[v2.4.0](https://github.com/TensionDev/UUIDUtil/releases/tag/v2.4.0)
13+
14+
### Changed
15+
- Changed ToVariant1 to ToRfc4122Variant for clarity.
16+
- Changed ToVariant2 to ToMicrosoftVariant for clarity.
17+
18+
1119
## [v2.3.1] - 2025-07-01
1220
[v2.3.1](https://github.com/TensionDev/UUIDUtil/releases/tag/v2.3.1)
1321

README.md

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,98 @@
1-
# TensionDev.UUID
1+
# TensionDev.UUID
22

33
[![.NET](https://github.com/TensionDev/UUIDUtil/actions/workflows/dotnet.yml/badge.svg)](https://github.com/TensionDev/UUIDUtil/actions/workflows/dotnet.yml)
44
[![Package Release](https://github.com/TensionDev/UUIDUtil/actions/workflows/package-release.yml/badge.svg)](https://github.com/TensionDev/UUIDUtil/actions/workflows/package-release.yml)
55
[![CodeQL](https://github.com/TensionDev/UUIDUtil/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/TensionDev/UUIDUtil/actions/workflows/github-code-scanning/codeql)
66

7-
A project to store UUID functions within a library for future use.
7+
TensionDev.UUID is a .NET library for working with Universally Unique Identifiers (UUIDs).
88
This project references the following documents for implementation.
99
- [Universally unique identifier - Wikipedia](https://en.wikipedia.org/wiki/Universally_unique_identifier)
1010
- [MySQL :: MySQL 8.0 Reference Manual :: 12.24 Miscellaneous Functions](https://dev.mysql.com/doc/refman/8.0/en/miscellaneous-functions.html#function_uuid)
1111
- [rfc4122](https://datatracker.ietf.org/doc/html/rfc4122)
1212
- [rfc9562](https://datatracker.ietf.org/doc/html/rfc9562)
13+
14+
---
15+
16+
## Features
17+
18+
- Support for multiple UUID versions:
19+
- v1 (date-time and MAC address)
20+
- v3 (MD5 namespace name-based)
21+
- v4 (random)
22+
- v5 (SHA-1 namespace name-based)
23+
- v6 (date-time-ordered)
24+
- v7 (Unix time + randomness)
25+
- Converters:
26+
- `ToGuid()` and `FromGuid(Guid)`
27+
- `ToByteArray()` and `FromBytes(byte[])`
28+
- Variant conversions (`ToVariant1`, `ToVariant2`)
29+
- Parsing utilities:
30+
- `Parse(string)`
31+
- `TryParse(string, out Uuid)`
32+
- Formatting options:
33+
- `N`, `D`, `B`, `P` (same as System.Guid)
34+
- Comparison operators:
35+
- `==`, `!=`, `<`, `>`, `<=`, `>=`
36+
- Equality and hashing for dictionary/set usage
37+
- Strict RFC compliance for parsing and validation
38+
39+
---
40+
41+
## Installation
42+
```
43+
dotnet add package TensionDev.UUID
44+
```
45+
46+
---
47+
48+
## Usage Examples
49+
50+
### Generate UUID v1 (date-time and MAC address)
51+
```csharp
52+
using TensionDev.UUID;
53+
54+
Uuid uuid = UUIDv1.NewUUIDv1();
55+
Console.WriteLine(uuid); // Example: 164a714c-0c79-11ec-82a8-0242ac130003
56+
```
57+
58+
### Generate UUID v4 (random)
59+
```csharp
60+
using TensionDev.UUID;
61+
62+
Uuid uuid = UUIDv4.NewUUIDv4();
63+
Console.WriteLine(uuid); // Example: 550e8400-e29b-41d4-a716-446655440000
64+
```
65+
66+
### Generate UUID v5 (SHA-1 namespace name-based)
67+
```csharp
68+
using TensionDev.UUID;
69+
70+
Uuid uuid = UUIDv5.NewUUIDv5(UUIDNamespace.URL, "https://www.contoso.com");
71+
Console.WriteLine(uuid); // Example: 1bf6935b-49e6-54cf-a9c8-51fb21c41b46
72+
```
73+
74+
### Parse and validate
75+
```csharp
76+
using TensionDev.UUID;
77+
78+
bool isValid = Uuid.TryParse("550e8400-e29b-41d4-a716-446655440000", out var parsed);
79+
```
80+
81+
### Byte Conversions
82+
```csharp
83+
using TensionDev.UUID;
84+
85+
byte[] bytes = uuid.ToByteArray();
86+
Uuid fromBytes = Uuid.FromBytes(bytes);
87+
```
88+
89+
### String Formatting
90+
```csharp
91+
using TensionDev.UUID;
92+
93+
Console.WriteLine(uuid.ToString("N")); // 32 hex digits
94+
Console.WriteLine(uuid.ToString("D")); // canonical form
95+
Console.WriteLine(uuid.ToString("B")); // with braces
96+
Console.WriteLine(uuid.ToString("P")); // with parentheses
97+
```
98+

UUIDUtil/UUIDNamespace.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
22
//
3-
// Copyright 2021 TensionDev <TensionDev@outlook.com>
3+
// Copyright 2021 - 2026 TensionDev <TensionDev@outlook.com>
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.

UUIDUtil/UUIDUtil.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1111
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1212
<PackageId>TensionDev.UUID</PackageId>
13-
<Version>2.3.1</Version>
13+
<Version>2.4.0</Version>
1414
<Authors>TensionDev amsga</Authors>
1515
<Company>TensionDev</Company>
1616
<Product>TensionDev.UUID</Product>
17-
<Description>A project to store various UUID functions within a library for future use.</Description>
18-
<Copyright>Copyright (c) TensionDev 2021</Copyright>
17+
<Description>TensionDev.UUID is a .NET library that supports multiple UUID versions (v1, v3, v4, v5, v6, v7) with strict RFC compliance.</Description>
18+
<Copyright>Copyright (c) TensionDev 2021 - 2026</Copyright>
1919
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
2020
<PackageProjectUrl>https://github.com/TensionDev/UUIDUtil</PackageProjectUrl>
2121
<RepositoryUrl>https://github.com/TensionDev/UUIDUtil</RepositoryUrl>

UUIDUtil/UUIDv1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
22
//
3-
// Copyright 2021 TensionDev <TensionDev@outlook.com>
3+
// Copyright 2021 - 2026 TensionDev <TensionDev@outlook.com>
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.

UUIDUtil/UUIDv3.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
22
//
3-
// Copyright 2021 TensionDev <TensionDev@outlook.com>
3+
// Copyright 2021 - 2026 TensionDev <TensionDev@outlook.com>
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.

UUIDUtil/UUIDv4.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
22
//
3-
// Copyright 2021 TensionDev <TensionDev@outlook.com>
3+
// Copyright 2021 - 2026 TensionDev <TensionDev@outlook.com>
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.

UUIDUtil/UUIDv5.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
22
//
3-
// Copyright 2021 TensionDev <TensionDev@outlook.com>
3+
// Copyright 2021 - 2026 TensionDev <TensionDev@outlook.com>
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.

UUIDUtil/UUIDv6.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
22
//
3-
// Copyright 2021 TensionDev <TensionDev@outlook.com>
3+
// Copyright 2021 - 2026 TensionDev <TensionDev@outlook.com>
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.

UUIDUtil/UUIDv7.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
22
//
3-
// Copyright 2021 TensionDev <TensionDev@outlook.com>
3+
// Copyright 2021 - 2026 TensionDev <TensionDev@outlook.com>
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)