C#

C#

Made by DeepSource

Consider using not null instead of an empty recursive pattern when checking for nullness CS-R1120

Anti-pattern
Major
Autofix

One way to check for nullness using pattern matching is to use the empty recursive pattern syntax {}. However, consider using not null instead as it is more readable and easier to comprehend as it accurately conveys what it achieves.

Bad Practice

if (obj is C
{
    field: { }
})
{
    // ...
}

Recommended

if (obj is C
{
    field: not null
})
{
    // ...
}