Table of Contents

AL0002: Don't repeat negated patterns

The negated pattern should not be repeated multiple times.

When it triggers

// Warning: Use 'not' only once or not at all
if (x is not not null) { }  // AL0002 - double negation

Why this matters

Double negation in patterns is confusing and makes code harder to read. It's equivalent to not using negation at all.

How to fix

Remove the redundant negation:

if (x is null) { }      // Clear intent
if (x is not null) { }  // Clear intent

Configuration

[*.cs]
dotnet_diagnostic.AL0002.severity = warning