-
Notifications
You must be signed in to change notification settings - Fork 344
Open
Labels
feature request 📬A request for new changes to improve functionalityA request for new changes to improve functionality
Description
Overview
I've found guard clauses being abused and used to validate non-arguments. It would be great to have an analyzer that checks for incorrect usage where one of the Guard
clauses is used for something that is not an argument to a method, property, etc.
Here is an example of something that I would like the analyzer to catch:
class C
{
string P { get; }
void M(string s)
{
Guard.IsNotNull(P); // <-- P is not an argument!
}
}
API breakdown
N/A for an analyzer.
Usage example
class C
{
string P { get; }
void M(string s)
{
Guard.IsNotNull(P); // <-- The analyzer should report a warning, squiggle, etc.
}
}
Breaking change?
No
Alternatives
Anyone could write an analyzer to do this outside of the toolkit, but it would obviously be best and most natural to have it included as part of the toolkit itself.
Additional context
This is predicated on my understanding that the Guard
clauses provided by the toolkit are specifically intended for arguments.
Help us help you
No, just wanted to propose this
Metadata
Metadata
Assignees
Labels
feature request 📬A request for new changes to improve functionalityA request for new changes to improve functionality