possible-null-dereference
What it does
Section titled “What it does”Reports a member or element access on an expression that the nullable analysis says may be null. Only code under #nullable enable is checked. Off by default: the compiler reports the same thing.
Why it matters
Section titled “Why it matters”Dereferencing a null reference throws NullReferenceException at run time, so the warning points at a crash that the code allows.
To fix, check for null before the access, or change the type if it cannot be null.
Configuration
Section titled “Configuration”csharp: lint: rules: possible-null-dereference: warn # off (default), warn, errorEnabled by the presets: csharp/roslynator.
Suppress one line with sudsy-disable-next-line possible-null-dereference in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| Roslynator | RCS1202 |
full |