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

Remove calls to throw helpers for validating input #80

Closed
oliverbooth opened this issue Apr 13, 2023 · 0 comments · Fixed by #81
Closed

Remove calls to throw helpers for validating input #80

oliverbooth opened this issue Apr 13, 2023 · 0 comments · Fixed by #81
Assignees
Labels
approved This issue has been approved by the developer enhancement New feature or request net6.0 Issue applies to .NET 6. net7.0 Issue applies to .NET 7.
Milestone

Comments

@oliverbooth
Copy link
Owner

Summary

Replace all methods containing the following call:

ArgumentNullException.ThrowIfNull(...);

with the following:

if (... is null)
{
    throw new ArgumentNullException(nameof(...));
}

Rationale

On a personal level, I find it inconvenient that Rider fails to generate the <exception> node in XMLDoc using a throw helper, since there's no explicit throw statement in any immediate code path.

On a more important level, however, throw helpers obscure the call stack and more vitally introduce a problem in test coverage. Since a single method call instruction is covered in all cases, coverage can falsely be reported as 100% despite no unit tests existing for a null check. A branch with an explicit throw, however, will guarantee that tests reach true 100% coverage by adding in tests cases for null input, without exception*.

* Pun intended.

@oliverbooth oliverbooth added enhancement New feature or request approved This issue has been approved by the developer net6.0 Issue applies to .NET 6. net7.0 Issue applies to .NET 7. labels Apr 13, 2023
@oliverbooth oliverbooth added this to the 4.0.0 milestone Apr 13, 2023
@oliverbooth oliverbooth self-assigned this Apr 13, 2023
@oliverbooth oliverbooth linked a pull request Apr 13, 2023 that will close this issue
oliverbooth added a commit that referenced this issue Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved This issue has been approved by the developer enhancement New feature or request net6.0 Issue applies to .NET 6. net7.0 Issue applies to .NET 7.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant