Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jvmlet opened this issue Oct 9, 2024 · 2 comments

Comments

@jvmlet
Copy link

jvmlet commented Oct 9, 2024

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.

@ardalis
Copy link
Owner

ardalis commented Oct 22, 2024

Good point. Unfortunately a big breaking change but one we can probably absorb into a future version.

@ardalis ardalis closed this as completed Oct 22, 2024
@ardalis ardalis reopened this Oct 22, 2024
@beyzaaydogan
Copy link

@jvmlet I guess you can pass a custom message without passing parameterName as follows:

Guard.Against.Negative(input, message: "Test message.");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants