Code inspection: Replace with OfType<T>().Any() (replace with OfType<T>().Any(..))
This inspection reports a LINQ query that casts elements with as, filters out null, and then applies an additional predicate inside Any(...). The same logic is easier to read with OfType<T>().Any(...).
Example
bool hasLongName = items.Select(x => x as Person).Any(y => y != null && y.Name.Length > 10);
bool hasLongName = items.OfType<Person>().Any(y => y.Name.Length > 10);
Quick-fix
Replace the Select(... as T).Any(y => y != null && ...) pattern with OfType<T>().Any(...).
29 March 2026