C#

C#

Made by DeepSource

Consider collapsing the null check CS-R1040

Anti-pattern
Major
Autofix

The ?. operator allows you to access a property or a member only if it is non-null. Consider simplifying the highlighted expression, i.e. the object and its member's null checks via the usage of this ?. operator.

Bad Practice

if (foo == null || foo.bar == null)
{
    // ...
}

Recommended

if (foo?.bar == null)
{
    // ...
}

Reference