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

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 )