C#

C#

Made by DeepSource

Consider using the equality operators when evaluating bool? CS-R1118

Anti-pattern
Major
Autofix

While the null coalescing operator may come in handy when evaluating the bool? types, it is recommended that you stick to the traditional equality operators and explicit boolean values — an approach that is more readable and easier to comprehend.

Bad Practice

if (instance?.field ?? false)
{
    // ...
}

Recommended

if (instance?.field == true)
{
    // ...
}