GuardClauses
GuardClauses copied to clipboard
[CallerArgumentExpression] parameter should be the last one to allow passing custom message
trafficstars
See the guards API below :
public static int Negative([JetBrainsNotNull] this IGuardClause guardClause,
int input,
[JetBrainsNotNull][JetBrainsInvokerParameterName][CallerArgumentExpression("input")] string? parameterName = null,
string? message = null){
......
}
If I want to pass custom message I need to pass parameterName as well, which breaks the CallerArgumentExpression functionality.
Good point. Unfortunately a big breaking change but one we can probably absorb into a future version.
@jvmlet I guess you can pass a custom message without passing parameterName as follows:
Guard.Against.Negative(input, message: "Test message.");