You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use guid-backed ids a lot, but since they may represent Empty (which it almost never a possible value), we have to do a lot of
if(id==TId.Empty){thrownull!;// well, any stupid handling}
checks. It looks like adding a new backing type (NotEmptyGuid) will be handy.
Probably we can go even deeper and introduce a new AllowEmpty parameter, because empty strings and zero ints/longs are also usually represent invalid identifiers.
The text was updated successfully, but these errors were encountered:
Not possible.
Guid.Empty == default(Guid).
StrongId is struct type.
So, default(StrongId) where typeof(UNDERLYING) == typeof(Guid) - is also Guid.Empty.
Might be covered in the scope of #75. Having the default constructor generation disabled, the developer could just define their own constructor that will disallow Guid.Empty (or string.Empty, or 0).
The main idea is to make the library much more maintainable while also giving people a mechanism to customise the generated IDs as much as they like. So if you want to do something like throw in the constructor when provided Guid.Empty, you can 🙂
We use guid-backed ids a lot, but since they may represent
Empty
(which it almost never a possible value), we have to do a lot ofchecks. It looks like adding a new backing type (
NotEmptyGuid
) will be handy.Probably we can go even deeper and introduce a new
AllowEmpty
parameter, because empty strings and zero ints/longs are also usually represent invalid identifiers.The text was updated successfully, but these errors were encountered: