-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Rule summary
Value | |
---|---|
Title | Validate arguments of public methods |
CheckId | CA1062 |
Category | Design |
Link | https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1062 |
What is the problem
Depending on which type of application, and if you are running with C# 8 and Nullable enabled, then this rule could cause more noise than benefit.
For example. An API application is not going to be called by other assemblies as the interface is the API. Therefore, the additionally null check on all public method becomes less interesting as it is only the application it self that will call it.
However, for library code, then this rule could still make sense.
Suggestion
This code should only be in SRC. Currently I believe it is enabled in ROOT and TEST does not gain any benefit from this rule.
A suggestion could be disable the rule as a default:
- C# 8 and Nullable Reference Type partly ensures the same thing. However, nullable reference type does not resolve the issue for users calling a library code incorrectly.
- Depending on the usage of the coding rules, there might be a more prevalence for API projects than Library code. But this is not a good excuse and goes against the nature of this project.
Another suggestion is to add a feature to inform coding-rules of the type of application of the project. Thereby disabling this rules based on the application type; enabled for API applications, disabled for Library applications.