Currently the implementation of Ulid.Parse will not parse a Ulid that is in GUID format back into the correct Ulid.
Example:
var ulidX = Ulid.NewUlid();
var guidX = ulidX.ToGuid();
var ulidXrt = Ulid.Parse(guidX.ToString());
var xeq = ulidX == ulidXrt;
var guidY = Guid.NewGuid();
var ulidY = Ulid.Parse(guidY.ToString());
var guidYrt = ulidY.ToGuid();
var yeq = guidY == guidYrt;
With this code in both cases the equality checks on the round-tripped from GUID string versions will fail to be the same as the original Ulid (or GUID). I would consider this unexpected and potentially dangerous behavior for data integrity purposes.
I would suggest that the implementation of Ulid.Parse should detect that a GUID format (not ULID) has been passed and either:
Parse it as a GUID and return the equivalent of: new Uild(Guid.Parse(input))
Throw an exception explaining that the input was in GUID format which is not supported.
Currently the implementation of
Ulid.Parse
will not parse a Ulid that is in GUID format back into the correct Ulid.Example:
With this code in both cases the equality checks on the round-tripped from GUID string versions will fail to be the same as the original Ulid (or GUID). I would consider this unexpected and potentially dangerous behavior for data integrity purposes.
I would suggest that the implementation of
Ulid.Parse
should detect that a GUID format (not ULID) has been passed and either:new Uild(Guid.Parse(input))