ardalis / ardalis/GuardClauses

[CallerArgumentExpression] parameter should be the last one to allow passing custom message

Open
#362 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C#
Stars
3.3k
Forks
296
PR merge metrics
No merged PRs in 30d

Description

See the guards API below :

````c#
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.

Contributor guide

Open the contributing guide

Research direction

Start by locating the Negative guard in the guards API and review how its optional parameterName and message arguments are exposed. Confirm the intended parameter order and check existing coverage or callers; done means a custom message can be supplied without explicitly passing parameterName while caller-expression behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.