diff --git a/csharp/ql/consistency-queries/SsaConsistency.ql b/csharp/ql/consistency-queries/SsaConsistency.ql index 003e7ddd5e94..6b3f4510e487 100644 --- a/csharp/ql/consistency-queries/SsaConsistency.ql +++ b/csharp/ql/consistency-queries/SsaConsistency.ql @@ -10,7 +10,7 @@ query predicate localDeclWithSsaDef(LocalVariableDeclExpr d) { exists(SsaExplicitWrite def | d = def.getDefinition().(AssignableDefinitions::LocalVariableDefinition).getDeclaration() | - not d = any(ForeachStmt fs).getVariableDeclExpr() and + not d = any(ForEachStmt fs).getVariableDeclExpr() and not d = any(SpecificCatchClause scc).getVariableDeclExpr() and not d.getVariable().getType() instanceof Struct and not d instanceof PatternExpr and diff --git a/csharp/ql/lib/Linq/Helpers.qll b/csharp/ql/lib/Linq/Helpers.qll index 2a4d5c8c27a2..feabaecff55a 100644 --- a/csharp/ql/lib/Linq/Helpers.qll +++ b/csharp/ql/lib/Linq/Helpers.qll @@ -8,13 +8,13 @@ private import semmle.code.csharp.frameworks.system.collections.Generic as Gener private import semmle.code.csharp.frameworks.system.Collections as Collections //#################### PREDICATES #################### -private Stmt firstStmt(ForeachStmt fes) { +private Stmt firstStmt(ForEachStmt fes) { if fes.getBody() instanceof BlockStmt then result = fes.getBody().(BlockStmt).getStmt(0) else result = fes.getBody() } -private int numStmts(ForeachStmt fes) { +private int numStmts(ForEachStmt fes) { if fes.getBody() instanceof BlockStmt then result = count(fes.getBody().(BlockStmt).getAStmt()) else result = 1 @@ -33,12 +33,15 @@ predicate isIEnumerableType(ValueOrRefType t) { ) } +/** DEPRECATED: Use `ForEachStmtGenericEnumerable` instead. */ +deprecated class ForeachStmtGenericEnumerable = ForEachStmtGenericEnumerable; + /** * A class of foreach statements where the iterable expression * supports the use of the LINQ extension methods on `IEnumerable`. */ -class ForeachStmtGenericEnumerable extends ForeachStmt { - ForeachStmtGenericEnumerable() { +class ForEachStmtGenericEnumerable extends ForEachStmt { + ForEachStmtGenericEnumerable() { exists(ValueOrRefType t | t = this.getIterableExpr().getType() | t.getABaseType*().getUnboundDeclaration() instanceof GenericCollections::SystemCollectionsGenericIEnumerableTInterface or @@ -47,12 +50,15 @@ class ForeachStmtGenericEnumerable extends ForeachStmt { } } +/** DEPRECATED: Use `ForEachStmtEnumerable` instead. */ +deprecated class ForeachStmtEnumerable = ForEachStmtEnumerable; + /** * A class of foreach statements where the iterable expression * supports the use of the LINQ extension methods on `IEnumerable`. */ -class ForeachStmtEnumerable extends ForeachStmt { - ForeachStmtEnumerable() { +class ForEachStmtEnumerable extends ForEachStmt { + ForEachStmtEnumerable() { exists(ValueOrRefType t | t = this.getIterableExpr().getType() | t.getABaseType*() instanceof Collections::SystemCollectionsIEnumerableInterface or t.(ArrayType).getRank() = 1 @@ -62,11 +68,11 @@ class ForeachStmtEnumerable extends ForeachStmt { /** * Holds if `foreach` statement `fes` could be converted to a `.All()` call. - * That is, the `ForeachStmt` contains a single `if` with a condition that + * That is, the `ForEachStmt` contains a single `if` with a condition that * accesses the loop variable and with a body that assigns `false` to a variable * and `break`s out of the `foreach`. */ -predicate missedAllOpportunity(ForeachStmtGenericEnumerable fes) { +predicate missedAllOpportunity(ForEachStmtGenericEnumerable fes) { exists(IfStmt is | // The loop contains an if statement with no else case, and nothing else. is = firstStmt(fes) and @@ -90,7 +96,7 @@ predicate missedAllOpportunity(ForeachStmtGenericEnumerable fes) { * block, the access is a cast, and the first statement is a * local variable declaration statement `s`. */ -predicate missedCastOpportunity(ForeachStmtEnumerable fes, LocalVariableDeclStmt s) { +predicate missedCastOpportunity(ForEachStmtEnumerable fes, LocalVariableDeclStmt s) { s = firstStmt(fes) and forex(VariableAccess va | va = fes.getVariable().getAnAccess() | va = s.getAVariableDeclExpr().getAChildExpr*() @@ -107,7 +113,7 @@ predicate missedCastOpportunity(ForeachStmtEnumerable fes, LocalVariableDeclStmt * block, the access is a cast with the `as` operator, and the first statement * is a local variable declaration statement `s`. */ -predicate missedOfTypeOpportunity(ForeachStmtEnumerable fes, LocalVariableDeclStmt s) { +predicate missedOfTypeOpportunity(ForEachStmtEnumerable fes, LocalVariableDeclStmt s) { s = firstStmt(fes) and forex(VariableAccess va | va = fes.getVariable().getAnAccess() | va = s.getAVariableDeclExpr().getAChildExpr*() @@ -125,7 +131,7 @@ predicate missedOfTypeOpportunity(ForeachStmtEnumerable fes, LocalVariableDeclSt * local variable declaration statement `s`, and the initializer does not * contain an `await` expression (since `Select` does not support async lambdas). */ -predicate missedSelectOpportunity(ForeachStmtGenericEnumerable fes, LocalVariableDeclStmt s) { +predicate missedSelectOpportunity(ForEachStmtGenericEnumerable fes, LocalVariableDeclStmt s) { s = firstStmt(fes) and forex(VariableAccess va | va = fes.getVariable().getAnAccess() | va = s.getAVariableDeclExpr().getAChildExpr*() @@ -140,7 +146,7 @@ predicate missedSelectOpportunity(ForeachStmtGenericEnumerable fes, LocalVariabl * variable, and the body of the `if` is either a `continue` or there's nothing * else in the loop than the `if`. */ -predicate missedWhereOpportunity(ForeachStmtGenericEnumerable fes, IfStmt is) { +predicate missedWhereOpportunity(ForEachStmtGenericEnumerable fes, IfStmt is) { // The very first thing the foreach loop does is test its iteration variable. is = firstStmt(fes) and exists(VariableAccess va | diff --git a/csharp/ql/lib/semmle/code/csharp/Stmt.qll b/csharp/ql/lib/semmle/code/csharp/Stmt.qll index 3be818e43a50..ebf0e354b9bc 100644 --- a/csharp/ql/lib/semmle/code/csharp/Stmt.qll +++ b/csharp/ql/lib/semmle/code/csharp/Stmt.qll @@ -305,7 +305,7 @@ class DefaultCase extends CaseStmt, LabeledStmt { * * Either a `while` statement (`WhileStmt`), a `do`-`while` statement * (`DoStmt`), a `for` statement (`ForStmt`), or a `foreach` statement - * (`ForeachStmt`). + * (`ForEachStmt`). */ class LoopStmt extends Stmt, @loop_stmt { /** Gets the body of this loop statement. */ @@ -422,6 +422,9 @@ class ForStmt extends LoopStmt, @for_stmt { override string getAPrimaryQlClass() { result = "ForStmt" } } +/** DEPRECATED: Use `ForEachStmt` instead. */ +deprecated class ForeachStmt = ForEachStmt; + /** * A `foreach` loop, for example * @@ -431,7 +434,7 @@ class ForStmt extends LoopStmt, @for_stmt { * } * ``` */ -class ForeachStmt extends LoopStmt, @foreach_stmt { +class ForEachStmt extends LoopStmt, @foreach_stmt { /** * Gets the local variable of this `foreach` loop, if any. * @@ -564,7 +567,7 @@ class ForeachStmt extends LoopStmt, @foreach_stmt { override string toString() { result = "foreach (... ... in ...) ..." } - override string getAPrimaryQlClass() { result = "ForeachStmt" } + override string getAPrimaryQlClass() { result = "ForEachStmt" } } /** diff --git a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll index b30646466a57..b813d58875c1 100644 --- a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll +++ b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/ControlFlowGraph.qll @@ -188,9 +188,9 @@ module Ast implements AstSig { AstNode getUpdate(int index) { result = super.getUpdate(index) } } - final private class FinalForeachStmt = CS::ForeachStmt; + final private class FinalForEachStmt = CS::ForEachStmt; - class ForEachStmt extends FinalForeachStmt { + class ForEachStmt extends FinalForEachStmt { Expr getVariable() { result = this.getVariableDeclExpr() or result = this.getVariableDeclTuple() } diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/Nullness.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/Nullness.qll index 1cd9c71acfc9..be2ed39a7d45 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/Nullness.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/Nullness.qll @@ -116,7 +116,7 @@ private predicate nonNullDef(SsaExplicitWrite def) { any(AssignableDefinitions::LocalVariableDefinition d | d.getExpr() = any(SpecificCatchClause scc).getVariableDeclExpr() or - d.getExpr() = any(ForeachStmt fs).getAVariableDeclExpr() + d.getExpr() = any(ForEachStmt fs).getAVariableDeclExpr() ) ) } @@ -306,7 +306,7 @@ class Dereference extends G::DereferenceableExpr { or this = any(LockStmt stmt).getExpr() or - this = any(ForeachStmt stmt).getIterableExpr() + this = any(ForEachStmt stmt).getIterableExpr() or exists(ExtensionMethodCall emc, Parameter p | this = emc.getArgumentForParameter(p) and diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll index d114101a7a38..8b86347ce460 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll @@ -2207,7 +2207,7 @@ private predicate readContentStep(Node node1, Content c, Node node2) { c instanceof ElementContent or exists( - ForeachStmt fs, SsaExplicitWrite def, AssignableDefinitions::LocalVariableDefinition defTo + ForEachStmt fs, SsaExplicitWrite def, AssignableDefinitions::LocalVariableDefinition defTo | node1.asExpr() = fs.getIterableExpr() and defTo.getDeclaration() = fs.getVariableDeclExpr() and diff --git a/csharp/ql/lib/semmle/code/csharp/exprs/Expr.qll b/csharp/ql/lib/semmle/code/csharp/exprs/Expr.qll index 857212f90aac..c8648741d011 100644 --- a/csharp/ql/lib/semmle/code/csharp/exprs/Expr.qll +++ b/csharp/ql/lib/semmle/code/csharp/exprs/Expr.qll @@ -1107,7 +1107,7 @@ class QualifiableExpr extends Expr, @qualifiable_expr { private Expr getAnAssignOrForeachChild() { result = any(AssignExpr e).getLeftOperand() or - result = any(ForeachStmt fs).getVariableDeclTuple() + result = any(ForEachStmt fs).getVariableDeclTuple() or result = getAnAssignOrForeachChild().getAChildExpr() } diff --git a/csharp/ql/src/API Abuse/NoDisposeCallOnLocalIDisposable.ql b/csharp/ql/src/API Abuse/NoDisposeCallOnLocalIDisposable.ql index 3fc8e07f6afe..e99647939c38 100644 --- a/csharp/ql/src/API Abuse/NoDisposeCallOnLocalIDisposable.ql +++ b/csharp/ql/src/API Abuse/NoDisposeCallOnLocalIDisposable.ql @@ -59,7 +59,7 @@ module DisposeCallOnLocalIDisposableConfig implements DataFlow::ConfigSig { exists(UsingStmt us | us.getAnExpr() = e) or // Foreach calls Dispose - exists(ForeachStmt fs | fs.getIterableExpr() = e) + exists(ForEachStmt fs | fs.getIterableExpr() = e) or // As are disposables on which the Dispose method is called explicitly exists(MethodCall mc | diff --git a/csharp/ql/src/Dead Code/DeadStoreOfLocal.ql b/csharp/ql/src/Dead Code/DeadStoreOfLocal.ql index 20f522e7b484..af6aa286ef07 100644 --- a/csharp/ql/src/Dead Code/DeadStoreOfLocal.ql +++ b/csharp/ql/src/Dead Code/DeadStoreOfLocal.ql @@ -31,7 +31,7 @@ class RelevantDefinition extends AssignableDefinition { any(LocalVariableDeclExpr lvde | lvde = any(SpecificCatchClause scc).getVariableDeclExpr() or - lvde = any(ForeachStmt fs).getVariableDeclExpr() and + lvde = any(ForEachStmt fs).getVariableDeclExpr() and not lvde.getName() = "_" ) or diff --git a/csharp/ql/src/Language Abuse/ForeachCapture.ql b/csharp/ql/src/Language Abuse/ForeachCapture.ql index 2ed24b42eba9..77226bdead79 100644 --- a/csharp/ql/src/Language Abuse/ForeachCapture.ql +++ b/csharp/ql/src/Language Abuse/ForeachCapture.ql @@ -23,17 +23,17 @@ predicate lambdaCaptures(AnonymousFunctionExpr lambda, Variable v) { exists(VariableAccess va | va.getEnclosingCallable() = lambda | va.getTarget() = v) } -predicate lambdaCapturesLoopVariable(AnonymousFunctionExpr lambda, ForeachStmt loop, Variable v) { +predicate lambdaCapturesLoopVariable(AnonymousFunctionExpr lambda, ForEachStmt loop, Variable v) { lambdaCaptures(lambda, v) and - inForeachStmtBody(loop, lambda) and + inForEachStmtBody(loop, lambda) and loop.getVariable() = v } -predicate inForeachStmtBody(ForeachStmt loop, Element e) { +predicate inForEachStmtBody(ForEachStmt loop, Element e) { e = loop.getBody() or exists(Element mid | - inForeachStmtBody(loop, mid) and + inForEachStmtBody(loop, mid) and e = mid.getAChild() ) } @@ -53,7 +53,7 @@ module LambdaDataFlow { exists(DataFlow::Node sink | flow(DataFlow::exprNode(lambda), sink) | storage = getAssignmentTarget(sink.asExpr()) ) and - exists(ForeachStmt loop | lambdaCapturesLoopVariable(lambda, loop, loopVar) | + exists(ForEachStmt loop | lambdaCapturesLoopVariable(lambda, loop, loopVar) | not declaredInsideLoop(loop, storage) ) } @@ -103,9 +103,9 @@ Element getCollectionAssignmentTarget(Expr e) { } // Variable v is declared inside the loop body -predicate declaredInsideLoop(ForeachStmt loop, LocalVariable v) { +predicate declaredInsideLoop(ForEachStmt loop, LocalVariable v) { exists(LocalVariableDeclStmt decl | decl.getVariableDeclExpr(_).getVariable() = v | - inForeachStmtBody(loop, decl) + inForEachStmtBody(loop, decl) ) } diff --git a/csharp/ql/src/Likely Bugs/Collections/WriteOnlyContainer.ql b/csharp/ql/src/Likely Bugs/Collections/WriteOnlyContainer.ql index 046099213cc6..df382ee4b9f7 100644 --- a/csharp/ql/src/Likely Bugs/Collections/WriteOnlyContainer.ql +++ b/csharp/ql/src/Likely Bugs/Collections/WriteOnlyContainer.ql @@ -28,7 +28,7 @@ where any(LocalVariableDeclAndInitExpr ass | ass.getRightOperand() instanceof ObjectCreation) .getLeftOperand() ) and - not v = any(ForeachStmt fs).getVariable() and + not v = any(ForEachStmt fs).getVariable() and not v = any(BindingPatternExpr vpe).getVariableDeclExpr().getVariable() and not v = any(Attribute a).getTarget() select v, "The contents of this container are never accessed." diff --git a/csharp/ql/src/Likely Bugs/Statements/UseBraces.ql b/csharp/ql/src/Likely Bugs/Statements/UseBraces.ql index 39f0bfddf6aa..ccac74250dab 100644 --- a/csharp/ql/src/Likely Bugs/Statements/UseBraces.ql +++ b/csharp/ql/src/Likely Bugs/Statements/UseBraces.ql @@ -36,7 +36,7 @@ class IfThenElseStmt extends IfStmt { Stmt getTrailingBody(Stmt s) { result = s.(ForStmt).getBody() or - result = s.(ForeachStmt).getBody() or + result = s.(ForEachStmt).getBody() or result = s.(WhileStmt).getBody() or result = s.(IfThenStmt).getThen() or result = s.(IfThenElseStmt).getElse() diff --git a/csharp/ql/src/Linq/BadMultipleIteration.ql b/csharp/ql/src/Linq/BadMultipleIteration.ql index 0f9e335e2251..7de0d7f1b6d8 100644 --- a/csharp/ql/src/Linq/BadMultipleIteration.ql +++ b/csharp/ql/src/Linq/BadMultipleIteration.ql @@ -38,7 +38,7 @@ predicate likelyNonRepeatableSequence(IEnumerableSequence seq) { /** An access to an enumerable sequence that potentially consumes sequence elements. */ predicate potentiallyConsumingAccess(VariableAccess va) { - exists(ForeachStmt fes | va = fes.getIterableExpr()) + exists(ForEachStmt fes | va = fes.getIterableExpr()) or exists(MethodCall mc | va = mc.getArgument(0) and diff --git a/csharp/ql/src/Linq/MissedAllOpportunity.ql b/csharp/ql/src/Linq/MissedAllOpportunity.ql index 1c03372d23b6..9e84c280c3f5 100644 --- a/csharp/ql/src/Linq/MissedAllOpportunity.ql +++ b/csharp/ql/src/Linq/MissedAllOpportunity.ql @@ -32,7 +32,7 @@ import Linq.Helpers * bool allEven = lst.All(i => i % 2 == 0); */ -from ForeachStmtGenericEnumerable fes +from ForEachStmtGenericEnumerable fes where missedAllOpportunity(fes) select fes, "This foreach loop looks as if it might be testing whether every sequence element satisfies a predicate - consider using '.All(...)'." diff --git a/csharp/ql/src/Linq/MissedCastOpportunity.ql b/csharp/ql/src/Linq/MissedCastOpportunity.ql index d40009e24c89..66e920f740e1 100644 --- a/csharp/ql/src/Linq/MissedCastOpportunity.ql +++ b/csharp/ql/src/Linq/MissedCastOpportunity.ql @@ -15,7 +15,7 @@ import csharp import Linq.Helpers -from ForeachStmtEnumerable fes, LocalVariableDeclStmt s +from ForEachStmtEnumerable fes, LocalVariableDeclStmt s where missedCastOpportunity(fes, s) select fes, "This foreach loop immediately $@ - consider casting the sequence explicitly using '.Cast(...)'.", diff --git a/csharp/ql/src/Linq/MissedOfTypeOpportunity.ql b/csharp/ql/src/Linq/MissedOfTypeOpportunity.ql index a4c8dff4b538..d80f9d983a7f 100644 --- a/csharp/ql/src/Linq/MissedOfTypeOpportunity.ql +++ b/csharp/ql/src/Linq/MissedOfTypeOpportunity.ql @@ -15,7 +15,7 @@ import csharp import Linq.Helpers -from ForeachStmtEnumerable fes, LocalVariableDeclStmt s +from ForEachStmtEnumerable fes, LocalVariableDeclStmt s where missedOfTypeOpportunity(fes, s) select fes, "This foreach loop immediately uses 'as' to $@ - consider using '.OfType(...)' instead.", s, diff --git a/csharp/ql/src/Linq/MissedSelectOpportunity.ql b/csharp/ql/src/Linq/MissedSelectOpportunity.ql index 8ea2a1c11d73..9e3571f36d54 100644 --- a/csharp/ql/src/Linq/MissedSelectOpportunity.ql +++ b/csharp/ql/src/Linq/MissedSelectOpportunity.ql @@ -22,7 +22,7 @@ predicate oversized(LocalVariableDeclStmt s) { ) } -from ForeachStmtGenericEnumerable fes, LocalVariableDeclStmt s +from ForEachStmtGenericEnumerable fes, LocalVariableDeclStmt s where missedSelectOpportunity(fes, s) and not oversized(s) diff --git a/csharp/ql/src/Linq/MissedWhereOpportunity.ql b/csharp/ql/src/Linq/MissedWhereOpportunity.ql index 62b34b93305a..e9e82f79baf3 100644 --- a/csharp/ql/src/Linq/MissedWhereOpportunity.ql +++ b/csharp/ql/src/Linq/MissedWhereOpportunity.ql @@ -14,7 +14,7 @@ import csharp import Linq.Helpers -from ForeachStmtGenericEnumerable fes, IfStmt is +from ForEachStmtGenericEnumerable fes, IfStmt is where missedWhereOpportunity(fes, is) and not missedAllOpportunity(fes) diff --git a/csharp/ql/test/library-tests/csharp7/ForEach.ql b/csharp/ql/test/library-tests/csharp7/ForEach.ql index e42b6f47372f..5391d6b96f8a 100644 --- a/csharp/ql/test/library-tests/csharp7/ForEach.ql +++ b/csharp/ql/test/library-tests/csharp7/ForEach.ql @@ -1,5 +1,5 @@ import csharp -from ForeachStmt stmt, int i +from ForEachStmt stmt, int i select stmt, i, stmt.getVariableDeclExpr(i), stmt.getVariable(i), stmt.getIterableExpr(), stmt.getBody() diff --git a/csharp/ql/test/library-tests/csharp7/PrintAst.expected b/csharp/ql/test/library-tests/csharp7/PrintAst.expected index 47ab207bb556..6ac8d9d92ac7 100644 --- a/csharp/ql/test/library-tests/csharp7/PrintAst.expected +++ b/csharp/ql/test/library-tests/csharp7/PrintAst.expected @@ -864,19 +864,19 @@ CSharp7.cs: # 283| -1: [ParameterAccess] access to parameter item # 283| 1: [PropertyCall] access to property Value # 283| -1: [ParameterAccess] access to parameter item -# 285| 2: [ForeachStmt] foreach (... ... in ...) ... +# 285| 2: [ForEachStmt] foreach (... ... in ...) ... # 285| 0: [TupleExpr] (..., ...) # 285| 0: [LocalVariableDeclExpr] Int32 a # 285| 1: [LocalVariableDeclExpr] String b # 285| 1: [LocalVariableAccess] access to local variable list # 285| 2: [BlockStmt] {...} -# 287| 3: [ForeachStmt] foreach (... ... in ...) ... +# 287| 3: [ForEachStmt] foreach (... ... in ...) ... # 287| 0: [TupleExpr] (..., ...) # 287| 0: [LocalVariableDeclExpr] Int32 a # 287| 1: [LocalVariableDeclExpr] String b # 287| 1: [LocalVariableAccess] access to local variable list # 287| 2: [BlockStmt] {...} -# 289| 4: [ForeachStmt] foreach (... ... in ...) ... +# 289| 4: [ForEachStmt] foreach (... ... in ...) ... # 289| 0: [TupleExpr] (..., ...) # 289| 0: [LocalVariableDeclExpr] Int32 a # 289| 1: [LocalVariableDeclExpr] String b diff --git a/csharp/ql/test/library-tests/csharp8/PrintAst.expected b/csharp/ql/test/library-tests/csharp8/PrintAst.expected index f5eb7caab572..4efcaad323ac 100644 --- a/csharp/ql/test/library-tests/csharp8/PrintAst.expected +++ b/csharp/ql/test/library-tests/csharp8/PrintAst.expected @@ -33,7 +33,7 @@ AsyncStreams.cs: # 15| 7: [Method] F # 15| -1: [TypeMention] Void # 16| 4: [BlockStmt] {...} -# 17| 0: [ForeachStmt] foreach (... ... in ...) ... +# 17| 0: [ForEachStmt] foreach (... ... in ...) ... # 17| 0: [LocalVariableDeclExpr] Int32 item # 17| 0: [TypeMention] int # 17| 1: [MethodCall] call to method Items diff --git a/csharp/ql/test/library-tests/csharp9/PrintAst.expected b/csharp/ql/test/library-tests/csharp9/PrintAst.expected index 459349fb9fc8..f86c98e4c6cf 100644 --- a/csharp/ql/test/library-tests/csharp9/PrintAst.expected +++ b/csharp/ql/test/library-tests/csharp9/PrintAst.expected @@ -241,7 +241,7 @@ ForeachExtension.cs: # 23| 0: [TypeMention] Enumerable # 23| 0: [IntLiteral] 0 # 23| 1: [IntLiteral] 10 -# 24| 1: [ForeachStmt] foreach (... ... in ...) ... +# 24| 1: [ForEachStmt] foreach (... ... in ...) ... # 24| 0: [LocalVariableDeclExpr] Int32 item # 24| 0: [TypeMention] int # 24| 1: [LocalVariableAccess] access to local variable enumerator1 @@ -252,17 +252,17 @@ ForeachExtension.cs: # 28| 1: [TypeMention] int # 28| 0: [LocalVariableAccess] access to local variable enumerator2 # 28| 1: [MethodCall] call to method GetAsyncEnumerator -# 29| 3: [ForeachStmt] foreach (... ... in ...) ... +# 29| 3: [ForEachStmt] foreach (... ... in ...) ... # 29| 0: [LocalVariableDeclExpr] Int32 item # 29| 0: [TypeMention] int # 29| 1: [LocalVariableAccess] access to local variable enumerator2 # 30| 2: [BlockStmt] {...} -# 33| 4: [ForeachStmt] foreach (... ... in ...) ... +# 33| 4: [ForEachStmt] foreach (... ... in ...) ... # 33| 0: [LocalVariableDeclExpr] Int32 item # 33| 0: [TypeMention] int # 33| 1: [IntLiteral] 42 # 34| 2: [BlockStmt] {...} -# 37| 5: [ForeachStmt] foreach (... ... in ...) ... +# 37| 5: [ForEachStmt] foreach (... ... in ...) ... # 37| 0: [LocalVariableDeclExpr] Int32 i # 37| 0: [TypeMention] int # 37| 1: [ArrayCreation] array creation of type Int32[] diff --git a/csharp/ql/test/library-tests/csharp9/foreach.ql b/csharp/ql/test/library-tests/csharp9/foreach.ql index 343ecc556ab8..eae1f44fdd25 100644 --- a/csharp/ql/test/library-tests/csharp9/foreach.ql +++ b/csharp/ql/test/library-tests/csharp9/foreach.ql @@ -4,11 +4,11 @@ private string getLocation(Member m) { if m.fromSource() then result = m.getALocation().(SourceLocation).toString() else result = "-" } -private string getIsAsync(ForeachStmt f) { +private string getIsAsync(ForEachStmt f) { if f.isAsync() then result = "async" else result = "sync" } -from ForeachStmt f +from ForEachStmt f select f, f.getElementType().toString(), getIsAsync(f), f.getGetEnumerator().getDeclaringType().getFullyQualifiedNameDebug(), getLocation(f.getGetEnumerator()), f.getCurrent().getDeclaringType().getFullyQualifiedNameDebug(), diff --git a/csharp/ql/test/library-tests/definitions/PrintAst.expected b/csharp/ql/test/library-tests/definitions/PrintAst.expected index 28196c75a857..fd9adbb2bff0 100644 --- a/csharp/ql/test/library-tests/definitions/PrintAst.expected +++ b/csharp/ql/test/library-tests/definitions/PrintAst.expected @@ -199,7 +199,7 @@ definitions.cs: # 86| 0: [LocalVariableDeclExpr] Exception e # 86| 0: [TypeMention] Exception # 87| 1: [BlockStmt] {...} -# 88| 0: [ForeachStmt] foreach (... ... in ...) ... +# 88| 0: [ForEachStmt] foreach (... ... in ...) ... # 88| 0: [LocalVariableDeclExpr] S1 s # 88| 0: [TypeMention] S1 # 88| 1: [ParameterAccess] access to parameter ss diff --git a/csharp/ql/test/library-tests/methods/PrintAst.expected b/csharp/ql/test/library-tests/methods/PrintAst.expected index 4810c6c0b5b7..f8a673575a12 100644 --- a/csharp/ql/test/library-tests/methods/PrintAst.expected +++ b/csharp/ql/test/library-tests/methods/PrintAst.expected @@ -323,7 +323,7 @@ methods.cs: # 127| 1: [StringLiteralUtf16] "22" # 127| 2: [StringLiteralUtf16] "333" # 127| 3: [StringLiteralUtf16] "4444" -# 128| 1: [ForeachStmt] foreach (... ... in ...) ... +# 128| 1: [ForEachStmt] foreach (... ... in ...) ... # 128| 0: [LocalVariableDeclExpr] String s # 128| 0: [TypeMention] string # 128| 1: [MethodCall] call to method Slice diff --git a/csharp/ql/test/library-tests/statements/Foreach1.ql b/csharp/ql/test/library-tests/statements/Foreach1.ql index 3f70956d9ca6..6f52f23fd988 100644 --- a/csharp/ql/test/library-tests/statements/Foreach1.ql +++ b/csharp/ql/test/library-tests/statements/Foreach1.ql @@ -4,5 +4,5 @@ import csharp -where forall(ForeachStmt s | exists(s.getBody()) and exists(s.getIterableExpr())) +where forall(ForEachStmt s | exists(s.getBody()) and exists(s.getIterableExpr())) select 1 diff --git a/csharp/ql/test/library-tests/statements/Foreach3.ql b/csharp/ql/test/library-tests/statements/Foreach3.ql index 9dfe5ba6a4e9..2ff6a0cdbe68 100644 --- a/csharp/ql/test/library-tests/statements/Foreach3.ql +++ b/csharp/ql/test/library-tests/statements/Foreach3.ql @@ -4,7 +4,7 @@ import csharp -from Method m, ForeachStmt s +from Method m, ForEachStmt s where m.getName() = "MainForeach" and s.getEnclosingCallable() = m and diff --git a/csharp/ql/test/library-tests/statements/PrintAst.expected b/csharp/ql/test/library-tests/statements/PrintAst.expected index 59af8ce4a2ea..7709f65b7c3c 100644 --- a/csharp/ql/test/library-tests/statements/PrintAst.expected +++ b/csharp/ql/test/library-tests/statements/PrintAst.expected @@ -357,7 +357,7 @@ statements.cs: # 139| -1: [TypeMention] String[] # 139| 1: [TypeMention] string # 140| 4: [BlockStmt] {...} -# 141| 0: [ForeachStmt] foreach (... ... in ...) ... +# 141| 0: [ForEachStmt] foreach (... ... in ...) ... # 141| 0: [LocalVariableDeclExpr] String s # 141| 0: [TypeMention] string # 141| 1: [ParameterAccess] access to parameter args @@ -501,7 +501,7 @@ statements.cs: # 192| 24: [Method] MainYield # 192| -1: [TypeMention] Void # 193| 4: [BlockStmt] {...} -# 194| 0: [ForeachStmt] foreach (... ... in ...) ... +# 194| 0: [ForEachStmt] foreach (... ... in ...) ... # 194| 0: [LocalVariableDeclExpr] Int32 x # 194| 0: [TypeMention] int # 194| 1: [MethodCall] call to method Range