Guid.Empty
to create an empty GUID CS-R1007Guid.Empty
instead of new Guid()
for an empty Guid 57
58 // CS-R1007: Use `Guid.Empty` instead.
59 // https://deepsource.io/directory/analyzers/csharp/issues/CS-R1007
60 var guid = new Guid(); 61
62 var s1 = "alpha";
63 var s2 = "Alpha";
new SomeClass()
is the syntax to instantiate a class in C#. However, new Guid()
does not generate a new GUID
. It instead returns an empty GUID
. If you intend to use an empty GUID
, consider using Guid.Empty
as it is more straightforward to comprehend. If you wish to generate a new usable GUID
, consider using Guid.NewGuid()
.
var emptyGuid = new Guid();
var emptyGuid = Guid.Empty;
var usableGuid = Guid.NewGuid();