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

Predicate missedCastOpportunity

Holds if the foreach statement fes can be converted to a .Cast() call. That is, the loop variable is accessed only in the first statement of the block, the access is a cast, and the first statement is a local variable declaration statement s.

Import path

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