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

ParamName not set in some of the thrown Argument(*)Exceptions #168

Closed
Miljankg opened this issue Jan 2, 2022 · 0 comments · Fixed by #169
Closed

ParamName not set in some of the thrown Argument(*)Exceptions #168

Miljankg opened this issue Jan 2, 2022 · 0 comments · Fixed by #169

Comments

@Miljankg
Copy link
Contributor

Miljankg commented Jan 2, 2022

  • .NET SDK Version: 6.0.101

Discussed in #167

Description: It seems that in some cases, Guard clauses throw Argument exceptions without "paramName" parameter being set.

Steps to Reproduce:

  1. Use Ardalis.GuardClauses 3.3.0 NuGet Package.
  2. Ensure that Guard.Against.Null is invoked with 3 parameters set: input, parameterName, and message. Input must be null.
  3. Examine the exception thrown by the Guard clause and check the ParamName property.
  4. The Param.Name property will be Null, even though the "parameterName" parameter of the Guard clause has been set.

Further details:

This described situation occurs when using some of the Guard clauses with the custom message set. Without the custom message, everything is expected. Guard clauses affected by this are:

  • Null
  • OutOfRange (general)
  • OutOfRange (enum)
  • OutOfRange (enumerable)

The next .net fiddle has a sample code that demonstrate the issue in all mentioned cases: https://dotnetfiddle.net/3PzcIQ

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

Successfully merging a pull request may close this issue.

1 participant