437 references to ForEachStatementSyntax
Microsoft.CodeAnalysis.CSharp (28)
Binder\Binder.cs (1)
733if (node.AsNode() is ForEachStatementSyntax foreachSyntax)
Binder\ForEachLoopBinder.cs (5)
87var syntax = (ForEachStatementSyntax)_syntax; 274var node = (ForEachStatementSyntax)_syntax; 1286((syntax as ForEachStatementSyntax)?.Type.IsVar == true) ?
Binder\LocalBinderFactory.cs (1)
661public override void VisitForEachStatement(ForEachStatementSyntax node)
Compilation\CSharpSemanticModel.cs (3)
3264public ILocalSymbol GetDeclaredSymbol(ForEachStatementSyntax forEachStatement) 4811public abstract ForEachStatementInfo GetForEachStatementInfo(ForEachStatementSyntax node); 5125return this.GetDeclaredSymbol((ForEachStatementSyntax)node);
Compilation\MemberSemanticModel.cs (1)
936public override ForEachStatementInfo GetForEachStatementInfo(ForEachStatementSyntax node)
Compilation\SpeculativeSemanticModelWithMemberModel.cs (1)
400public override ForEachStatementInfo GetForEachStatementInfo(ForEachStatementSyntax node)
Compilation\SyntaxTreeSemanticModel.cs (1)
2360public override ForEachStatementInfo GetForEachStatementInfo(ForEachStatementSyntax node)
CSharpExtensions.cs (2)
891public static ForEachStatementInfo GetForEachStatementInfo(this SemanticModel? semanticModel, ForEachStatementSyntax forEachStatement) 1581public static ILocalSymbol? GetDeclaredSymbol(this SemanticModel? semanticModel, ForEachStatementSyntax forEachStatement, CancellationToken cancellationToken = default(CancellationToken))
FlowAnalysis\NullableWalker.cs (4)
6840ForEachStatementSyntax { Expression: var expression } => expression, 11076ForEachStatementSyntax statement => statement.Identifier.GetLocation(), 11109var foreachSyntax = (ForEachStatementSyntax)node.Syntax;
Lowering\Instrumentation\DebugInfoInjector.cs (2)
318var forEachSyntax = (ForEachStatementSyntax)original.Syntax;
Symbols\LocalDeclarationKind.cs (1)
48/// User defined local variable declared by <see cref="ForEachStatementSyntax"/> or <see cref="ForEachVariableStatementSyntax"/>.
Symbols\Source\SourceLocalSymbol.cs (1)
443Debug.Assert(node is ForEachStatementSyntax || node is SingleVariableDesignationSyntax);
Syntax\ForEachStatementSyntax.cs (4)
11public ForEachStatementSyntax Update(SyntaxToken forEachKeyword, SyntaxToken openParenToken, TypeSyntax type, SyntaxToken identifier, SyntaxToken inKeyword, ExpressionSyntax expression, SyntaxToken closeParenToken, StatementSyntax statement) 14public ForEachStatementSyntax Update(SyntaxToken awaitKeyword, SyntaxToken forEachKeyword, SyntaxToken openParenToken, TypeSyntax type, SyntaxToken identifier, SyntaxToken inKeyword, ExpressionSyntax expression, SyntaxToken closeParenToken, StatementSyntax statement) 23public static ForEachStatementSyntax ForEachStatement(SyntaxToken forEachKeyword, SyntaxToken openParenToken, TypeSyntax type, SyntaxToken identifier, SyntaxToken inKeyword, ExpressionSyntax expression, SyntaxToken closeParenToken, StatementSyntax statement) 26public static ForEachStatementSyntax ForEachStatement(SyntaxToken awaitKeyword, SyntaxToken forEachKeyword, SyntaxToken openParenToken, TypeSyntax type, SyntaxToken identifier, SyntaxToken inKeyword, ExpressionSyntax expression, SyntaxToken closeParenToken, StatementSyntax statement)
Syntax\SyntaxFacts.cs (1)
132return ((ForEachStatementSyntax)parent).Type == node;
Microsoft.CodeAnalysis.CSharp.CodeStyle (19)
src\Analyzers\CSharp\Analyzers\RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (1)
103if (unusedDefinition.Syntax.Parent is ForEachStatementSyntax forEachStatement &&
src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUpdateExpressionSyntaxHelper.cs (2)
22var foreachStatement = (ForEachStatementSyntax)statement;
src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUseCollectionInitializerAnalyzer.cs (1)
108case ForEachStatementSyntax foreachStatement:
src\Analyzers\CSharp\Analyzers\UseDeconstruction\CSharpUseDeconstructionDiagnosticAnalyzer.cs (3)
53case ForEachStatementSyntax forEachStatement: 75SyntaxNodeAnalysisContext context, ForEachStatementSyntax forEachStatement, NotificationOption2 notificationOption) 121ForEachStatementSyntax forEachStatement,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
393else if (current.Parent is ForEachStatementSyntax foreachStatement &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (1)
133var node = TryGetAncestorForLocation<ForEachStatementSyntax>(root, position);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (1)
1355=> node?.Parent is ForEachStatementSyntax foreachStatement && foreachStatement.Expression == node;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (2)
657ForEachStatementSyntax foreachStatement => foreachStatement.Type.IsTypeInferred(semanticModel), 896if (forEach is ForEachStatementSyntax foreachStatement)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.cs (2)
91ForEachStatementSyntax forEachStatement => ShouldAnalyzeForEachStatement(forEachStatement, semanticModel, cancellationToken) 115protected virtual bool ShouldAnalyzeForEachStatement(ForEachStatementSyntax forEachStatement, SemanticModel semanticModel, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.State.cs (1)
144ForEachStatementSyntax forEach => forEach.Type,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseExplicitTypeHelper.cs (2)
54protected override bool ShouldAnalyzeForEachStatement(ForEachStatementSyntax forEachStatement, SemanticModel semanticModel, CancellationToken cancellationToken) 104else if (typeName.Parent is ForEachStatementSyntax foreachStatement &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (2)
60protected override bool ShouldAnalyzeForEachStatement(ForEachStatementSyntax forEachStatement, SemanticModel semanticModel, CancellationToken cancellationToken) 152else if (typeName.Parent is ForEachStatementSyntax foreachStatement &&
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (14)
src\Analyzers\CSharp\CodeFixes\MakeStatementAsynchronous\CSharpMakeStatementAsynchronousCodeFixProvider.cs (1)
69case ForEachStatementSyntax forEach:
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (2)
31ForEachStatementSyntax, SwitchSectionSyntax, SwitchLabelSyntax, CatchClauseSyntax, CatchClauseSyntax> 39protected override SyntaxToken GetForEachStatementIdentifier(ForEachStatementSyntax node)
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (2)
497else if (node is ForEachStatementSyntax foreachStatement) 780else if (node is ForEachStatementSyntax foreachStatement)
src\Analyzers\CSharp\CodeFixes\UseDeconstruction\CSharpUseDeconstructionCodeFixProvider.cs (3)
89else if (node is ForEachStatementSyntax forEachStatement) 98(current, _) => CreateForEachVariableStatement(tupleType, (ForEachStatementSyntax)current)); 116private ForEachVariableStatementSyntax CreateForEachVariableStatement(INamedTypeSymbol tupleType, ForEachStatementSyntax forEachStatement)
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (2)
68else if (declarationContext is ForEachStatementSyntax forEach) 109private static Task HandleForEachStatementAsync(Document document, SyntaxEditor editor, ForEachStatementSyntax forEach, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (1)
1652if (outer.Parent is ForEachStatementSyntax @foreach)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (3)
160ForEachStatementSyntax forEachStatement => InferTypeInForEachStatement(forEachStatement, expression), 227ForEachStatementSyntax forEachStatement => InferTypeInForEachStatement(forEachStatement, previousToken: token), 1231private IEnumerable<TypeInferenceInfo> InferTypeInForEachStatement(ForEachStatementSyntax forEachStatementSyntax, ExpressionSyntax expressionOpt = null, SyntaxToken? previousToken = null)
Microsoft.CodeAnalysis.CSharp.EditorFeatures (3)
AutomaticCompletion\AutomaticLineEnderCommandHandler.cs (1)
332or ForEachStatementSyntax
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (2)
151WhileStatementSyntax or ForEachStatementSyntax or ForStatementSyntax or LockStatementSyntax or UsingStatementSyntax 945ForEachStatementSyntax forEachStatementNode => forEachStatementNode.WithStatement(block),
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (62)
CodeGen\CodeGenAwaitForeachTests.cs (56)
936var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 1661var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 1721var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 1865var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 1902var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 1942var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 1979var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 2013var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 2969var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 3034var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 3119var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 3237var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 3292var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 3350var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 3546var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 3594var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 3715var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 4239var loop = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 4462var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 4536var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 5049var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 5130var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 5356var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 6439var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 9107var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 9183var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 9261var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 9322var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single();
CodeGen\CodeGenForEachTests.cs (2)
1758var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single();
CodeGen\CodeGenTupleTest.cs (2)
24269var xSymbol = model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single()); 24332var xSymbol = model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single());
CodeGen\ForeachTest.cs (2)
1687var decl = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (117)
FlowAnalysis\IterationJumpYieldStatementTests.cs (2)
914var foreachNode = tree.GetCompilationUnitRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single();
FlowAnalysis\RegionAnalysisTests.cs (3)
5488var foreachStatement = methodBlock.DescendantNodes().OfType<ForEachStatementSyntax>().First(); 7909var stmt = tree.GetCompilationUnitRoot().DescendantNodesAndSelf().OfType<ForEachStatementSyntax>().Single().Statement;
RefStructInterfacesTests.cs (102)
7575var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 7765var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 7984var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().First(); 8175var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 8368var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 8443var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 8647var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 9018var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 9222var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 9386var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 9586var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 9810var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 10019var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 10246var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 10349var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 10444var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 10629var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 10826var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 11066var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().First(); 11294var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 11506var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 11606var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 11701var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 14258var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 14599var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 14965var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().First(); 15309var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 15657var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 15734var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 16095var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 16760var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 16825var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 16890var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 16974var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 17062var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 17155var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 17252var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 17336var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 17762var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 17959var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 18182var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().First(); 18379var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 18580var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 18654var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 18864var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 19199var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 19370var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 19527var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 19695var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 19863var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 19968var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single();
Semantics\InlineArrayTests.cs (6)
18583var f = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single().Expression; 18593var forEachInfo = model.GetForEachStatementInfo((ForEachStatementSyntax)f.Parent); 18909var f = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single().Expression; 18919var forEachInfo = model.GetForEachStatementInfo((ForEachStatementSyntax)f.Parent); 19246var collection = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single().Expression; 19256var forEachInfo = model.GetForEachStatementInfo((ForEachStatementSyntax)collection.Parent);
Semantics\OutVarTests.cs (2)
35649var foreachStatement = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single();
Semantics\ParamsCollectionTests.cs (2)
12533var node = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Features (71)
CodeRefactorings\UseExplicitOrImplicitType\AbstractUseTypeCodeRefactoringProvider.cs (2)
102var foreachStatement1 = await context.TryGetRelevantNodeAsync<ForEachStatementSyntax>().ConfigureAwait(false); 109if (type?.Parent is ForEachStatementSyntax foreachStatement2 &&
Completion\CompletionProviders\DeclarationName\DeclarationNameInfo.cs (1)
407f is ForEachStatementSyntax forEachStatement ? forEachStatement.Type :
Completion\KeywordRecommenders\InKeywordRecommender.cs (1)
66if (token.Parent is ForEachStatementSyntax statement && token == statement.Identifier)
ConvertForEachToFor\CSharpConvertForEachToForCodeRefactoringProvider.cs (4)
24AbstractConvertForEachToForCodeRefactoringProvider<StatementSyntax, ForEachStatementSyntax> 35protected override bool IsValid(ForEachStatementSyntax foreachStatement) 53protected override (SyntaxNode start, SyntaxNode end) GetForEachBody(ForEachStatementSyntax foreachStatement) 152protected override bool IsSupported(ILocalSymbol foreachVariable, IForEachLoopOperation forEachOperation, ForEachStatementSyntax foreachStatement)
ConvertLinq\ConvertForEachToLinqQuery\AbstractConverter.cs (10)
24internal abstract class AbstractConverter(ForEachInfo<ForEachStatementSyntax, StatementSyntax> forEachInfo) : IConverter<ForEachStatementSyntax, StatementSyntax> 26public ForEachInfo<ForEachStatementSyntax, StatementSyntax> ForEachInfo { get; } = forEachInfo; 83return CreateFromClause((ForEachStatementSyntax)node.Node, node.ExtraLeadingComments, node.ExtraTrailingComments); 98ForEachStatementSyntax forEachStatement, 145ForEachStatementSyntax forEachStatement, 222/// <param name="hasForEachChild">Flag indicating if any of the processed <see cref="ForEachInfo{ForEachStatementSyntax, StatementSyntax}.ConvertingExtendedNodes"/> is a <see cref="ForEachStatementSyntax"/>.</param> 252var foreachStatement = (ForEachStatementSyntax)node.Node; 274var parentForEachStatement = ifStatement.GetAncestor<ForEachStatementSyntax>();
ConvertLinq\ConvertForEachToLinqQuery\AbstractToMethodConverter.cs (1)
25ForEachInfo<ForEachStatementSyntax, StatementSyntax> forEachInfo,
ConvertLinq\ConvertForEachToLinqQuery\CSharpConvertForEachToLinqQueryProvider.cs (11)
25: AbstractConvertForEachToLinqQueryProvider<ForEachStatementSyntax, StatementSyntax> 33protected override IConverter<ForEachStatementSyntax, StatementSyntax> CreateDefaultConverter( 34ForEachInfo<ForEachStatementSyntax, StatementSyntax> forEachInfo) 37protected override ForEachInfo<ForEachStatementSyntax, StatementSyntax> CreateForEachInfo( 38ForEachStatementSyntax forEachStatement, 100var currentForEachStatement = (ForEachStatementSyntax)current; 162return new ForEachInfo<ForEachStatementSyntax, StatementSyntax>( 210ForEachInfo<ForEachStatementSyntax, StatementSyntax> forEachInfo, 214[NotNullWhen(true)] out IConverter<ForEachStatementSyntax, StatementSyntax>? converter) 338IConverter<ForEachStatementSyntax, StatementSyntax> converter,
ConvertLinq\ConvertForEachToLinqQuery\DefaultConverter.cs (1)
21internal sealed class DefaultConverter(ForEachInfo<ForEachStatementSyntax, StatementSyntax> forEachInfo) : AbstractConverter(forEachInfo)
ConvertLinq\ConvertForEachToLinqQuery\ToCountConverter.cs (1)
18ForEachInfo<ForEachStatementSyntax, StatementSyntax> forEachInfo,
ConvertLinq\ConvertForEachToLinqQuery\ToToListConverter.cs (1)
19ForEachInfo<ForEachStatementSyntax, StatementSyntax> forEachInfo,
ConvertLinq\ConvertForEachToLinqQuery\YieldReturnConverter.cs (1)
16ForEachInfo<ForEachStatementSyntax, StatementSyntax> forEachInfo,
ConvertLinq\CSharpConvertLinqQueryToForEachProvider.cs (4)
232return TryConvertIfInForEach((ForEachStatementSyntax)parent, queryExpressionProcessingInfo, out documentUpdateInfo); 612ForEachStatementSyntax forEachStatement, 682ForEachStatementSyntax forEachStatement, 706ForEachStatementSyntax forEachStatement,
Debugging\CSharpProximityExpressionsService.RelevantExpressionsCollector.cs (1)
62public override void VisitForEachStatement(ForEachStatementSyntax node)
EditAndContinue\BreakpointSpans.cs (2)
676var simpleForEachStatement = (ForEachStatementSyntax)statement;
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (4)
347private static TextSpan GetActiveSpan(ForEachStatementSyntax node, ForEachPart part) 618span = GetActiveSpan((ForEachStatementSyntax)node, (ForEachPart)statementPart); 906case SyntaxKind.ForEachStatement: return AreEquivalentIgnoringLambdaBodies(((ForEachStatementSyntax)oldNode).Type, ((ForEachStatementSyntax)newNode).Type);
EditAndContinue\SyntaxComparer.cs (1)
1305GetLocalNames(((ForEachStatementSyntax)commonForEach).Identifier, ref result);
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs (1)
215public override SyntaxNode VisitForEachStatement(ForEachStatementSyntax node)
InlineHints\CSharpInlineTypeHintsService.cs (1)
67else if (node is ForEachStatementSyntax { Type.IsVar: true } forEachStatement)
Snippets\CSharpForEachLoopSnippetProvider.cs (6)
32internal sealed class CSharpForEachLoopSnippetProvider() : AbstractForEachLoopSnippetProvider<ForEachStatementSyntax> 58protected override ForEachStatementSyntax GenerateStatement(SyntaxGenerator generator, SyntaxContext syntaxContext, InlineExpressionInfo? inlineExpressionInfo) 80ForEachStatementSyntax forEachStatement; 112protected override ImmutableArray<SnippetPlaceholder> GetPlaceHolderLocationsList(ForEachStatementSyntax node, ISyntaxFacts syntaxFacts, CancellationToken cancellationToken) 123protected override int GetTargetCaretPosition(ForEachStatementSyntax forEachStatement, SourceText sourceText) 129protected override Task<Document> AddIndentationToDocumentAsync(Document document, ForEachStatementSyntax forEachStatement, CancellationToken cancellationToken)
src\Analyzers\CSharp\Analyzers\RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (1)
103if (unusedDefinition.Syntax.Parent is ForEachStatementSyntax forEachStatement &&
src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUpdateExpressionSyntaxHelper.cs (2)
22var foreachStatement = (ForEachStatementSyntax)statement;
src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUseCollectionInitializerAnalyzer.cs (1)
108case ForEachStatementSyntax foreachStatement:
src\Analyzers\CSharp\Analyzers\UseDeconstruction\CSharpUseDeconstructionDiagnosticAnalyzer.cs (3)
53case ForEachStatementSyntax forEachStatement: 75SyntaxNodeAnalysisContext context, ForEachStatementSyntax forEachStatement, NotificationOption2 notificationOption) 121ForEachStatementSyntax forEachStatement,
src\Analyzers\CSharp\CodeFixes\MakeStatementAsynchronous\CSharpMakeStatementAsynchronousCodeFixProvider.cs (1)
69case ForEachStatementSyntax forEach:
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (2)
31ForEachStatementSyntax, SwitchSectionSyntax, SwitchLabelSyntax, CatchClauseSyntax, CatchClauseSyntax> 39protected override SyntaxToken GetForEachStatementIdentifier(ForEachStatementSyntax node)
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (2)
497else if (node is ForEachStatementSyntax foreachStatement) 780else if (node is ForEachStatementSyntax foreachStatement)
src\Analyzers\CSharp\CodeFixes\UseDeconstruction\CSharpUseDeconstructionCodeFixProvider.cs (3)
89else if (node is ForEachStatementSyntax forEachStatement) 98(current, _) => CreateForEachVariableStatement(tupleType, (ForEachStatementSyntax)current)); 116private ForEachVariableStatementSyntax CreateForEachVariableStatement(INamedTypeSymbol tupleType, ForEachStatementSyntax forEachStatement)
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (2)
68else if (declarationContext is ForEachStatementSyntax forEach) 109private static Task HandleForEachStatementAsync(Document document, SyntaxEditor editor, ForEachStatementSyntax forEach, CancellationToken cancellationToken)
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (41)
IOperation\IOperationTests.cs (1)
379var op = (IForEachLoopOperation)comp.GetSemanticModel(tree).GetOperation(tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single());
IOperation\IOperationTests_IBranchOperation.Extensions.cs (2)
109AssertOuterIsCorrespondingLoopOfInner<ForEachStatementSyntax, BreakStatementSyntax>(@" 128AssertOuterIsCorrespondingLoopOfInner<ForEachStatementSyntax, BreakStatementSyntax>(@"
IOperation\IOperationTests_IForEachLoopStatement.cs (38)
61VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 114VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 188VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 251VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 314VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 360VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 459VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 507VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 579VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 632VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 663VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 697VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 736VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 780VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 812VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 846VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 878VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 931VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 969VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 1008VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 1079VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree); 1326VerifyOperationTreeAndDiagnosticsForTest<ForEachStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 1514VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree, parseOptions: TestOptions.Regular9); 1567VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree, parseOptions: TestOptions.Regular9); 1613VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree, parseOptions: TestOptions.Regular9); 1672VerifyOperationTreeForTest<ForEachStatementSyntax>(source, expectedOperationTree, parseOptions: TestOptions.Regular9); 1727VerifyOperationTreeForTest<ForEachStatementSyntax>(comp, expectedOperationTree); 1782VerifyOperationTreeForTest<ForEachStatementSyntax>(comp, expectedOperationTree); 1835VerifyOperationTreeForTest<ForEachStatementSyntax>(comp, expectedOperationTree); 1896VerifyOperationTreeForTest<ForEachStatementSyntax>(comp, expectedOperationTree); 2781var op = (Operations.ForEachLoopOperation)VerifyOperationTreeForTest<ForEachStatementSyntax>(comp, @"IForEachLoopOperation (LoopKind.ForEach, IsAsynchronous, Continue Label Id: 0, Exit Label Id: 1) (OperationKind.Loop, Type: null) (Syntax: 'await forea ... }') 2913var op = (Operations.ForEachLoopOperation)VerifyOperationTreeForTest<ForEachStatementSyntax>(comp, @"IForEachLoopOperation (LoopKind.ForEach, IsAsynchronous, Continue Label Id: 0, Exit Label Id: 1) (OperationKind.Loop, Type: null) (Syntax: 'await forea ... }') 3005var op = (Operations.ForEachLoopOperation)VerifyOperationTreeForTest<ForEachStatementSyntax>(comp, @" 5632VerifyOperationTreeForTest<ForEachStatementSyntax>(source + s_IAsyncEnumerable + s_ValueTask, expectedOperationTree); 7592VerifyOperationTreeAndDiagnosticsForTest<ForEachStatementSyntax>(comp, expectedOperationTree, expectedDiagnostics); 7722VerifyOperationTreeAndDiagnosticsForTest<ForEachStatementSyntax>(comp, expectedOperationTree, expectedDiagnostics); 7860VerifyOperationTreeAndDiagnosticsForTest<ForEachStatementSyntax>(comp, expectedOperationTree, expectedDiagnostics); 8004VerifyOperationTreeAndDiagnosticsForTest<ForEachStatementSyntax>(comp, expectedOperationTree, expectedDiagnostics);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (28)
Semantics\ForEachTests.cs (11)
2129var loopSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 2181var loopSyntaxes = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().ToArray(); 2885var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 3326var loop = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 3360var loop = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 3421var node = tree.GetRoot().DescendantNodes().Where(n => n.Kind() == SyntaxKind.ForEachStatement).OfType<ForEachStatementSyntax>().Single();
Semantics\NullableReferenceTypesTests.cs (9)
10534var foreachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().ToArray(); 146304var @foreach = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 146343var @foreach = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 146383var @foreach = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 146422var @foreach = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single();
Semantics\RefFieldTests.cs (6)
14598var decls = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().ToArray(); 14605foreach (var decl in decls) 15051var decls = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().ToArray(); 15077var decls = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().ToArray(); 15132var decls = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().ToArray(); 15144foreach (var decl in decls)
Semantics\UnsafeTests.cs (2)
11877var foreachSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (19)
Compilation\GetSemanticInfoTests.cs (2)
5988var foreachSyntaxNode = root.DescendantNodes().OfType<ForEachStatementSyntax>().Single();
Compilation\SemanticModelAPITests.cs (4)
241var rxDecl = root.DescendantNodes().OfType<ForEachStatementSyntax>().Single(); 1982var statement = (ForEachStatementSyntax)SyntaxFactory.ParseStatement(@"
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (2)
38var rxDecl = root.DescendantNodes().OfType<ForEachStatementSyntax>().Single();
Symbols\ConversionTests.cs (2)
1735var forEachSyntax = tree.GetRoot().DescendantNodes().OfType<ForEachStatementSyntax>().Single();
Symbols\Source\DeclaringSyntaxNodeTests.cs (1)
611CheckDeclaringSyntax<ForEachStatementSyntax>(comp, tree, "loc8", SymbolKind.Local);
Symbols\Source\NullablePublicAPITests.cs (8)
2453var declarations = root.DescendantNodes().OfType<ForEachStatementSyntax>().ToList(); 2460void assertAnnotation(ForEachStatementSyntax foreachStatement) 2501var declarations = root.DescendantNodes().OfType<ForEachStatementSyntax>().ToList(); 2508void assertAnnotation(ForEachStatementSyntax variable, PublicNullableAnnotation expectedAnnotation) 2595var declarations = root.DescendantNodes().OfType<ForEachStatementSyntax>().ToList(); 2600void assertAnnotation(ForEachStatementSyntax foreachStatement, PublicNullableAnnotation expectedElementTypeAnnotation) 3868var @foreach = lambda.DescendantNodes().OfType<ForEachStatementSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (13)
Generated\Syntax.Test.xml.Generated.cs (5)
10616private static ForEachStatementSyntax GenerateForEachStatement() 12516var node = GenerateForEachStatement(); 12528var newNode = node.WithAttributeLists(node.AttributeLists).WithAwaitKeyword(node.AwaitKeyword).WithForEachKeyword(node.ForEachKeyword).WithOpenParenToken(node.OpenParenToken).WithType(node.Type).WithIdentifier(node.Identifier).WithInKeyword(node.InKeyword).WithExpression(node.Expression).WithCloseParenToken(node.CloseParenToken).WithStatement(node.Statement); 17453var oldNode = GenerateForEachStatement(); 17469var oldNode = GenerateForEachStatement();
Parsing\StatementParsingTests.cs (8)
1929var fs = (ForEachStatementSyntax)statement; 1958var fs = (ForEachStatementSyntax)statement; 1991var fs = (ForEachStatementSyntax)statement; 3377var fs = (ForEachStatementSyntax)statement;
Microsoft.CodeAnalysis.CSharp.Test.Utilities (3)
CompilationTestUtils.cs (1)
371(expression.Parent is ForEachStatementSyntax forEach && forEach.Type == expression) ||
Extensions.cs (1)
650declaration is ForEachStatementSyntax ||
LocalVariableDeclaratorsCollector.cs (1)
32public sealed override void VisitForEachStatement(ForEachStatementSyntax node)
Microsoft.CodeAnalysis.CSharp.Workspaces (19)
Classification\ClassificationHelpers.cs (1)
256else if (token.Parent is ForEachStatementSyntax forEachStatementSyntax && forEachStatementSyntax.Identifier == token)
Classification\SyntaxClassification\NameSyntaxClassifier.cs (1)
274name.CheckParent<ForEachStatementSyntax>(f => f.Type == name) ||
Rename\LocalConflictVisitor.cs (1)
63public override void VisitForEachStatement(ForEachStatementSyntax node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
393else if (current.Parent is ForEachStatementSyntax foreachStatement &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (1)
133var node = TryGetAncestorForLocation<ForEachStatementSyntax>(root, position);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (1)
1355=> node?.Parent is ForEachStatementSyntax foreachStatement && foreachStatement.Expression == node;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (2)
657ForEachStatementSyntax foreachStatement => foreachStatement.Type.IsTypeInferred(semanticModel), 896if (forEach is ForEachStatementSyntax foreachStatement)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.cs (2)
91ForEachStatementSyntax forEachStatement => ShouldAnalyzeForEachStatement(forEachStatement, semanticModel, cancellationToken) 115protected virtual bool ShouldAnalyzeForEachStatement(ForEachStatementSyntax forEachStatement, SemanticModel semanticModel, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.State.cs (1)
144ForEachStatementSyntax forEach => forEach.Type,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseExplicitTypeHelper.cs (2)
54protected override bool ShouldAnalyzeForEachStatement(ForEachStatementSyntax forEachStatement, SemanticModel semanticModel, CancellationToken cancellationToken) 104else if (typeName.Parent is ForEachStatementSyntax foreachStatement &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (2)
60protected override bool ShouldAnalyzeForEachStatement(ForEachStatementSyntax forEachStatement, SemanticModel semanticModel, CancellationToken cancellationToken) 152else if (typeName.Parent is ForEachStatementSyntax foreachStatement &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (1)
1652if (outer.Parent is ForEachStatementSyntax @foreach)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (3)
160ForEachStatementSyntax forEachStatement => InferTypeInForEachStatement(forEachStatement, expression), 227ForEachStatementSyntax forEachStatement => InferTypeInForEachStatement(forEachStatement, previousToken: token), 1231private IEnumerable<TypeInferenceInfo> InferTypeInForEachStatement(ForEachStatementSyntax forEachStatementSyntax, ExpressionSyntax expressionOpt = null, SyntaxToken? previousToken = null)