Skip to content

Conversation

@AlexanderSher
Copy link

No description provided.

}

[Test]
public void ShouldWarnOnArgumentExceptionHasStringParameterNameInMethod() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think explicit test case and even special message would be highly useful (but maybe not part of this PR) when user uses different order of arguments - throw ArgumentExcpetion("name", "message").

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see at least 4 different cases here:

  • throw new ArgumentException("name", "message") - your case
  • throw new ArgumentException("name", "name") - the name of the argument is used as description (probably valid). Also, it can be `throw new ArgumentException("name", nameof(name))
  • throw new ArgumentException("name1", "name2") - the name of one argument is used as description, the other one is used as parameter (both are valid names)
  • throw new ArgumentException("name", variable) - variable can provide required name

There may be more, but even those add 4 additional rules. Looks more like additional task to me.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely. Out of scope for this task.

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 this pull request may close these issues.

2 participants