dotnet-null-pattern-matching
Narrow trigger extracted from skills/dotnet-conventions §5.6, so a null check routes here directly
instead of only through the whole .NET block.
When
Writing or reviewing a null check — especially inside a type's own operator ==/Equals override,
where the wrong form is a functional bug, not just a style deviation.
Steps
- Test null with the pattern form (
is null/is not null) rather than the equality operator, and avoid the roundabout not-null spellings. - This is a preference in ordinary code — an informed override is fine.
- Inside an equality-operator body, using the equality operator is infinite recursion, not a
style choice.
is null/is not nullis the only correct form there, because==calls the very operator being defined.
Output / checkpoint
Null checks in the diff use is null/is not null; any operator ==/Equals override in the diff
never compares to null with == inside its own body.
Guardrails
- The pattern form isn't just style inside an overload — a type that overrides
==and then checksx == nullinside that same overload recurses until it stack-overflows, which is why this is a correctness rule at that one call site specifically. - The rest of the disposal/nullability/enumeration section lives in
skills/dotnet-conventions§5 — read it for the neighbouring rules this one sits beside.
Origin
No external source: this is skills/dotnet-conventions §5.6 extracted to its own trigger. Written
2026-09-09, same restructuring pilot as laravel-no-db-enums.