Code inspection: Replace with OfType<T>().Single()
This inspection reports a LINQ query that casts elements with as and then uses Single(...) to find the only non-null cast result. The same intent is clearer with OfType<T>().Single().
Example
var item = items.Select(x => x as string).Single(y => y != null);
var item = items.OfType<string>().Single();
Quick-fix
Replace the Select(... as T).Single(y => y != null) pattern with OfType<T>().Single().
29 March 2026