Skip to content

CA1062 should also trigger when calling functions that don't take nullable references #6961

Open

Description

Analyzer

Diagnostic ID: CA1062: Validate arguments of public methods

Describe the improvement

When an argument of a public function is used to call another public function which does not accept nullable references
no warning is emitted.

The description of CA1062 says:

All reference arguments that are passed to externally visible methods should be checked against null.

I do understand that the rule seems to only apply when the argument is "dereferenced". I don't understand why this distinction happens as it makes stack traces deeper then they should be.

Notice in the attached example that the method I'm calling does not accept nullable parameters. I think that in this case the warning should also be shown.

CA1062 improvement.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions