Code inspection: Redundant type check in a pattern
This inspection reports a type check inside a pattern when that type check does not add any useful filtering. In these cases, the pattern can be simplified without changing behavior.
Example
switch (value)
{
case object _:
Handle(value);
break;
}
switch (value)
{
case not null:
Handle(value);
break;
}
Quick-fix
The quick-fix simplifies the pattern by removing the redundant type check.
13 April 2026