Skip to content

Commit c1ea4d4

Browse files
committed
task: add conditional compilation for GUID generation
Introduce conditional compilation in Base.cs to handle GUID generation based on the target framework version. For .NET 9.0 or greater, use `System.Guid.CreateVersion7()`. For earlier versions, continue using `System.Guid.NewGuid()`. This ensures compatibility with new features in .NET 9.0 while maintaining support for older versions.
1 parent 9155c94 commit c1ea4d4

File tree

1 file changed

+4
-1
lines changed
  • src/Primitively/EmbeddedResources/Guid

1 file changed

+4
-1
lines changed

src/Primitively/EmbeddedResources/Guid/Base.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ private PRIMITIVE_TYPE(string value)
4040
public static implicit operator global::System.Guid(PRIMITIVE_TYPE value) => value._value;
4141
public static explicit operator PRIMITIVE_TYPE(global::System.Guid value) => new(value);
4242
public static explicit operator PRIMITIVE_TYPE(string value) => new(value);
43-
43+
#if NET9_0_OR_GREATER
44+
public static PRIMITIVE_TYPE New() => new PRIMITIVE_TYPE(global::System.Guid.CreateVersion7());
45+
#else
4446
public static PRIMITIVE_TYPE New() => new PRIMITIVE_TYPE(global::System.Guid.NewGuid());
47+
#endif
4548
public static readonly PRIMITIVE_TYPE Empty = new PRIMITIVE_TYPE(global::System.Guid.Empty);
4649

4750
public static PRIMITIVE_TYPE Parse(string value) => new(value);

0 commit comments

Comments
 (0)