CodeQL library for C#
codeql/csharp-all 0.5.1 (changelog, source)

Predicate missedCastOpportunity

Holds if foreach statement fes could be converted to a .Cast() call. That is, the loop variable is accessed only in the first statement of the block, and the access is a cast. The first statement needs to be a LocalVariableDeclStmt.

Import path

import Linq.Helpers
predicate missedCastOpportunity(ForeachStmt fes, LocalVariableDeclStmt s)