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

Fix #17: Warn when provided argument name in ArgumentException is incorrect #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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