1 instantiation of LocalFunctionStatementSyntax
Microsoft.CodeAnalysis.CSharp (1)
Syntax.xml.Internal.Generated.cs (1)
10296internal override SyntaxNode CreateRed(SyntaxNode? parent, int position) => new CSharp.Syntax.LocalFunctionStatementSyntax(this, parent, position);
531 references to LocalFunctionStatementSyntax
ILLink.CodeFixProvider (1)
BaseAttributeCodeFixProvider.cs (1)
116case LocalFunctionStatementSyntax or BaseMethodDeclarationSyntax or AccessorDeclarationSyntax when targets.HasFlag(AttributeableParentTargets.MethodOrConstructor):
Microsoft.CodeAnalysis.CSharp (75)
Binder\Binder_Statements.cs (3)
70result = BindLocalFunctionStatement((LocalFunctionStatementSyntax)node, diagnostics); 554private BoundStatement BindLocalFunctionStatement(LocalFunctionStatementSyntax node, BindingDiagnosticBag diagnostics) 3596LocalFunctionStatementSyntax => (MessageID?)null,
Binder\LocalBinderFactory.cs (2)
404public override void VisitLocalFunctionStatement(LocalFunctionStatementSyntax node) 439private static LocalFunctionSymbol FindLocalFunction(LocalFunctionStatementSyntax node, Binder enclosing)
Binder\LocalScopeBinder.cs (5)
228var decl = (LocalFunctionStatementSyntax)innerStatement; 320var decl = (LocalFunctionStatementSyntax)innerStatement; 345protected LocalFunctionSymbol MakeLocalFunction(LocalFunctionStatementSyntax declaration)
Compilation\CSharpSemanticModel.cs (2)
2943public abstract IMethodSymbol GetDeclaredSymbol(LocalFunctionStatementSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken)); 5106return this.GetDeclaredSymbol((LocalFunctionStatementSyntax)node, cancellationToken);
Compilation\MemberSemanticModel.cs (6)
231LocalFunctionStatementSyntax ownerOfTypeParametersInScope = null; 255var localFunction = (LocalFunctionStatementSyntax)stmt; 622public override IMethodSymbol GetDeclaredSymbol(LocalFunctionStatementSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken)) 715internal LocalFunctionSymbol GetDeclaredLocalFunction(LocalFunctionStatementSyntax declarationSyntax) 853var localFunction = GetDeclaredSymbol((LocalFunctionStatementSyntax)paramList.Parent, cancellationToken).GetSymbol<MethodSymbol>();
Compilation\PublicSemanticModel.cs (1)
39LocalFunctionStatementSyntax or
Compilation\SpeculativeSemanticModelWithMemberModel.cs (1)
280public override IMethodSymbol GetDeclaredSymbol(LocalFunctionStatementSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
Compilation\SyntaxTreeSemanticModel.cs (2)
1506public override IMethodSymbol GetDeclaredSymbol(LocalFunctionStatementSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken)) 2207case LocalFunctionStatementSyntax localDecl:
CSharpExtensions.cs (1)
1651public static IMethodSymbol? GetDeclaredSymbol(this SemanticModel? semanticModel, LocalFunctionStatementSyntax node, CancellationToken cancellationToken = default(CancellationToken))
FlowAnalysis\NullableWalker.cs (1)
1086LocalFunctionStatementSyntax localFunctionSyntax => localFunctionSyntax.GetLastToken(),
Lowering\ClosureConversion\ClosureConversion.cs (1)
1456else if (syntax is LocalFunctionStatementSyntax localFunction)
Symbols\MethodSymbolExtensions.cs (1)
209else if (node is LocalFunctionStatementSyntax statement)
Symbols\Source\LocalFunctionSymbol.cs (5)
42LocalFunctionStatementSyntax syntax) 104internal LocalFunctionStatementSyntax Syntax => (LocalFunctionStatementSyntax)syntaxReferenceOpt.GetSyntax(); 497var syntax = Syntax; 527var syntax = Syntax;
Symbols\Source\SourceMethodSymbolWithAttributes.cs (2)
56case LocalFunctionStatementSyntax localFunction: 1543LocalFunctionStatementSyntax { ReturnType: var localReturnType } => localReturnType,
Syntax.xml.Main.Generated.cs (8)
346public virtual TResult? VisitLocalFunctionStatement(LocalFunctionStatementSyntax node) => this.DefaultVisit(node); 1090public virtual void VisitLocalFunctionStatement(LocalFunctionStatementSyntax node) => this.DefaultVisit(node); 1833public override SyntaxNode? VisitLocalFunctionStatement(LocalFunctionStatementSyntax node) 3977public static LocalFunctionStatementSyntax LocalFunctionStatement(SyntaxList<AttributeListSyntax> attributeLists, SyntaxTokenList modifiers, TypeSyntax returnType, SyntaxToken identifier, TypeParameterListSyntax? typeParameterList, ParameterListSyntax parameterList, SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken semicolonToken) 3988return (LocalFunctionStatementSyntax)Syntax.InternalSyntax.SyntaxFactory.LocalFunctionStatement(attributeLists.Node.ToGreenList<Syntax.InternalSyntax.AttributeListSyntax>(), modifiers.Node.ToGreenList<Syntax.InternalSyntax.SyntaxToken>(), (Syntax.InternalSyntax.TypeSyntax)returnType.Green, (Syntax.InternalSyntax.SyntaxToken)identifier.Node!, typeParameterList == null ? null : (Syntax.InternalSyntax.TypeParameterListSyntax)typeParameterList.Green, (Syntax.InternalSyntax.ParameterListSyntax)parameterList.Green, constraintClauses.Node.ToGreenList<Syntax.InternalSyntax.TypeParameterConstraintClauseSyntax>(), body == null ? null : (Syntax.InternalSyntax.BlockSyntax)body.Green, expressionBody == null ? null : (Syntax.InternalSyntax.ArrowExpressionClauseSyntax)expressionBody.Green, (Syntax.InternalSyntax.SyntaxToken?)semicolonToken.Node).CreateRed(); 3992public static LocalFunctionStatementSyntax LocalFunctionStatement(SyntaxList<AttributeListSyntax> attributeLists, SyntaxTokenList modifiers, TypeSyntax returnType, SyntaxToken identifier, TypeParameterListSyntax? typeParameterList, ParameterListSyntax parameterList, SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody) 3996public static LocalFunctionStatementSyntax LocalFunctionStatement(TypeSyntax returnType, SyntaxToken identifier) 4000public static LocalFunctionStatementSyntax LocalFunctionStatement(TypeSyntax returnType, string identifier)
Syntax.xml.Syntax.Generated.cs (19)
6394public LocalFunctionStatementSyntax Update(SyntaxList<AttributeListSyntax> attributeLists, SyntaxTokenList modifiers, TypeSyntax returnType, SyntaxToken identifier, TypeParameterListSyntax? typeParameterList, ParameterListSyntax parameterList, SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken semicolonToken) 6398var newNode = SyntaxFactory.LocalFunctionStatement(attributeLists, modifiers, returnType, identifier, typeParameterList, parameterList, constraintClauses, body, expressionBody, semicolonToken); 6407public new LocalFunctionStatementSyntax WithAttributeLists(SyntaxList<AttributeListSyntax> attributeLists) => Update(attributeLists, this.Modifiers, this.ReturnType, this.Identifier, this.TypeParameterList, this.ParameterList, this.ConstraintClauses, this.Body, this.ExpressionBody, this.SemicolonToken); 6408public LocalFunctionStatementSyntax WithModifiers(SyntaxTokenList modifiers) => Update(this.AttributeLists, modifiers, this.ReturnType, this.Identifier, this.TypeParameterList, this.ParameterList, this.ConstraintClauses, this.Body, this.ExpressionBody, this.SemicolonToken); 6409public LocalFunctionStatementSyntax WithReturnType(TypeSyntax returnType) => Update(this.AttributeLists, this.Modifiers, returnType, this.Identifier, this.TypeParameterList, this.ParameterList, this.ConstraintClauses, this.Body, this.ExpressionBody, this.SemicolonToken); 6410public LocalFunctionStatementSyntax WithIdentifier(SyntaxToken identifier) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, identifier, this.TypeParameterList, this.ParameterList, this.ConstraintClauses, this.Body, this.ExpressionBody, this.SemicolonToken); 6411public LocalFunctionStatementSyntax WithTypeParameterList(TypeParameterListSyntax? typeParameterList) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.Identifier, typeParameterList, this.ParameterList, this.ConstraintClauses, this.Body, this.ExpressionBody, this.SemicolonToken); 6412public LocalFunctionStatementSyntax WithParameterList(ParameterListSyntax parameterList) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.Identifier, this.TypeParameterList, parameterList, this.ConstraintClauses, this.Body, this.ExpressionBody, this.SemicolonToken); 6413public LocalFunctionStatementSyntax WithConstraintClauses(SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.Identifier, this.TypeParameterList, this.ParameterList, constraintClauses, this.Body, this.ExpressionBody, this.SemicolonToken); 6414public LocalFunctionStatementSyntax WithBody(BlockSyntax? body) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.Identifier, this.TypeParameterList, this.ParameterList, this.ConstraintClauses, body, this.ExpressionBody, this.SemicolonToken); 6415public LocalFunctionStatementSyntax WithExpressionBody(ArrowExpressionClauseSyntax? expressionBody) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.Identifier, this.TypeParameterList, this.ParameterList, this.ConstraintClauses, this.Body, expressionBody, this.SemicolonToken); 6416public LocalFunctionStatementSyntax WithSemicolonToken(SyntaxToken semicolonToken) => Update(this.AttributeLists, this.Modifiers, this.ReturnType, this.Identifier, this.TypeParameterList, this.ParameterList, this.ConstraintClauses, this.Body, this.ExpressionBody, semicolonToken); 6419public new LocalFunctionStatementSyntax AddAttributeLists(params AttributeListSyntax[] items) => WithAttributeLists(this.AttributeLists.AddRange(items)); 6420public LocalFunctionStatementSyntax AddModifiers(params SyntaxToken[] items) => WithModifiers(this.Modifiers.AddRange(items)); 6421public LocalFunctionStatementSyntax AddTypeParameterListParameters(params TypeParameterSyntax[] items) 6426public LocalFunctionStatementSyntax AddParameterListParameters(params ParameterSyntax[] items) => WithParameterList(this.ParameterList.WithParameters(this.ParameterList.Parameters.AddRange(items))); 6427public LocalFunctionStatementSyntax AddConstraintClauses(params TypeParameterConstraintClauseSyntax[] items) => WithConstraintClauses(this.ConstraintClauses.AddRange(items)); 6428public LocalFunctionStatementSyntax AddBodyAttributeLists(params AttributeListSyntax[] items) 6433public LocalFunctionStatementSyntax AddBodyStatements(params StatementSyntax[] items)
Syntax\LambdaUtilities.cs (7)
118return GetLocalFunctionBody((LocalFunctionStatementSyntax)newLambda); 129LocalFunctionStatementSyntax localFunctionStatementSyntax => (CSharpSyntaxNode?)localFunctionStatementSyntax.Body ?? localFunctionStatementSyntax.ExpressionBody!.Expression, 158var localFunction = (LocalFunctionStatementSyntax)parent; 163return arrowExpressionClause.Expression == node && arrowExpressionClause.Parent is LocalFunctionStatementSyntax; 352lambdaBody1 = GetLocalFunctionBody((LocalFunctionStatementSyntax)node); 486private static SyntaxNode? GetLocalFunctionBody(LocalFunctionStatementSyntax localFunctionStatementSyntax)
Syntax\LocalFunctionStatementSyntax.cs (3)
12public LocalFunctionStatementSyntax Update(SyntaxTokenList modifiers, TypeSyntax returnType, SyntaxToken identifier, TypeParameterListSyntax typeParameterList, ParameterListSyntax parameterList, SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses, BlockSyntax body, ArrowExpressionClauseSyntax expressionBody, SyntaxToken semicolonToken) 24public static LocalFunctionStatementSyntax LocalFunctionStatement(SyntaxTokenList modifiers, TypeSyntax returnType, SyntaxToken identifier, TypeParameterListSyntax? typeParameterList, ParameterListSyntax parameterList, SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody) 30public static LocalFunctionStatementSyntax LocalFunctionStatement(SyntaxTokenList modifiers, TypeSyntax returnType, SyntaxToken identifier, TypeParameterListSyntax? typeParameterList, ParameterListSyntax parameterList, SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody, SyntaxToken semicolonToken)
Syntax\LookupPosition.cs (3)
229internal static bool IsInLocalFunctionTypeParameterScope(int position, LocalFunctionStatementSyntax localFunction) 442LocalFunctionStatementSyntax localFunctionStmt = (LocalFunctionStatementSyntax)statement;
Syntax\SyntaxFacts.cs (1)
188return ((LocalFunctionStatementSyntax)parent).ReturnType == node;
Syntax\SyntaxNodeExtensions.cs (1)
267(current.Parent is LocalFunctionStatementSyntax localFunction && localFunction.ReturnType == current) ||
Microsoft.CodeAnalysis.CSharp.CodeStyle (38)
src\Analyzers\CSharp\Analyzers\MakeLocalFunctionStatic\MakeLocalFunctionStaticDiagnosticAnalyzer.cs (2)
37var localFunction = (LocalFunctionStatementSyntax)context.Node;
src\Analyzers\CSharp\Analyzers\MakeLocalFunctionStatic\MakeLocalFunctionStaticHelper.cs (5)
17private static bool TryGetDataFlowAnalysis(LocalFunctionStatementSyntax localFunction, SemanticModel semanticModel, [NotNullWhen(returnValue: true)] out DataFlowAnalysis? dataFlow) 23private static bool CanBeCalledFromStaticContext(LocalFunctionStatementSyntax localFunction, DataFlowAnalysis dataFlow) 30static bool IsChildOrSelf(LocalFunctionStatementSyntax containingLocalFunction, ISymbol calledLocationFunction) 38public static bool CanMakeLocalFunctionStaticBecauseNoCaptures(LocalFunctionStatementSyntax localFunction, SemanticModel semanticModel) 43public static bool CanMakeLocalFunctionStaticByRefactoringCaptures(LocalFunctionStatementSyntax localFunction, SemanticModel semanticModel, out ImmutableArray<ISymbol> captures)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryUnsafeModifier\UnnecessaryUnsafeModifierUtilities.cs (4)
49if (existingNode is not MemberDeclarationSyntax and not LocalFunctionStatementSyntax) 67LocalFunctionStatementSyntax => NodeGroup.LocalFunctions, 126LocalFunctionStatementSyntax localFunction => localFunction.WithModifiers(GetNewModifierList(localFunction)), 137LocalFunctionStatementSyntax localFunction => localFunction.Modifiers,
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyForLocalFunctionHelper.cs (11)
18UseExpressionBodyHelper<LocalFunctionStatementSyntax> 35protected override BlockSyntax GetBody(LocalFunctionStatementSyntax statement) 38protected override ArrowExpressionClauseSyntax GetExpressionBody(LocalFunctionStatementSyntax statement) 41protected override SyntaxToken GetSemicolonToken(LocalFunctionStatementSyntax statement) 44protected override LocalFunctionStatementSyntax WithSemicolonToken(LocalFunctionStatementSyntax statement, SyntaxToken token) 47protected override LocalFunctionStatementSyntax WithExpressionBody(LocalFunctionStatementSyntax statement, ArrowExpressionClauseSyntax expressionBody) 50protected override LocalFunctionStatementSyntax WithBody(LocalFunctionStatementSyntax statement, BlockSyntax body) 54SemanticModel semanticModel, LocalFunctionStatementSyntax statement, CancellationToken cancellationToken)
src\Analyzers\CSharp\Analyzers\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (1)
106LocalFunctionStatementSyntax localFunction => (localFunction.ReturnType, localFunction.Modifiers.Any(SyntaxKind.AsyncKeyword)),
src\Analyzers\CSharp\Analyzers\UseSimpleUsingStatement\UseSimpleUsingStatementDiagnosticAnalyzer.cs (1)
240while (index + 1 < statements.Count && statements[index + 1] is LocalFunctionStatementSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ILocalSymbolExtensions.cs (3)
18var localFunctionStatement = destinationBlock.FirstAncestorOrSelf<LocalFunctionStatementSyntax>(); 38case LocalFunctionStatementSyntax localFunctionStatement:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
471public static IMethodSymbol GetRequiredDeclaredSymbol(this SemanticModel semanticModel, LocalFunctionStatementSyntax syntax, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (5)
153LocalFunctionStatementSyntax localFunction => localFunction.ParameterList, 282=> node is MethodDeclarationSyntax or AnonymousFunctionExpressionSyntax or LocalFunctionStatementSyntax; 345case LocalFunctionStatementSyntax localFunction when localFunction.Modifiers.Any(SyntaxKind.StaticKeyword): 745LocalFunctionStatementSyntax localFunction => localFunction.Modifiers, 757LocalFunctionStatementSyntax localFunction => localFunction.WithModifiers(modifiers),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (1)
470else if (currentToken.Parent is LocalFunctionStatementSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (1)
212if (node is AnonymousFunctionExpressionSyntax or LocalFunctionStatementSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (1)
155LocalFunctionStatementSyntax localFunc => localFunc.Modifiers,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (2)
70var node = TryGetAncestorForLocation<LocalFunctionStatementSyntax>(root, position, out localFunction);
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (37)
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AssignOutParametersAboveReturnCodeFixProvider.cs (1)
48if (exprOrStatement is LocalFunctionStatementSyntax { ExpressionBody: { } localFunctionExpressionBody })
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AssignOutParametersAtStartCodeFixProvider.cs (1)
33if (location is LocalFunctionStatementSyntax { ExpressionBody: { } })
src\Analyzers\CSharp\CodeFixes\FixReturnType\CSharpFixReturnTypeCodeFixProvider.cs (1)
147LocalFunctionStatementSyntax localFunction => (localFunction.ReturnType, localFunction.Modifiers.Any(SyntaxKind.AsyncKeyword)),
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeFixHelper.cs (4)
28LocalFunctionStatementSyntax localFunction, 40LocalFunctionStatementSyntax localFunction, 174var localFunctionWithNewParameters = (LocalFunctionStatementSyntax)info.Service.AddParameters(
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\PassInCapturedVariablesAsArgumentsCodeFixProvider.cs (3)
65Func<Document, LocalFunctionStatementSyntax, ImmutableArray<ISymbol>, Task> fixer, 77.Select(d => root.FindNode(d.Location.SourceSpan).AncestorsAndSelf().OfType<LocalFunctionStatementSyntax>().FirstOrDefault()) 87foreach (var localFunction in localFunctions)
src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (3)
85LocalFunctionStatementSyntax localFunction => FixLocalFunction(keepVoid, methodSymbol, localFunction, knownTypes), 111private static LocalFunctionStatementSyntax FixLocalFunction( 114LocalFunctionStatementSyntax localFunction,
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (1)
145LocalFunctionStatementSyntax localFunction =>
src\Analyzers\CSharp\CodeFixes\RemoveUnusedLocalFunction\CSharpRemoveUnusedLocalFunctionCodeFixProvider.cs (2)
47.Select(t => t.GetAncestor<LocalFunctionStatementSyntax>()); 49foreach (var localFunction in localFunctions)
src\Analyzers\CSharp\CodeFixes\UseLocalFunction\CSharpUseLocalFunctionCodeFixProvider.cs (2)
158var newLocalFunctionStatement = CreateLocalFunctionStatement(localDeclaration, anonymousFunction, delegateMethod, parameterList, makeStatic) 198private static LocalFunctionStatementSyntax CreateLocalFunctionStatement(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (3)
492else if (destinationMember is LocalFunctionStatementSyntax localFunctionStatement) 613TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, LocalFunctionStatementSyntax localFunctionStatement) where TDeclarationNode : SyntaxNode 625var finalMember = localFunctionStatement
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (8)
92public static LocalFunctionStatementSyntax GenerateLocalFunctionDeclaration( 98var reusableSyntax = GetReuseableSyntaxNodeForSymbol<LocalFunctionStatementSyntax>(method, info); 104var declaration = GenerateLocalFunctionDeclarationWorker( 164private static LocalFunctionStatementSyntax GenerateLocalFunctionDeclarationWorker( 168var localFunctionDeclaration = LocalFunctionStatement( 201private static LocalFunctionStatementSyntax UseExpressionBodyIfDesired( 202CSharpCodeGenerationContextInfo info, LocalFunctionStatementSyntax localFunctionDeclaration, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (1)
506targetToken.GetAncestors<LocalFunctionStatementSyntax>().Any(f => f.GetModifiers().Any(SyntaxKind.UnsafeKeyword))) ||
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (1)
1131MethodDeclarationSyntax or LocalFunctionStatementSyntax or ConstructorDeclarationSyntax or DelegateDeclarationSyntax or TypeDeclarationSyntax => true,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ExpressionSyntaxExtensions.cs (1)
168if (name.IsFoundUnder<LocalFunctionStatementSyntax>(d => d.ReturnType) ||
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpMoveDeclarationNearReferenceService.cs (1)
35LocalFunctionStatementSyntax or
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSemanticFactsService.cs (1)
48if (container.Parent is LocalFunctionStatementSyntax or TypeDeclarationSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\InitializeParameter\InitializeParameterHelpers.cs (3)
134=> node is BaseMethodDeclarationSyntax or LocalFunctionStatementSyntax or AnonymousFunctionExpressionSyntax; 140LocalFunctionStatementSyntax localFunction => (SyntaxNode?)localFunction.Body ?? localFunction.ExpressionBody!, 149LocalFunctionStatementSyntax localFunction => localFunction.SemicolonToken,
Microsoft.CodeAnalysis.CSharp.EditorFeatures (8)
AutomaticCompletion\AutomaticLineEnderCommandHandler.cs (2)
319or LocalFunctionStatementSyntax 395or LocalFunctionStatementSyntax
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (6)
467LocalFunctionStatementSyntax localFunctionStatementNode => ShouldAddBraceForLocalFunctionStatement(localFunctionStatementNode, caretPosition), 522private static bool ShouldAddBraceForLocalFunctionStatement(LocalFunctionStatementSyntax localFunctionStatementNode, int caretPosition) 752if (node is LocalFunctionStatementSyntax { Body: { } localFunctionBody }) 874LocalFunctionStatementSyntax localFunctionStatementNode => AddBlockToLocalFunctionDeclaration(localFunctionStatementNode, formattingOptions), 910private static LocalFunctionStatementSyntax AddBlockToLocalFunctionDeclaration( 911LocalFunctionStatementSyntax localFunctionStatementNode,
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (31)
RefactoringHelpers\RefactoringHelpersTests.cs (31)
19=> TestAsync<LocalFunctionStatementSyntax>(""" 34=> TestAsync<LocalFunctionStatementSyntax>(""" 49=> TestAsync<LocalFunctionStatementSyntax>(""" 64=> TestMissingAsync<LocalFunctionStatementSyntax>(""" 80=> TestAsync<LocalFunctionStatementSyntax>(""" 95=> TestAsync<LocalFunctionStatementSyntax>(""" 110=> TestAsync<LocalFunctionStatementSyntax>(""" 128=> TestMissingAsync<LocalFunctionStatementSyntax>(""" 143=> TestMissingAsync<LocalFunctionStatementSyntax>(""" 161=> TestMissingAsync<LocalFunctionStatementSyntax>(""" 179=> TestMissingAsync<LocalFunctionStatementSyntax>(""" 195=> TestAsync<LocalFunctionStatementSyntax>(""" 210=> TestAsync<LocalFunctionStatementSyntax>(""" 226=> TestMissingAsync<LocalFunctionStatementSyntax>(""" 243=> TestAsync<LocalFunctionStatementSyntax>(""" 259=> TestMissingAsync<LocalFunctionStatementSyntax>(""" 343=> TestAsync<LocalFunctionStatementSyntax>(""" 358=> TestAsync<LocalFunctionStatementSyntax>(""" 373=> TestAsync<LocalFunctionStatementSyntax>(""" 388=> TestMissingAsync<LocalFunctionStatementSyntax>(""" 403=> TestMissingAsync<LocalFunctionStatementSyntax>(""" 418=> TestMissingAsync<LocalFunctionStatementSyntax>(""" 433=> TestMissingAsync<LocalFunctionStatementSyntax>(""" 448=> TestAsync<LocalFunctionStatementSyntax>(""" 463=> TestAsync<LocalFunctionStatementSyntax>(""" 482=> TestAsync<LocalFunctionStatementSyntax>(""" 499=> TestMissingAsync<LocalFunctionStatementSyntax>(""" 516=> TestMissingAsync<LocalFunctionStatementSyntax>(""" 1029=> TestAsync<LocalFunctionStatementSyntax>(""" 1048=> TestAsync<LocalFunctionStatementSyntax>(""" 1070=> TestMissingAsync<LocalFunctionStatementSyntax>("""
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (10)
CodeGen\CodeGenLocalFunctionTests.cs (6)
146var localFunction = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 5749.GetDeclaredSymbol(syntaxTree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single()) 5824.GetDeclaredSymbol(syntaxTree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single()) 5897var localFunctions = syntaxTree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToList(); 5905void checkImplAttributes(LocalFunctionStatementSyntax localFunctionStatement, MethodImplAttributes expectedFlags)
Emit\InAttributeModifierTests.cs (4)
1900var localFunc = model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single()).GetSymbol<MethodSymbol>(); 1958var localFunc = model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single()).GetSymbol<MethodSymbol>(); 2000var localFunc = model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single()).GetSymbol<MethodSymbol>(); 2052var localFunc = model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single()).GetSymbol<MethodSymbol>();
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (7)
Attributes\AttributeTests_WellKnownAttributes.cs (2)
5768var localFunctionSyntax = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single();
RefStructInterfacesTests.cs (2)
21643var localFunctions = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToArray(); 21646foreach (var localFunction in localFunctions)
Semantics\OutVarTests.cs (3)
36404Assert.Same(symbolInfo.Symbol, speculativeModel.GetDeclaredSymbol(tree2.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Where(l => l.Identifier.ValueText == "M2").Single())); 36486Assert.Same(symbolInfo.Symbol, speculativeModel.GetDeclaredSymbol(tree2.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Where(l => l.Identifier.ValueText == "M2").Single())); 36559Assert.Same(symbolInfo.Symbol, speculativeModel.GetDeclaredSymbol(tree2.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Where(l => l.Identifier.ValueText == "M2").Single()));
Microsoft.CodeAnalysis.CSharp.Features (103)
ChangeSignature\CSharpChangeSignatureService.cs (1)
333if (updatedNode is LocalFunctionStatementSyntax localFunction)
CodeRefactorings\ConvertLocalFunctionToMethod\CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs (5)
39var localFunction = await context.TryGetRelevantNodeAsync<LocalFunctionStatementSyntax>().ConfigureAwait(false); 66LocalFunctionStatementSyntax localFunction, 254LocalFunctionStatementSyntax localFunction, 307MethodDeclarationSyntax method, LocalFunctionStatementSyntax localFunction)
Completion\CompletionProviders\AwaitCompletionProvider.cs (3)
41LocalFunctionStatementSyntax local => local.ReturnType.SpanStart, 57LocalFunctionStatementSyntax local => local.ReturnType, 108if (parent is NameSyntax { Parent: LocalFunctionStatementSyntax localFunction } name &&
Completion\CompletionProviders\DeclarationName\DeclarationNameInfo.cs (1)
412result = IsLastTokenOfType<LocalFunctionStatementSyntax>(token, semanticModel,
Completion\KeywordRecommenders\MethodKeywordRecommender.cs (1)
29or LocalFunctionStatementSyntax
Completion\KeywordRecommenders\WhereKeywordRecommender.cs (1)
64or LocalFunctionStatementSyntax { TypeParameterList: not null }
ConvertLinq\CSharpConvertLinqQueryToForEachProvider.cs (1)
581var localFunctionDeclaration = LocalFunctionStatement(
EditAndContinue\BreakpointSpans.cs (2)
420var localFunction = (LocalFunctionStatementSyntax)node;
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (5)
459if (root is LocalFunctionStatementSyntax localFunc) 1466=> node is LocalFunctionStatementSyntax { TypeParameterList: not null }; 1469=> node is AnonymousFunctionExpressionSyntax or LocalFunctionStatementSyntax; 1836var lfd = (LocalFunctionStatementSyntax)node;
EditAndContinue\SyntaxComparer.cs (2)
1027var localFunction = (LocalFunctionStatementSyntax)nestedFunction;
EditAndContinue\SyntaxUtilities.cs (1)
224LocalFunctionStatementSyntax localFunction => localFunction.Modifiers.Any(SyntaxKind.AsyncKeyword),
ExtractMethod\CSharpMethodExtractor.cs (1)
80if (currentNode is LocalFunctionStatementSyntax localFunction)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (6)
1013LocalFunctionStatementSyntax localFunction => TweakNewLinesInMethod(localFunction), 1026private static LocalFunctionStatementSyntax TweakNewLinesInMethod(LocalFunctionStatementSyntax method) 1061var nodeIsMethodOrLocalFunction = syntaxNode is MethodDeclarationSyntax or LocalFunctionStatementSyntax; 1069var returnType = syntaxNode is MethodDeclarationSyntax method ? method.ReturnType : ((LocalFunctionStatementSyntax)syntaxNode).ReturnType; 1080LocalFunctionStatementSyntax _ => true,
ExtractMethod\CSharpMethodExtractor.TriviaResult.cs (3)
25var isMethodOrLocalFunction = method is MethodDeclarationSyntax or LocalFunctionStatementSyntax; 36var isMethodOrLocalFunction = method is MethodDeclarationSyntax or LocalFunctionStatementSyntax; 126LocalFunctionStatementSyntax localFunctionDeclaration => (localFunctionDeclaration.Body, localFunctionDeclaration.ExpressionBody, localFunctionDeclaration.SemicolonToken),
ExtractMethod\CSharpSelectionResult.StatementResult.cs (3)
32LocalFunctionStatementSyntax localFunction => localFunction.Modifiers.Any(SyntaxKind.AsyncKeyword), 43LocalFunctionStatementSyntax or 64case LocalFunctionStatementSyntax localFunction:
ExtractMethod\CSharpSelectionValidator.cs (1)
155if (current is AnonymousFunctionExpressionSyntax or LocalFunctionStatementSyntax or MemberDeclarationSyntax)
Highlighting\KeywordHighlighters\AsyncAwaitHighlighter.cs (1)
74LocalFunctionStatementSyntax localFunction => TryAddAsyncModifier(localFunction.Modifiers, spans),
IntroduceVariable\CSharpIntroduceVariableService.cs (2)
142var localFunction = expression.GetAncestor<LocalFunctionStatementSyntax>();
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (6)
280LocalFunctionStatementSyntax localFunction => localFunction 302var localFunction = expression.GetAncestor<LocalFunctionStatementSyntax>(); 371var localFunction = block.GetAncestor<LocalFunctionStatementSyntax>(); 456var localFunctionIdentifiers = localFunctions.Select(node => ((LocalFunctionStatementSyntax)node).Identifier.ValueText);
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (2)
79case LocalFunctionStatementSyntax: 106LocalFunctionStatementSyntax or AccessorDeclarationSyntax or MemberDeclarationSyntax
LanguageServices\CSharpSymbolDisplayService.SymbolDescriptionBuilder.cs (1)
257if (syntax is LocalFunctionStatementSyntax or AnonymousFunctionExpressionSyntax)
MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeRefactoringProvider.cs (2)
33var localFunction = await context.TryGetRelevantNodeAsync<LocalFunctionStatementSyntax>().ConfigureAwait(false);
NavigationBar\CSharpNavigationBarItemService.cs (2)
222n == node || n is not LocalFunctionStatementSyntax).Where(n => n is LocalFunctionStatementSyntax);
src\Analyzers\CSharp\Analyzers\MakeLocalFunctionStatic\MakeLocalFunctionStaticDiagnosticAnalyzer.cs (2)
37var localFunction = (LocalFunctionStatementSyntax)context.Node;
src\Analyzers\CSharp\Analyzers\MakeLocalFunctionStatic\MakeLocalFunctionStaticHelper.cs (5)
17private static bool TryGetDataFlowAnalysis(LocalFunctionStatementSyntax localFunction, SemanticModel semanticModel, [NotNullWhen(returnValue: true)] out DataFlowAnalysis? dataFlow) 23private static bool CanBeCalledFromStaticContext(LocalFunctionStatementSyntax localFunction, DataFlowAnalysis dataFlow) 30static bool IsChildOrSelf(LocalFunctionStatementSyntax containingLocalFunction, ISymbol calledLocationFunction) 38public static bool CanMakeLocalFunctionStaticBecauseNoCaptures(LocalFunctionStatementSyntax localFunction, SemanticModel semanticModel) 43public static bool CanMakeLocalFunctionStaticByRefactoringCaptures(LocalFunctionStatementSyntax localFunction, SemanticModel semanticModel, out ImmutableArray<ISymbol> captures)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryUnsafeModifier\UnnecessaryUnsafeModifierUtilities.cs (4)
49if (existingNode is not MemberDeclarationSyntax and not LocalFunctionStatementSyntax) 67LocalFunctionStatementSyntax => NodeGroup.LocalFunctions, 126LocalFunctionStatementSyntax localFunction => localFunction.WithModifiers(GetNewModifierList(localFunction)), 137LocalFunctionStatementSyntax localFunction => localFunction.Modifiers,
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyForLocalFunctionHelper.cs (11)
18UseExpressionBodyHelper<LocalFunctionStatementSyntax> 35protected override BlockSyntax GetBody(LocalFunctionStatementSyntax statement) 38protected override ArrowExpressionClauseSyntax GetExpressionBody(LocalFunctionStatementSyntax statement) 41protected override SyntaxToken GetSemicolonToken(LocalFunctionStatementSyntax statement) 44protected override LocalFunctionStatementSyntax WithSemicolonToken(LocalFunctionStatementSyntax statement, SyntaxToken token) 47protected override LocalFunctionStatementSyntax WithExpressionBody(LocalFunctionStatementSyntax statement, ArrowExpressionClauseSyntax expressionBody) 50protected override LocalFunctionStatementSyntax WithBody(LocalFunctionStatementSyntax statement, BlockSyntax body) 54SemanticModel semanticModel, LocalFunctionStatementSyntax statement, CancellationToken cancellationToken)
src\Analyzers\CSharp\Analyzers\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (1)
106LocalFunctionStatementSyntax localFunction => (localFunction.ReturnType, localFunction.Modifiers.Any(SyntaxKind.AsyncKeyword)),
src\Analyzers\CSharp\Analyzers\UseSimpleUsingStatement\UseSimpleUsingStatementDiagnosticAnalyzer.cs (1)
240while (index + 1 < statements.Count && statements[index + 1] is LocalFunctionStatementSyntax)
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AssignOutParametersAboveReturnCodeFixProvider.cs (1)
48if (exprOrStatement is LocalFunctionStatementSyntax { ExpressionBody: { } localFunctionExpressionBody })
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AssignOutParametersAtStartCodeFixProvider.cs (1)
33if (location is LocalFunctionStatementSyntax { ExpressionBody: { } })
src\Analyzers\CSharp\CodeFixes\FixReturnType\CSharpFixReturnTypeCodeFixProvider.cs (1)
147LocalFunctionStatementSyntax localFunction => (localFunction.ReturnType, localFunction.Modifiers.Any(SyntaxKind.AsyncKeyword)),
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeFixHelper.cs (4)
28LocalFunctionStatementSyntax localFunction, 40LocalFunctionStatementSyntax localFunction, 174var localFunctionWithNewParameters = (LocalFunctionStatementSyntax)info.Service.AddParameters(
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\PassInCapturedVariablesAsArgumentsCodeFixProvider.cs (3)
65Func<Document, LocalFunctionStatementSyntax, ImmutableArray<ISymbol>, Task> fixer, 77.Select(d => root.FindNode(d.Location.SourceSpan).AncestorsAndSelf().OfType<LocalFunctionStatementSyntax>().FirstOrDefault()) 87foreach (var localFunction in localFunctions)
src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (3)
85LocalFunctionStatementSyntax localFunction => FixLocalFunction(keepVoid, methodSymbol, localFunction, knownTypes), 111private static LocalFunctionStatementSyntax FixLocalFunction( 114LocalFunctionStatementSyntax localFunction,
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (1)
145LocalFunctionStatementSyntax localFunction =>
src\Analyzers\CSharp\CodeFixes\RemoveUnusedLocalFunction\CSharpRemoveUnusedLocalFunctionCodeFixProvider.cs (2)
47.Select(t => t.GetAncestor<LocalFunctionStatementSyntax>()); 49foreach (var localFunction in localFunctions)
src\Analyzers\CSharp\CodeFixes\UseLocalFunction\CSharpUseLocalFunctionCodeFixProvider.cs (2)
158var newLocalFunctionStatement = CreateLocalFunctionStatement(localDeclaration, anonymousFunction, delegateMethod, parameterList, makeStatic) 198private static LocalFunctionStatementSyntax CreateLocalFunctionStatement(
src\Compilers\CSharp\Portable\Syntax\LambdaUtilities.cs (7)
118return GetLocalFunctionBody((LocalFunctionStatementSyntax)newLambda); 129LocalFunctionStatementSyntax localFunctionStatementSyntax => (CSharpSyntaxNode?)localFunctionStatementSyntax.Body ?? localFunctionStatementSyntax.ExpressionBody!.Expression, 158var localFunction = (LocalFunctionStatementSyntax)parent; 163return arrowExpressionClause.Expression == node && arrowExpressionClause.Parent is LocalFunctionStatementSyntax; 352lambdaBody1 = GetLocalFunctionBody((LocalFunctionStatementSyntax)node); 486private static SyntaxNode? GetLocalFunctionBody(LocalFunctionStatementSyntax localFunctionStatementSyntax)
UsePatternMatching\CSharpIsAndCastCheckWithoutNameDiagnosticAnalyzer.cs (1)
184if (node is LocalFunctionStatementSyntax localFunction && localFunction.Modifiers.Any(SyntaxKind.StaticKeyword))
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (6)
EditAndContinue\SyntaxUtilitiesTests.cs (6)
184var f1 = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(m => m.Identifier.ValueText == "f1"); 185var f2 = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(m => m.Identifier.ValueText == "f2"); 250var f = m2.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(m => m.Identifier.ValueText == "f");
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (18)
IOperation\IOperationTests_ILocalFunctionStatement.cs (17)
49VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 77VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 105VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 140VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 181VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 217VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 266VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics, targetFramework: TargetFramework.Mscorlib46Extended); 295VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 331VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 365VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 404VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 436VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 468VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 503VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 547VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 640VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 703VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics);
IOperation\IOperationTests_IParameterReferenceExpression.cs (1)
1119VerifyOperationTreeAndDiagnosticsForTest<LocalFunctionStatementSyntax>(source, expectedOperationTree, expectedDiagnostics);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (64)
Semantics\InitOnlyMemberTests.cs (2)
4143var localFunctionSyntax = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single();
Semantics\LocalFunctionTests.cs (25)
487var localFunction = tree.GetRoot().DescendantNodes() 488.OfType<LocalFunctionStatementSyntax>() 535var localFunction = tree.GetRoot().DescendantNodes() 536.OfType<LocalFunctionStatementSyntax>() 799var localFunction = tree.GetRoot().DescendantNodes() 800.OfType<LocalFunctionStatementSyntax>() 846var localFunction = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 962var localFunction = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 2365LocalFunctionStatementSyntax declaration = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().First(); 2581var exprs = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToImmutableArray(); 2894var func = tree2.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 5410var localDecl = (LocalFunctionStatementSyntax)tree.FindNodeOrTokenByKind(SyntaxKind.LocalFunctionStatement).AsNode(); 10687var localFunction = root.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 11047var localFunctionSyntaxes = syntaxTree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToArray(); 11049var i1Syntax = localFunctionSyntaxes[0]; 11053var i2Syntax = localFunctionSyntaxes[1]; 11088var localFunctionSyntaxes = syntaxTree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToArray(); 11090var i1Syntax = localFunctionSyntaxes[0]; 11094var i2Syntax = localFunctionSyntaxes[1];
Semantics\NullableReferenceTypesTests.cs (10)
65973var function1 = tree1.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Last(); 65977var function2 = tree2.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 97883var localSyntaxes = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToArray(); 99212var localSyntaxes = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToArray(); 111896var localSyntaxes = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>(); 111901void verifyLocalFunction(LocalFunctionStatementSyntax localSyntax, string expectedName, string[] expectedConstraintTypes) 111950var localSyntaxes = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>(); 111954void verifyLocalFunction(LocalFunctionStatementSyntax localSyntax, string expectedName, string[] expectedConstraintTypes)
Semantics\RefFieldTests.cs (1)
11087var decls = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToArray();
Semantics\SimpleLambdaParametersWithModifiersTests.cs (2)
540var lambda = root.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single();
Semantics\TopLevelStatementsTests.cs (18)
236var localDecl = unit1.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 359var localDecl = unit2.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 2121var localDecl = tree1.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 2285var localDecl = tree1.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 4252var declarator = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 4547var symbol1 = model1.GetDeclaredSymbol(tree1.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single()); 4553var symbol2 = model2.GetDeclaredSymbol(tree2.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().First()); 4611var symbol1 = model1.GetDeclaredSymbol(tree1.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().First()); 4615var symbol2 = model1.GetDeclaredSymbol(tree1.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Skip(1).First()); 4660var symbol1 = model1.GetDeclaredSymbol(tree1.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().First()); 6177var localFunctions = syntaxTree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToList(); 6185void checkImplAttributes(LocalFunctionStatementSyntax localFunctionStatement, MethodImplAttributes expectedFlags) 6251.GetDeclaredSymbol(syntaxTree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single())
SourceGeneration\GeneratorDriverTests_Attributes_FullyQualifiedName.cs (6)
326var input = ctx.ForAttributeWithMetadataName<LocalFunctionStatementSyntax>("System.CLSCompliantAttribute"); 335step => Assert.True(step.Outputs.Single().Value is LocalFunctionStatementSyntax { Identifier.ValueText: "LocalFunc" })); 362var input = ctx.ForAttributeWithMetadataName<LocalFunctionStatementSyntax>("System.CLSCompliantAttribute"); 371step => Assert.True(step.Outputs.Single().Value is LocalFunctionStatementSyntax { Identifier.ValueText: "LocalFunc" })); 401var input = ctx.ForAttributeWithMetadataName<LocalFunctionStatementSyntax>("System.CLSCompliantAttribute"); 410step => Assert.True(step.Outputs.Single().Value is LocalFunctionStatementSyntax { Identifier.ValueText: "LocalFunc" }));
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (23)
Symbols\LocalFunctionTests.cs (7)
35var localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 56var localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 77var localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 100var localsSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToArray();
Symbols\Source\NullablePublicAPITests.cs (16)
570return syntaxTree.GetRoot().DescendantNodes().OfType<CSharp.Syntax.LocalFunctionStatementSyntax>().Select(func => semanticModel.GetDeclaredSymbol(func)).Cast<IMethodSymbol>().ToArray(); 3664var localFunction = lambda.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 3697var localFunctionBody = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 3876var localFunction = lambda.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 4059var localFunction = root.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 4114var localFunction = lambda.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 4176var localFunction = lambda.DescendantNodes().OfType<LocalFunctionStatementSyntax>().First(); 4178var nestedLocalFunction = (IMethodSymbol)model.GetDeclaredSymbol(lambda.DescendantNodes().OfType<LocalFunctionStatementSyntax>().ElementAt(1)); 4930var localFunction = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (18)
Generated\Syntax.Test.xml.Generated.cs (5)
10690private static LocalFunctionStatementSyntax GenerateLocalFunctionStatement() 12393var node = GenerateLocalFunctionStatement(); 12405var newNode = node.WithAttributeLists(node.AttributeLists).WithModifiers(node.Modifiers).WithReturnType(node.ReturnType).WithIdentifier(node.Identifier).WithTypeParameterList(node.TypeParameterList).WithParameterList(node.ParameterList).WithConstraintClauses(node.ConstraintClauses).WithBody(node.Body).WithExpressionBody(node.ExpressionBody).WithSemicolonToken(node.SemicolonToken); 17123var oldNode = GenerateLocalFunctionStatement(); 17139var oldNode = GenerateLocalFunctionStatement();
IncrementalParsing\IncrementalParsingTests.cs (2)
564var localFunc1 = tree.GetRoot().DescendantNodesAndSelf().Single(n => n is LocalFunctionStatementSyntax); 581var localFunc2 = tree.GetRoot().DescendantNodesAndSelf().Single(n => n is LocalFunctionStatementSyntax);
Parsing\LocalFunctionParsingTests.cs (6)
1297var s1 = Assert.IsType<LocalFunctionStatementSyntax>(m.Body.Statements[0]); 1301s1 = Assert.IsType<LocalFunctionStatementSyntax>(m.Body.Statements[0]); 1349var s1 = Assert.IsType<LocalFunctionStatementSyntax>(m.Body.Statements[0]); 1359s1 = Assert.IsType<LocalFunctionStatementSyntax>(m2.Body.Statements[0]);
Parsing\ParserErrorMessageTests.cs (3)
3773var localFunctionStatement = (LocalFunctionStatementSyntax)tree.GetRoot().DescendantNodes().Single(node => node is LocalFunctionStatementSyntax);
Syntax\SyntaxNodeTests.cs (2)
3331var method = (LocalFunctionStatementSyntax)((GlobalStatementSyntax)root.Members[0]).Statement;
Microsoft.CodeAnalysis.CSharp.Workspaces (46)
Classification\ClassificationHelpers.cs (1)
226else if (token.Parent is LocalFunctionStatementSyntax localFunctionStatement && localFunctionStatement.Identifier == token)
CodeGeneration\CSharpSyntaxGenerator.cs (9)
1665LocalFunctionStatementSyntax localFunc => localFunc.WithModifiers(modifiers), 2391return ((LocalFunctionStatementSyntax)declaration).WithParameterList((ParameterListSyntax)list); 2455var local = (LocalFunctionStatementSyntax)declaration; 2511var local = (LocalFunctionStatementSyntax)declaration; 2633SyntaxKind.LocalFunctionStatement => ((LocalFunctionStatementSyntax)declaration).Body?.Statements, 2652LocalFunctionStatementSyntax localFunction => localFunction.Body, 2665LocalFunctionStatementSyntax localFunction => localFunction.WithBody(somebody).WithSemicolonToken(semicolon).WithExpressionBody(null),
FindSymbols\CSharpDeclaredSymbolInfoFactoryService.cs (2)
186if (node.AsNode() is LocalFunctionStatementSyntax localFunction) 500private static string GetMethodSuffix(LocalFunctionStatementSyntax method)
Recommendations\CSharpRecommendationServiceRunner.cs (1)
525LocalFunctionStatementSyntax localFunction => localFunction.Modifiers.Any(SyntaxKind.StaticKeyword),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ILocalSymbolExtensions.cs (3)
18var localFunctionStatement = destinationBlock.FirstAncestorOrSelf<LocalFunctionStatementSyntax>(); 38case LocalFunctionStatementSyntax localFunctionStatement:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
471public static IMethodSymbol GetRequiredDeclaredSymbol(this SemanticModel semanticModel, LocalFunctionStatementSyntax syntax, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (5)
153LocalFunctionStatementSyntax localFunction => localFunction.ParameterList, 282=> node is MethodDeclarationSyntax or AnonymousFunctionExpressionSyntax or LocalFunctionStatementSyntax; 345case LocalFunctionStatementSyntax localFunction when localFunction.Modifiers.Any(SyntaxKind.StaticKeyword): 745LocalFunctionStatementSyntax localFunction => localFunction.Modifiers, 757LocalFunctionStatementSyntax localFunction => localFunction.WithModifiers(modifiers),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (1)
470else if (currentToken.Parent is LocalFunctionStatementSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (1)
212if (node is AnonymousFunctionExpressionSyntax or LocalFunctionStatementSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (1)
155LocalFunctionStatementSyntax localFunc => localFunc.Modifiers,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (2)
70var node = TryGetAncestorForLocation<LocalFunctionStatementSyntax>(root, position, out localFunction);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (3)
492else if (destinationMember is LocalFunctionStatementSyntax localFunctionStatement) 613TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, LocalFunctionStatementSyntax localFunctionStatement) where TDeclarationNode : SyntaxNode 625var finalMember = localFunctionStatement
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (8)
92public static LocalFunctionStatementSyntax GenerateLocalFunctionDeclaration( 98var reusableSyntax = GetReuseableSyntaxNodeForSymbol<LocalFunctionStatementSyntax>(method, info); 104var declaration = GenerateLocalFunctionDeclarationWorker( 164private static LocalFunctionStatementSyntax GenerateLocalFunctionDeclarationWorker( 168var localFunctionDeclaration = LocalFunctionStatement( 201private static LocalFunctionStatementSyntax UseExpressionBodyIfDesired( 202CSharpCodeGenerationContextInfo info, LocalFunctionStatementSyntax localFunctionDeclaration, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (1)
506targetToken.GetAncestors<LocalFunctionStatementSyntax>().Any(f => f.GetModifiers().Any(SyntaxKind.UnsafeKeyword))) ||
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (1)
1131MethodDeclarationSyntax or LocalFunctionStatementSyntax or ConstructorDeclarationSyntax or DelegateDeclarationSyntax or TypeDeclarationSyntax => true,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ExpressionSyntaxExtensions.cs (1)
168if (name.IsFoundUnder<LocalFunctionStatementSyntax>(d => d.ReturnType) ||
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpMoveDeclarationNearReferenceService.cs (1)
35LocalFunctionStatementSyntax or
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSemanticFactsService.cs (1)
48if (container.Parent is LocalFunctionStatementSyntax or TypeDeclarationSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\InitializeParameter\InitializeParameterHelpers.cs (3)
134=> node is BaseMethodDeclarationSyntax or LocalFunctionStatementSyntax or AnonymousFunctionExpressionSyntax; 140LocalFunctionStatementSyntax localFunction => (SyntaxNode?)localFunction.Body ?? localFunction.ExpressionBody!, 149LocalFunctionStatementSyntax localFunction => localFunction.SemicolonToken,
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (2)
CodeGeneration\SyntaxGeneratorTests.cs (2)
3456var local = LocalFunctionStatement(PredefinedType(VoidKeyword), "p"); 3492var local = LocalFunctionStatement(PredefinedType(VoidKeyword), "p");
Microsoft.CodeAnalysis.Features.UnitTests (1)
FindUsages\DefinitionItemFactoryTests.cs (1)
1454var f = model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().Single(n => n is LocalFunctionStatementSyntax));
Microsoft.Interop.JavaScript.JSImportGenerator (3)
JSExportGenerator.cs (1)
427private static LocalFunctionStatementSyntax GenerateInnerLocalFunction(IncrementalStubGenerationContext context, string innerFunctionName, UnmanagedToManagedStubGenerator stubGenerator)
JSImportGenerator.cs (2)
286LocalFunctionStatementSyntax localFunction = GenerateInvokeFunction(LocalFunctionName, incrementalContext.SignatureContext, stubGenerator, hasReturn); 312private static LocalFunctionStatementSyntax GenerateInvokeFunction(string functionName, JSSignatureContext signatureContext, ManagedToNativeStubGenerator stubGenerator, bool hasReturn)
Microsoft.Interop.LibraryImportGenerator (3)
LibraryImportGenerator.cs (3)
376LocalFunctionStatementSyntax dllImport = CreateTargetDllImportAsLocalStatement( 444private static LocalFunctionStatementSyntax CreateTargetDllImportAsLocalStatement( 454LocalFunctionStatementSyntax localDllImport = LocalFunctionStatement(returnType, stubTargetName)
Microsoft.Interop.LibraryImportGenerator.Downlevel (3)
DownlevelLibraryImportGenerator.cs (3)
259LocalFunctionStatementSyntax dllImport = CreateTargetDllImportAsLocalStatement( 311private static LocalFunctionStatementSyntax CreateTargetDllImportAsLocalStatement( 318LocalFunctionStatementSyntax localDllImport = LocalFunctionStatement(returnType, stubTargetName)
Roslyn.Diagnostics.CSharp.Analyzers (33)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ILocalSymbolExtensions.cs (3)
18var localFunctionStatement = destinationBlock.FirstAncestorOrSelf<LocalFunctionStatementSyntax>(); 38case LocalFunctionStatementSyntax localFunctionStatement:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
471public static IMethodSymbol GetRequiredDeclaredSymbol(this SemanticModel semanticModel, LocalFunctionStatementSyntax syntax, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (5)
153LocalFunctionStatementSyntax localFunction => localFunction.ParameterList, 282=> node is MethodDeclarationSyntax or AnonymousFunctionExpressionSyntax or LocalFunctionStatementSyntax; 345case LocalFunctionStatementSyntax localFunction when localFunction.Modifiers.Any(SyntaxKind.StaticKeyword): 745LocalFunctionStatementSyntax localFunction => localFunction.Modifiers, 757LocalFunctionStatementSyntax localFunction => localFunction.WithModifiers(modifiers),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (1)
470else if (currentToken.Parent is LocalFunctionStatementSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (1)
212if (node is AnonymousFunctionExpressionSyntax or LocalFunctionStatementSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (1)
155LocalFunctionStatementSyntax localFunc => localFunc.Modifiers,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (2)
70var node = TryGetAncestorForLocation<LocalFunctionStatementSyntax>(root, position, out localFunction);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (3)
492else if (destinationMember is LocalFunctionStatementSyntax localFunctionStatement) 613TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, LocalFunctionStatementSyntax localFunctionStatement) where TDeclarationNode : SyntaxNode 625var finalMember = localFunctionStatement
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (8)
92public static LocalFunctionStatementSyntax GenerateLocalFunctionDeclaration( 98var reusableSyntax = GetReuseableSyntaxNodeForSymbol<LocalFunctionStatementSyntax>(method, info); 104var declaration = GenerateLocalFunctionDeclarationWorker( 164private static LocalFunctionStatementSyntax GenerateLocalFunctionDeclarationWorker( 168var localFunctionDeclaration = LocalFunctionStatement( 201private static LocalFunctionStatementSyntax UseExpressionBodyIfDesired( 202CSharpCodeGenerationContextInfo info, LocalFunctionStatementSyntax localFunctionDeclaration, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (1)
506targetToken.GetAncestors<LocalFunctionStatementSyntax>().Any(f => f.GetModifiers().Any(SyntaxKind.UnsafeKeyword))) ||
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (1)
1131MethodDeclarationSyntax or LocalFunctionStatementSyntax or ConstructorDeclarationSyntax or DelegateDeclarationSyntax or TypeDeclarationSyntax => true,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ExpressionSyntaxExtensions.cs (1)
168if (name.IsFoundUnder<LocalFunctionStatementSyntax>(d => d.ReturnType) ||
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpMoveDeclarationNearReferenceService.cs (1)
35LocalFunctionStatementSyntax or
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSemanticFactsService.cs (1)
48if (container.Parent is LocalFunctionStatementSyntax or TypeDeclarationSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\InitializeParameter\InitializeParameterHelpers.cs (3)
134=> node is BaseMethodDeclarationSyntax or LocalFunctionStatementSyntax or AnonymousFunctionExpressionSyntax; 140LocalFunctionStatementSyntax localFunction => (SyntaxNode?)localFunction.Body ?? localFunction.ExpressionBody!, 149LocalFunctionStatementSyntax localFunction => localFunction.SemicolonToken,
System.Private.CoreLib.Generators (1)
IntrinsicsInSystemPrivateCoreLibAnalyzer.cs (1)
574if (ancestorNode is LocalFunctionStatementSyntax)