-
Notifications
You must be signed in to change notification settings - Fork 33
LC0087
Arthur van de Vondervoort edited this page Jan 18, 2025
·
2 revisions
This rule ensures that GUID comparisons are performed safely by enforcing the use of the IsNullGuid()
method instead of direct comparisons. Directly comparing a GUID to an empty string (''
) will cause a runtime error because ''
is not a valid GUID format.
When a GUID is compared to a string-like type, the string is parsed into a GUID behind the scenes. If the string cannot be parsed into a valid GUID, a runtime exception is thrown.
procedure MyProcedure()
var
MyGuid: Guid;
begin
if MyGuid = '' then; // Use 'IsNullGuid(MyGuid)' method instead of comparing the Guid 'MyGuid' with '', as this will result in a runtime error.
end;
procedure MyProcedure()
var
MyGuid: Guid;
begin
if IsNullGuid(MyGuid) then;
end;