Skip to content

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

@Miljankg

Description

@Miljankg
  • .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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions