diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index ae411ec..6e90fa3 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
- dotnet: [ '3.1.x', '6.0.x' ]
+ dotnet: [ '3.1.x' ]
name: .NET ${{ matrix.dotnet }}
steps:
@@ -25,6 +25,6 @@ jobs:
- name: Restore dependencies
run: dotnet restore
- name: Build
- run: dotnet build ./UUIDUtil --no-restore
+ run: dotnet build --configuration Release --no-restore
- name: Test
- run: dotnet test ./UUIDUtil --no-build --verbosity normal
+ run: dotnet test --no-restore --verbosity normal
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 41a79ae..86e1cbe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+## [v1.1.0] - 2022-05-31
+[v1.1.0](https://github.com/TensionDev/UUIDUtil/releases/tag/v1.1.0)
+
+### Added
+- Added support to convert System.Guid to TensionDev.UUID.Uuid and vice-versa.
+
+
## [v1.0.0] - 2022-03-26
[v1.0.0](https://github.com/TensionDev/UUIDUtil/releases/tag/v1.0.0)
diff --git a/UUIDUtil/UUIDUtil.csproj b/UUIDUtil/UUIDUtil.csproj
index d32e5ed..dd9e11d 100644
--- a/UUIDUtil/UUIDUtil.csproj
+++ b/UUIDUtil/UUIDUtil.csproj
@@ -7,7 +7,7 @@
true
true
TensionDev.UUID
- 1.0.0
+ 1.1.0
TensionDev amsga
TensionDev
TensionDev.UUID
@@ -20,8 +20,8 @@
UUID GUID
Release with UUID / GUID Version 1, Version 3, Version 4 and Version 5.
en-SG
- 1.0.0.0
- 1.0.0.0
+ 1.1.0.0
+ 1.1.0.0
true
snupkg
diff --git a/UUIDUtil/Uuid.cs b/UUIDUtil/Uuid.cs
index ff71f39..a006990 100644
--- a/UUIDUtil/Uuid.cs
+++ b/UUIDUtil/Uuid.cs
@@ -317,6 +317,45 @@ public byte[] ToByteArray()
return vs;
}
+ ///
+ /// Returns the System.Guid equivalent of this instance.
+ ///
+ /// A System.Guid object.
+ public Guid ToGuid()
+ {
+ return new Guid(ToString());
+ }
+
+ ///
+ /// Return the Variant 2 version in System.Guid.
+ ///
+ /// A System.Guid object.
+ public Guid ToVariant2()
+ {
+ byte newClockSeq = (byte)(_clock_seq_hi_and_reserved & 0x1F);
+ newClockSeq = (byte)(newClockSeq | 0xC0);
+ Uuid variant2 = new Uuid(this.ToByteArray());
+
+ variant2._clock_seq_hi_and_reserved = newClockSeq;
+
+ return variant2.ToGuid();
+ }
+
+ ///
+ /// Returns the Variant 1 version in TensionDev.UUID.Uuid.
+ ///
+ /// The System.Guid object to convert.
+ /// A TensionDev.UUID.Uuid object.
+ public static Uuid ToVariant1(Guid guid)
+ {
+ Uuid variant1 = new Uuid(guid.ToString());
+ byte newClockSeq = (byte)(variant1._clock_seq_hi_and_reserved & 0x3F);
+ newClockSeq = (byte)(newClockSeq | 0x80);
+ variant1._clock_seq_hi_and_reserved = newClockSeq;
+
+ return variant1;
+ }
+
///
/// Returns a string representation of the value of this instance as per RFC 4122 Section 3.
///
diff --git a/XUnitTestProjectUUID/UnitTestUuid.cs b/XUnitTestProjectUUID/UnitTestUuid.cs
index 5553667..273b3fe 100644
--- a/XUnitTestProjectUUID/UnitTestUuid.cs
+++ b/XUnitTestProjectUUID/UnitTestUuid.cs
@@ -199,6 +199,36 @@ public void TestToByteArray3()
Assert.Equal(expected, actual);
}
+ [Fact]
+ public void TestToGuid()
+ {
+ Guid expected = new Guid("7d444840-9dc0-11d1-b245-5ffdce74fad2");
+ TensionDev.UUID.Uuid uuid = new TensionDev.UUID.Uuid("7d444840-9dc0-11d1-b245-5ffdce74fad2");
+
+ Guid actual = uuid.ToGuid();
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public void TestToVariant2()
+ {
+ Guid expected = new Guid("7d444840-9dc0-11d1-d245-5ffdce74fad2");
+ TensionDev.UUID.Uuid uuid = new TensionDev.UUID.Uuid("7d444840-9dc0-11d1-b245-5ffdce74fad2");
+
+ Guid actual = uuid.ToVariant2();
+ Assert.Equal(expected, actual);
+ }
+
+ [Fact]
+ public void TestToVariant1()
+ {
+ TensionDev.UUID.Uuid expected = new TensionDev.UUID.Uuid("7d444840-9dc0-11d1-9245-5ffdce74fad2");
+ Guid guid = new Guid("7d444840-9dc0-11d1-d245-5ffdce74fad2");
+
+ TensionDev.UUID.Uuid actual = TensionDev.UUID.Uuid.ToVariant1(guid);
+ Assert.Equal(expected, actual);
+ }
+
[Fact]
public void TestToString1()
{