Code inspection: Replace with OfType<T>().LongCount()
This inspection reports a LINQ query that casts elements with as and then counts non-null results with LongCount(...). The same count is more direct with OfType<T>().LongCount().
Example
long count = items.Select(x => x as string).LongCount(y => y != null);
long count = items.OfType<string>().LongCount();
Quick-fix
Replace the Select(... as T).LongCount(y => y != null) pattern with OfType<T>().LongCount().
29 March 2026