Skip to content

Commit 18fa128

Browse files
committed
Changed Classes to static with private fields.
1 parent aa31e7b commit 18fa128

File tree

11 files changed

+200
-76
lines changed

11 files changed

+200
-76
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [Unreleased]
1010

11+
## [v2.1.0] - 2024-06-05
12+
[v2.1.0](https://github.com/TensionDev/UUIDUtil/releases/tag/v2.1.0)
13+
14+
### Changed
15+
- Changed Classes to static with private fields.
16+
17+
1118
## [v2.1.0] - 2024-06-05
1219
[v2.1.0](https://github.com/TensionDev/UUIDUtil/releases/tag/v2.1.0)
1320

UUIDUtil/UUIDUtil.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
88
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
99
<PackageId>TensionDev.UUID</PackageId>
10-
<Version>2.1.1</Version>
10+
<Version>2.2.0</Version>
1111
<Authors>TensionDev amsga</Authors>
1212
<Company>TensionDev</Company>
1313
<Product>TensionDev.UUID</Product>

UUIDUtil/UUIDv1.cs

+6-10
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,14 @@ namespace TensionDev.UUID
2121
/// <summary>
2222
/// Class Library to generate Universally Unique Identifier (UUID) / Globally Unique Identifier (GUID) based on Version 1 (date-time and MAC address).
2323
/// </summary>
24-
public class UUIDv1
24+
public static class UUIDv1
2525
{
26-
protected internal static System.Net.NetworkInformation.PhysicalAddress s_physicalAddress = System.Net.NetworkInformation.PhysicalAddress.None;
27-
protected internal static Int32 s_clock = Int32.MinValue;
28-
protected internal static readonly DateTime s_epoch = new DateTime(1582, 10, 15, 0, 0, 0, DateTimeKind.Utc);
26+
private static System.Net.NetworkInformation.PhysicalAddress s_physicalAddress = System.Net.NetworkInformation.PhysicalAddress.None;
27+
private static Int32 s_clock = Int32.MinValue;
28+
private static readonly DateTime s_epoch = new DateTime(1582, 10, 15, 0, 0, 0, DateTimeKind.Utc);
2929

30-
protected internal static readonly Object s_initLock = new Object();
31-
protected internal static readonly Object s_clockLock = new Object();
32-
33-
protected UUIDv1()
34-
{
35-
}
30+
private static readonly Object s_initLock = new Object();
31+
private static readonly Object s_clockLock = new Object();
3632

3733
/// <summary>
3834
/// Initialises a new GUID/UUID based on Version 1 (date-time and MAC address)

UUIDUtil/UUIDv3.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@ namespace TensionDev.UUID
2323
/// <summary>
2424
/// Class Library to generate Universally Unique Identifier (UUID) / Globally Unique Identifier (GUID) based on Version 3 (MD5 namespace name-based).
2525
/// </summary>
26-
public class UUIDv3
26+
public static class UUIDv3
2727
{
28-
protected UUIDv3()
29-
{
30-
}
31-
3228
/// <summary>
3329
/// Initialises a new GUID/UUID based on Version 3 (MD5 namespace name-based)
3430
/// </summary>

UUIDUtil/UUIDv4.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ namespace TensionDev.UUID
2121
/// <summary>
2222
/// Class Library to generate Universally Unique Identifier (UUID) / Globally Unique Identifier (GUID) based on Version 4 (random).
2323
/// </summary>
24-
public class UUIDv4
24+
public static class UUIDv4
2525
{
26-
protected UUIDv4()
27-
{
28-
}
29-
3026
/// <summary>
3127
/// Initialises a new GUID/UUID based on Version 4 (random)
3228
/// </summary>

UUIDUtil/UUIDv5.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@ namespace TensionDev.UUID
2323
/// <summary>
2424
/// Class Library to generate Universally Unique Identifier (UUID) / Globally Unique Identifier (GUID) based on Version 5 (SHA-1 namespace name-based).
2525
/// </summary>
26-
public class UUIDv5
26+
public static class UUIDv5
2727
{
28-
protected UUIDv5()
29-
{
30-
}
31-
3228
/// <summary>
3329
/// Initialises a new GUID/UUID based on Version 5 (SHA-1 namespace name-based)
3430
/// </summary>

UUIDUtil/UUIDv6.cs

+5-9
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,13 @@ namespace TensionDev.UUID
2121
/// <summary>
2222
/// Class Library to generate Universally Unique Identifier (UUID) / Globally Unique Identifier (GUID) based on Version 6 (date-time).
2323
/// </summary>
24-
public class UUIDv6
24+
public static class UUIDv6
2525
{
26-
protected internal static Int32 s_clock = Int32.MinValue;
27-
protected internal static readonly DateTime s_epoch = new DateTime(1582, 10, 15, 0, 0, 0, DateTimeKind.Utc);
26+
private static Int32 s_clock = Int32.MinValue;
27+
private static readonly DateTime s_epoch = new DateTime(1582, 10, 15, 0, 0, 0, DateTimeKind.Utc);
2828

29-
protected internal static readonly Object s_initLock = new Object();
30-
protected internal static readonly Object s_clockLock = new Object();
31-
32-
protected UUIDv6()
33-
{
34-
}
29+
private static readonly Object s_initLock = new Object();
30+
private static readonly Object s_clockLock = new Object();
3531

3632
/// <summary>
3733
/// Initialises a new GUID/UUID based on Version 6 (date-time)

UUIDUtil/UUIDv7.cs

+4-8
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,12 @@ namespace TensionDev.UUID
2222
/// <summary>
2323
/// Class Library to generate Universally Unique Identifier (UUID) / Globally Unique Identifier (GUID) based on Version 7 (date-time).
2424
/// </summary>
25-
public class UUIDv7
25+
public static class UUIDv7
2626
{
27-
protected internal static readonly DateTime s_epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
27+
private static readonly DateTime s_epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
2828

29-
protected internal static UInt16 s_counter = 0;
30-
protected internal static readonly Object s_counterLock = new Object();
31-
32-
protected UUIDv7()
33-
{
34-
}
29+
private static UInt16 s_counter = 0;
30+
private static readonly Object s_counterLock = new Object();
3531

3632
public enum GenerationMethod
3733
{

UUIDUtil/Uuid.cs

+7-9
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public sealed class Uuid : IComparable<Uuid>, IEquatable<Uuid>
2727
private readonly uint _time_low;
2828
private readonly ushort _time_mid;
2929
private readonly ushort _time_hi_and_version;
30-
private byte _clock_seq_hi_and_reserved;
30+
private readonly byte _clock_seq_hi_and_reserved;
3131
private readonly byte _clock_seq_low;
3232
private readonly byte[] _node;
3333

@@ -355,10 +355,9 @@ public Guid ToVariant2()
355355
{
356356
byte newClockSeq = (byte)(_clock_seq_hi_and_reserved & 0x1F);
357357
newClockSeq = (byte)(newClockSeq | 0xC0);
358-
Uuid variant2 = new Uuid(this.ToByteArray())
359-
{
360-
_clock_seq_hi_and_reserved = newClockSeq
361-
};
358+
byte[] array = ToByteArray();
359+
array[8] = newClockSeq;
360+
Uuid variant2 = new Uuid(array);
362361

363362
return variant2.ToGuid();
364363
}
@@ -373,10 +372,9 @@ public static Uuid ToVariant1(Guid guid)
373372
Uuid variant2 = new Uuid(guid.ToString());
374373
byte newClockSeq = (byte)(variant2._clock_seq_hi_and_reserved & 0x3F);
375374
newClockSeq = (byte)(newClockSeq | 0x80);
376-
Uuid variant1 = new Uuid(variant2.ToByteArray())
377-
{
378-
_clock_seq_hi_and_reserved = newClockSeq
379-
};
375+
byte[] array = variant2.ToByteArray();
376+
array[8] = newClockSeq;
377+
Uuid variant1 = new Uuid(array);
380378

381379
return variant1;
382380
}

0 commit comments

Comments
 (0)