Code inspection: Replace with OfType<T>().SingleOrDefault() (replace with OfType<T>().SingleOrDefault(..))
This inspection reports a LINQ query that casts elements with as, filters out null, and then expects at most one element matching an additional condition. The same query is easier to read with OfType<T>().SingleOrDefault(...).
Example
var item = items.Select(x => x as Person).SingleOrDefault(y => y != null && y.IsActive);
var item = items.OfType<Person>().SingleOrDefault(y => y.IsActive);
Quick-fix
Replace the Select(... as T).SingleOrDefault(y => y != null && ...) pattern with OfType<T>().SingleOrDefault(...).
29 March 2026