Closed AKlaus closed 1 year ago
On second thought, the proposal would reduce understanding of the code and a marginal reduction of code lines.
Helper methods like this don't bring much value and may lead to an analysis paralysis on which method to use:
public static IDomainResult FailedIfNull<T>([NotNull] T? notNullArgument, string? error = null)
=> (notNullArgument is null) ? Failed(error) : Success(notNullArgument);
Add syntactic sugar static methods to return
Failed
status if the specified parameter isnull
– all to save time writing a null check if condition.Suggested methods:
IDomainResult.FailIfNull(object? argument, string? errorMessage = default)
DomainResult.FailIfNull(object? argument, string? errorMessage = default)