Code inspection: Replace with OfType<T>().Where() (replace with OfType<T>().Where(..))
This inspection reports a LINQ query that casts elements with as, filters out null, and then applies another Where(...) predicate. The same query is clearer with OfType<T>().Where(...).
Example
var query = items.Select(x => x as Person).Where(y => y != null && y.IsActive);
var query = items.OfType<Person>().Where(y => y.IsActive);
Quick-fix
Replace the Select(... as T).Where(y => y != null && ...) pattern with OfType<T>().Where(...).
29 March 2026