411 references to LocalFunctionStatementSyntax
Microsoft.CodeAnalysis.CSharp (44)
Binder\Binder_Statements.cs (3)
69result = BindLocalFunctionStatement((LocalFunctionStatementSyntax)node, diagnostics); 551private BoundStatement BindLocalFunctionStatement(LocalFunctionStatementSyntax node, BindingDiagnosticBag diagnostics) 3456LocalFunctionStatementSyntax => (MessageID?)null,
Binder\LocalBinderFactory.cs (2)
364public override void VisitLocalFunctionStatement(LocalFunctionStatementSyntax node) 397private static LocalFunctionSymbol FindLocalFunction(LocalFunctionStatementSyntax node, Binder enclosing)
Binder\LocalScopeBinder.cs (3)
274var decl = (LocalFunctionStatementSyntax)innerStatement; 299protected LocalFunctionSymbol MakeLocalFunction(LocalFunctionStatementSyntax declaration)
Compilation\CSharpSemanticModel.cs (2)
2935public abstract ISymbol GetDeclaredSymbol(LocalFunctionStatementSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken)); 5070return this.GetDeclaredSymbol((LocalFunctionStatementSyntax)node, cancellationToken);
Compilation\MemberSemanticModel.cs (6)
220LocalFunctionStatementSyntax ownerOfTypeParametersInScope = null; 244var localFunction = (LocalFunctionStatementSyntax)stmt; 611public override ISymbol GetDeclaredSymbol(LocalFunctionStatementSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken)) 704internal LocalFunctionSymbol GetDeclaredLocalFunction(LocalFunctionStatementSyntax declarationSyntax) 842var localFunction = GetDeclaredSymbol((LocalFunctionStatementSyntax)paramList.Parent, cancellationToken).GetSymbol<MethodSymbol>();
Compilation\PublicSemanticModel.cs (1)
39LocalFunctionStatementSyntax or
Compilation\SpeculativeSemanticModelWithMemberModel.cs (1)
276public override ISymbol GetDeclaredSymbol(LocalFunctionStatementSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
Compilation\SyntaxTreeSemanticModel.cs (2)
1485public override ISymbol GetDeclaredSymbol(LocalFunctionStatementSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken)) 2146case LocalFunctionStatementSyntax localDecl:
Lowering\ClosureConversion\ClosureConversion.cs (1)
1435else if (syntax is LocalFunctionStatementSyntax localFunction)
Symbols\MethodSymbolExtensions.cs (1)
207else if (node is LocalFunctionStatementSyntax statement)
Symbols\Source\LocalFunctionSymbol.cs (5)
38LocalFunctionStatementSyntax syntax) 91internal LocalFunctionStatementSyntax Syntax => (LocalFunctionStatementSyntax)syntaxReferenceOpt.GetSyntax(); 439var syntax = Syntax; 465var syntax = Syntax;
Symbols\Source\SourceMethodSymbolWithAttributes.cs (2)
53case LocalFunctionStatementSyntax localFunction: 1090LocalFunctionStatementSyntax { ReturnType: var localReturnType } => localReturnType,
Syntax\LambdaUtilities.cs (7)
116return GetLocalFunctionBody((LocalFunctionStatementSyntax)newLambda); 127LocalFunctionStatementSyntax localFunctionStatementSyntax => (CSharpSyntaxNode?)localFunctionStatementSyntax.Body ?? localFunctionStatementSyntax.ExpressionBody!.Expression, 156var localFunction = (LocalFunctionStatementSyntax)parent; 161return arrowExpressionClause.Expression == node && arrowExpressionClause.Parent is LocalFunctionStatementSyntax; 350lambdaBody1 = GetLocalFunctionBody((LocalFunctionStatementSyntax)node); 481private 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) 444LocalFunctionStatementSyntax 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 (31)
CSharpAccessibilityFacts.cs (1)
314LocalFunctionStatementSyntax localFunc => localFunc.Modifiers,
CSharpHeaderFacts.cs (2)
79var node = TryGetAncestorForLocation<LocalFunctionStatementSyntax>(root, position);
CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (1)
90LocalFunctionStatementSyntax localFunction => localFunction.ReturnType,
ElasticTriviaFormattingRule.cs (1)
462else if (currentToken.Parent is LocalFunctionStatementSyntax)
ILocalSymbolExtensions.cs (3)
18var localFunctionStatement = destinationBlock.FirstAncestorOrSelf<LocalFunctionStatementSyntax>(); 38case LocalFunctionStatementSyntax localFunctionStatement:
MakeLocalFunctionStaticDiagnosticAnalyzer.cs (2)
38var localFunction = (LocalFunctionStatementSyntax)context.Node;
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)
SuppressFormattingRule.cs (1)
212LocalFunctionStatementSyntax)
SyntaxNodeExtensions.cs (3)
169SyntaxKind.LocalFunctionStatement => ((LocalFunctionStatementSyntax)declaration).ParameterList, 870LocalFunctionStatementSyntax localFunction => localFunction.Modifiers, 883case LocalFunctionStatementSyntax localFunction: return localFunction.WithModifiers(modifiers);
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)
UseSimpleUsingStatementDiagnosticAnalyzer.cs (1)
219while (index + 1 < statements.Count && statements[index + 1] is LocalFunctionStatementSyntax)
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (37)
AssignOutParametersAboveReturnCodeFixProvider.cs (1)
52if (exprOrStatement is LocalFunctionStatementSyntax { ExpressionBody: { } localFunctionExpressionBody })
AssignOutParametersAtStartCodeFixProvider.cs (1)
37if (location is LocalFunctionStatementSyntax { ExpressionBody: { } })
CSharpCodeGenerationService.cs (3)
492else if (destinationMember is LocalFunctionStatementSyntax localFunctionStatement) 591TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, LocalFunctionStatementSyntax localFunctionStatement) where TDeclarationNode : SyntaxNode 603var finalMember = localFunctionStatement
CSharpDeclareAsNullableCodeFixProvider.cs (1)
167LocalFunctionStatementSyntax localFunction =>
CSharpFixReturnTypeCodeFixProvider.cs (1)
153LocalFunctionStatementSyntax localFunction => (localFunction.ReturnType, localFunction.Modifiers.Any(SyntaxKind.AsyncKeyword)),
CSharpMakeMethodAsynchronousCodeFixProvider.cs (3)
81LocalFunctionStatementSyntax localFunction => FixLocalFunction(keepVoid, methodSymbol, localFunction, knownTypes, cancellationToken), 99private static LocalFunctionStatementSyntax FixLocalFunction( 102LocalFunctionStatementSyntax localFunction,
CSharpMakeMethodSynchronousCodeFixProvider.cs (2)
39case LocalFunctionStatementSyntax localFunction: return FixLocalFunction(methodSymbol, localFunction, knownTypes); 52private static SyntaxNode FixLocalFunction(IMethodSymbol methodSymbol, LocalFunctionStatementSyntax localFunction, KnownTypes knownTypes)
CSharpMoveDeclarationNearReferenceService.cs (1)
35LocalFunctionStatementSyntax or
CSharpRemoveAsyncModifierCodeFixProvider.cs (2)
44LocalFunctionStatementSyntax localFunction => localFunction.WithBody(block).WithExpressionBody(null).WithSemicolonToken(default), 57LocalFunctionStatementSyntax localFunction => RemoveAsyncModifierHelpers.WithoutAsyncModifier(localFunction, localFunction.ReturnType),
CSharpRemoveUnusedLocalFunctionCodeFixProvider.cs (2)
56.Select(t => t.GetAncestor<LocalFunctionStatementSyntax>()); 58foreach (var localFunction in localFunctions)
CSharpUseLocalFunctionCodeFixProvider.cs (2)
165var newLocalFunctionStatement = CreateLocalFunctionStatement(localDeclaration, anonymousFunction, delegateMethod, parameterList, makeStatic) 205private static LocalFunctionStatementSyntax CreateLocalFunctionStatement(
ExpressionSyntaxExtensions.cs (1)
170if (name.IsFoundUnder<LocalFunctionStatementSyntax>(d => d.ReturnType) ||
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs\SyntaxTokenExtensions.cs (1)
504targetToken.GetAncestors<LocalFunctionStatementSyntax>().Any(f => f.GetModifiers().Any(SyntaxKind.UnsafeKeyword)));
MakeLocalFunctionStaticCodeFixHelper.cs (4)
30LocalFunctionStatementSyntax localFunction, 43LocalFunctionStatementSyntax localFunction, 182var localFunctionWithNewParameters = (LocalFunctionStatementSyntax)info.Service.AddParameters(
MethodGenerator.cs (8)
89public static LocalFunctionStatementSyntax GenerateLocalFunctionDeclaration( 95var reusableSyntax = GetReuseableSyntaxNodeForSymbol<LocalFunctionStatementSyntax>(method, info); 101var declaration = GenerateLocalFunctionDeclarationWorker( 137private static LocalFunctionStatementSyntax GenerateLocalFunctionDeclarationWorker( 141var localFunctionDeclaration = SyntaxFactory.LocalFunctionStatement( 174private static LocalFunctionStatementSyntax UseExpressionBodyIfDesired( 175CSharpCodeGenerationContextInfo info, LocalFunctionStatementSyntax localFunctionDeclaration)
PassInCapturedVariablesAsArgumentsCodeFixProvider.cs (3)
69Func<Document, LocalFunctionStatementSyntax, ImmutableArray<ISymbol>, Task> fixer, 81.Select(d => root.FindNode(d.Location.SourceSpan).AncestorsAndSelf().OfType<LocalFunctionStatementSyntax>().FirstOrDefault()) 91foreach (var localFunction in localFunctions)
RemoveAsyncModifierHelpers.cs (1)
18internal static SyntaxNode WithoutAsyncModifier(LocalFunctionStatementSyntax localFunction, TypeSyntax returnType)
Microsoft.CodeAnalysis.CSharp.EditorFeatures (8)
AutomaticCompletion\AutomaticLineEnderCommandHandler.cs (2)
333or LocalFunctionStatementSyntax 409or LocalFunctionStatementSyntax
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (6)
465LocalFunctionStatementSyntax localFunctionStatementNode => ShouldAddBraceForLocalFunctionStatement(localFunctionStatementNode, caretPosition), 520private static bool ShouldAddBraceForLocalFunctionStatement(LocalFunctionStatementSyntax localFunctionStatementNode, int caretPosition) 750if (node is LocalFunctionStatementSyntax { Body: { } localFunctionBody }) 875LocalFunctionStatementSyntax localFunctionStatementNode => AddBlockToLocalFunctionDeclaration(localFunctionStatementNode, formattingOptions), 911private static LocalFunctionStatementSyntax AddBlockToLocalFunctionDeclaration( 912LocalFunctionStatementSyntax localFunctionStatementNode,
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (37)
EditAndContinue\SyntaxUtilitiesTests.cs (6)
188var f1 = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(m => m.Identifier.ValueText == "f1"); 189var f2 = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(m => m.Identifier.ValueText == "f2"); 254var f = m2.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(m => m.Identifier.ValueText == "f");
RefactoringHelpers\RefactoringHelpersTests.cs (31)
31await TestAsync<LocalFunctionStatementSyntax>(testText); 48await TestAsync<LocalFunctionStatementSyntax>(testText); 65await TestAsync<LocalFunctionStatementSyntax>(testText); 83await TestMissingAsync<LocalFunctionStatementSyntax>(testText); 100await TestAsync<LocalFunctionStatementSyntax>(testText); 117await TestAsync<LocalFunctionStatementSyntax>(testText); 137await TestAsync<LocalFunctionStatementSyntax>(testText); 154await TestMissingAsync<LocalFunctionStatementSyntax>(testText); 174await TestMissingAsync<LocalFunctionStatementSyntax>(testText); 194await TestMissingAsync<LocalFunctionStatementSyntax>(testText); 212await TestMissingAsync<LocalFunctionStatementSyntax>(testText); 229await TestAsync<LocalFunctionStatementSyntax>(testText); 247await TestAsync<LocalFunctionStatementSyntax>(testText); 266await TestMissingAsync<LocalFunctionStatementSyntax>(testText); 284await TestAsync<LocalFunctionStatementSyntax>(testText); 303await TestMissingAsync<LocalFunctionStatementSyntax>(testText); 395await TestAsync<LocalFunctionStatementSyntax>(testText); 412await TestAsync<LocalFunctionStatementSyntax>(testText); 429await TestAsync<LocalFunctionStatementSyntax>(testText); 446await TestMissingAsync<LocalFunctionStatementSyntax>(testText); 463await TestMissingAsync<LocalFunctionStatementSyntax>(testText); 480await TestMissingAsync<LocalFunctionStatementSyntax>(testText); 497await TestMissingAsync<LocalFunctionStatementSyntax>(testText); 514await TestAsync<LocalFunctionStatementSyntax>(testText); 535await TestAsync<LocalFunctionStatementSyntax>(testText); 554await TestAsync<LocalFunctionStatementSyntax>(testText); 573await TestMissingAsync<LocalFunctionStatementSyntax>(testText); 592await TestMissingAsync<LocalFunctionStatementSyntax>(testText); 1166await TestAsync<LocalFunctionStatementSyntax>(testText); 1190await TestAsync<LocalFunctionStatementSyntax>(testText); 1210await TestMissingAsync<LocalFunctionStatementSyntax>(testText);
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (8)
CodeGen\CodeGenLocalFunctionTests.cs (8)
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) 6162var localFunctionSyntax = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (2)
Attributes\AttributeTests_WellKnownAttributes.cs (2)
5679var localFunctionSyntax = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Features (94)
AssignOutParametersAboveReturnCodeFixProvider.cs (1)
52if (exprOrStatement is LocalFunctionStatementSyntax { ExpressionBody: { } localFunctionExpressionBody })
AssignOutParametersAtStartCodeFixProvider.cs (1)
37if (location is LocalFunctionStatementSyntax { ExpressionBody: { } })
ChangeSignature\CSharpChangeSignatureService.cs (1)
320if (updatedNode is LocalFunctionStatementSyntax localFunction)
CodeRefactorings\ConvertLocalFunctionToMethod\CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs (4)
47var localFunction = await context.TryGetRelevantNodeAsync<LocalFunctionStatementSyntax>().ConfigureAwait(false); 80LocalFunctionStatementSyntax localFunction, 283MethodDeclarationSyntax method, LocalFunctionStatementSyntax localFunction)
Completion\CompletionProviders\AwaitCompletionProvider.cs (2)
48LocalFunctionStatementSyntax local => local.ReturnType.SpanStart, 70if (parent is QualifiedNameSyntax { Parent: LocalFunctionStatementSyntax localFunction } qualifiedName &&
Completion\CompletionProviders\DeclarationName\DeclarationNameInfo.cs (1)
346result = IsLastTokenOfType<LocalFunctionStatementSyntax>(token, semanticModel,
ConvertLinq\CSharpConvertLinqQueryToForEachProvider.cs (1)
589var localFunctionDeclaration = SyntaxFactory.LocalFunctionStatement(
CSharpDeclareAsNullableCodeFixProvider.cs (1)
167LocalFunctionStatementSyntax localFunction =>
CSharpFixReturnTypeCodeFixProvider.cs (1)
153LocalFunctionStatementSyntax localFunction => (localFunction.ReturnType, localFunction.Modifiers.Any(SyntaxKind.AsyncKeyword)),
CSharpMakeMethodAsynchronousCodeFixProvider.cs (3)
81LocalFunctionStatementSyntax localFunction => FixLocalFunction(keepVoid, methodSymbol, localFunction, knownTypes, cancellationToken), 99private static LocalFunctionStatementSyntax FixLocalFunction( 102LocalFunctionStatementSyntax localFunction,
CSharpMakeMethodSynchronousCodeFixProvider.cs (2)
39case LocalFunctionStatementSyntax localFunction: return FixLocalFunction(methodSymbol, localFunction, knownTypes); 52private static SyntaxNode FixLocalFunction(IMethodSymbol methodSymbol, LocalFunctionStatementSyntax localFunction, KnownTypes knownTypes)
CSharpRemoveAsyncModifierCodeFixProvider.cs (2)
44LocalFunctionStatementSyntax localFunction => localFunction.WithBody(block).WithExpressionBody(null).WithSemicolonToken(default), 57LocalFunctionStatementSyntax localFunction => RemoveAsyncModifierHelpers.WithoutAsyncModifier(localFunction, localFunction.ReturnType),
CSharpRemoveUnusedLocalFunctionCodeFixProvider.cs (2)
56.Select(t => t.GetAncestor<LocalFunctionStatementSyntax>()); 58foreach (var localFunction in localFunctions)
CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (1)
90LocalFunctionStatementSyntax localFunction => localFunction.ReturnType,
CSharpUseLocalFunctionCodeFixProvider.cs (2)
165var newLocalFunctionStatement = CreateLocalFunctionStatement(localDeclaration, anonymousFunction, delegateMethod, parameterList, makeStatic) 205private static LocalFunctionStatementSyntax CreateLocalFunctionStatement(
EditAndContinue\BreakpointSpans.cs (2)
313var localFunction = (LocalFunctionStatementSyntax)node;
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (4)
629if (root is LocalFunctionStatementSyntax localFunc) 1480=> node is AnonymousFunctionExpressionSyntax or LocalFunctionStatementSyntax; 1807var lfd = (LocalFunctionStatementSyntax)node;
EditAndContinue\SyntaxComparer.cs (2)
1009var localFunction = (LocalFunctionStatementSyntax)nestedFunction;
EditAndContinue\SyntaxUtilities.cs (1)
279LocalFunctionStatementSyntax localFunction => localFunction.Modifiers.Any(SyntaxKind.AsyncKeyword),
ExtractMethod\CSharpMethodExtractor.cs (1)
72if (currentNode is LocalFunctionStatementSyntax localFunction)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (6)
695LocalFunctionStatementSyntax localFunction => TweakNewLinesInMethod(localFunction), 709private static LocalFunctionStatementSyntax TweakNewLinesInMethod(LocalFunctionStatementSyntax method) 759var nodeIsMethodOrLocalFunction = syntaxNode is MethodDeclarationSyntax or LocalFunctionStatementSyntax; 771var returnType = syntaxNode is MethodDeclarationSyntax method ? method.ReturnType : ((LocalFunctionStatementSyntax)syntaxNode).ReturnType; 782LocalFunctionStatementSyntax _ => true,
ExtractMethod\CSharpMethodExtractor.TriviaResult.cs (3)
39var isMethodOrLocalFunction = method is MethodDeclarationSyntax or LocalFunctionStatementSyntax; 50var isMethodOrLocalFunction = method is MethodDeclarationSyntax or LocalFunctionStatementSyntax; 144LocalFunctionStatementSyntax localFunctionDeclaration => (localFunctionDeclaration.Body, localFunctionDeclaration.ExpressionBody, localFunctionDeclaration.SemicolonToken),
ExtractMethod\CSharpSelectionResult.cs (1)
86LocalFunctionStatementSyntax)
ExtractMethod\CSharpSelectionResult.StatementResult.cs (1)
59LocalFunctionStatementSyntax or
Highlighting\KeywordHighlighters\AsyncAwaitHighlighter.cs (1)
80LocalFunctionStatementSyntax localFunction => TryAddAsyncModifier(localFunction.Modifiers, spans),
InitializeParameter\InitializeParameterHelpers.cs (3)
23or LocalFunctionStatementSyntax 30LocalFunctionStatementSyntax localFunction => (SyntaxNode?)localFunction.Body ?? localFunction.ExpressionBody!, 39LocalFunctionStatementSyntax localFunction => localFunction.SemicolonToken,
IntroduceVariable\CSharpIntroduceVariableService.cs (2)
145var localFunction = expression.GetAncestor<LocalFunctionStatementSyntax>();
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (4)
272case LocalFunctionStatementSyntax localFunction: 297var localFunction = block.GetAncestor<LocalFunctionStatementSyntax>(); 390var localFunctionIdentifiers = localFunctions.Select(node => ((LocalFunctionStatementSyntax)node).Identifier.ValueText);
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (2)
72case LocalFunctionStatementSyntax: 99LocalFunctionStatementSyntax or AccessorDeclarationSyntax or MemberDeclarationSyntax
LambdaUtilities.cs (7)
116return GetLocalFunctionBody((LocalFunctionStatementSyntax)newLambda); 127LocalFunctionStatementSyntax localFunctionStatementSyntax => (CSharpSyntaxNode?)localFunctionStatementSyntax.Body ?? localFunctionStatementSyntax.ExpressionBody!.Expression, 156var localFunction = (LocalFunctionStatementSyntax)parent; 161return arrowExpressionClause.Expression == node && arrowExpressionClause.Parent is LocalFunctionStatementSyntax; 350lambdaBody1 = GetLocalFunctionBody((LocalFunctionStatementSyntax)node); 481private static SyntaxNode GetLocalFunctionBody(LocalFunctionStatementSyntax localFunctionStatementSyntax)
MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeRefactoringProvider.cs (2)
33var localFunction = await context.TryGetRelevantNodeAsync<LocalFunctionStatementSyntax>().ConfigureAwait(false);
MakeLocalFunctionStaticCodeFixHelper.cs (4)
30LocalFunctionStatementSyntax localFunction, 43LocalFunctionStatementSyntax localFunction, 182var localFunctionWithNewParameters = (LocalFunctionStatementSyntax)info.Service.AddParameters(
MakeLocalFunctionStaticDiagnosticAnalyzer.cs (2)
38var localFunction = (LocalFunctionStatementSyntax)context.Node;
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)
PassInCapturedVariablesAsArgumentsCodeFixProvider.cs (3)
69Func<Document, LocalFunctionStatementSyntax, ImmutableArray<ISymbol>, Task> fixer, 81.Select(d => root.FindNode(d.Location.SourceSpan).AncestorsAndSelf().OfType<LocalFunctionStatementSyntax>().FirstOrDefault()) 91foreach (var localFunction in localFunctions)
RemoveAsyncModifierHelpers.cs (1)
18internal static SyntaxNode WithoutAsyncModifier(LocalFunctionStatementSyntax localFunction, TypeSyntax returnType)
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)
UseSimpleUsingStatementDiagnosticAnalyzer.cs (1)
219while (index + 1 < statements.Count && statements[index + 1] is LocalFunctionStatementSyntax)
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 (55)
Semantics\InitOnlyMemberTests.cs (2)
4132var localFunctionSyntax = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single();
Semantics\LocalFunctionTests.cs (15)
493var localFunction = tree.GetRoot().DescendantNodes() 494.OfType<LocalFunctionStatementSyntax>() 541var localFunction = tree.GetRoot().DescendantNodes() 542.OfType<LocalFunctionStatementSyntax>() 805var localFunction = tree.GetRoot().DescendantNodes() 806.OfType<LocalFunctionStatementSyntax>() 852var localFunction = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 968var localFunction = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 2373LocalFunctionStatementSyntax declaration = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().First(); 2570var exprs = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToImmutableArray(); 5023var localDecl = (LocalFunctionStatementSyntax)tree.FindNodeOrTokenByKind(SyntaxKind.LocalFunctionStatement).AsNode();
Semantics\NullableReferenceTypesTests.cs (10)
63425var function1 = tree1.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Last(); 63429var function2 = tree2.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 94029var localSyntaxes = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToArray(); 95358var localSyntaxes = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToArray(); 108042var localSyntaxes = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>(); 108047void verifyLocalFunction(LocalFunctionStatementSyntax localSyntax, string expectedName, string[] expectedConstraintTypes) 108096var localSyntaxes = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>(); 108100void verifyLocalFunction(LocalFunctionStatementSyntax localSyntax, string expectedName, string[] expectedConstraintTypes)
Semantics\OutVarTests.cs (3)
36358Assert.Same(symbolInfo.Symbol, speculativeModel.GetDeclaredSymbol(tree2.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Where(l => l.Identifier.ValueText == "M2").Single())); 36440Assert.Same(symbolInfo.Symbol, speculativeModel.GetDeclaredSymbol(tree2.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Where(l => l.Identifier.ValueText == "M2").Single())); 36513Assert.Same(symbolInfo.Symbol, speculativeModel.GetDeclaredSymbol(tree2.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Where(l => l.Identifier.ValueText == "M2").Single()));
Semantics\RefFieldTests.cs (1)
10575var decls = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToArray();
Semantics\TopLevelStatementsTests.cs (18)
235var localDecl = unit1.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 358var localDecl = unit2.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 2072var localDecl = tree1.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 2236var localDecl = tree1.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 4203var declarator = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 4498var symbol1 = model1.GetDeclaredSymbol(tree1.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single()); 4504var symbol2 = model2.GetDeclaredSymbol(tree2.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().First()); 4562var symbol1 = model1.GetDeclaredSymbol(tree1.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().First()); 4566var symbol2 = model1.GetDeclaredSymbol(tree1.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Skip(1).First()); 4611var symbol1 = model1.GetDeclaredSymbol(tree1.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().First()); 6074var localFunctions = syntaxTree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToList(); 6082void checkImplAttributes(LocalFunctionStatementSyntax localFunctionStatement, MethodImplAttributes expectedFlags) 6148.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)
34var localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 55var localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 76var localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 99var localsSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().ToArray();
Symbols\Source\NullablePublicAPITests.cs (16)
568return syntaxTree.GetRoot().DescendantNodes().OfType<CSharp.Syntax.LocalFunctionStatementSyntax>().Select(func => semanticModel.GetDeclaredSymbol(func)).Cast<IMethodSymbol>().ToArray(); 3665var localFunction = lambda.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 3698var localFunctionBody = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 3877var localFunction = lambda.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 4063var localFunction = root.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 4118var localFunction = lambda.DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single(); 4180var localFunction = lambda.DescendantNodes().OfType<LocalFunctionStatementSyntax>().First(); 4182var nestedLocalFunction = (IMethodSymbol)model.GetDeclaredSymbol(lambda.DescendantNodes().OfType<LocalFunctionStatementSyntax>().ElementAt(1)); 4934var localFunction = tree.GetRoot().DescendantNodes().OfType<LocalFunctionStatementSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (16)
Generated\Syntax.Test.xml.Generated.cs (5)
10304private static LocalFunctionStatementSyntax GenerateLocalFunctionStatement() 11949var node = GenerateLocalFunctionStatement(); 11961var 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); 16505var oldNode = GenerateLocalFunctionStatement(); 16521var oldNode = GenerateLocalFunctionStatement();
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)
3852var localFunctionStatement = (LocalFunctionStatementSyntax)tree.GetRoot().DescendantNodes().Single(node => node is LocalFunctionStatementSyntax);
Syntax\SyntaxNodeTests.cs (2)
3259var method = (LocalFunctionStatementSyntax)((GlobalStatementSyntax)root.Members[0]).Statement;
Microsoft.CodeAnalysis.CSharp.Workspaces (36)
Classification\ClassificationHelpers.cs (1)
220else if (token.Parent is LocalFunctionStatementSyntax localFunctionStatement && localFunctionStatement.Identifier == token)
CodeGeneration\CSharpSyntaxGenerator.cs (8)
1651LocalFunctionStatementSyntax localFunc => localFunc.WithModifiers(modifiers), 2230return ((LocalFunctionStatementSyntax)declaration).WithParameterList((ParameterListSyntax)list); 2294var local = (LocalFunctionStatementSyntax)declaration; 2350var local = (LocalFunctionStatementSyntax)declaration; 2480return ((LocalFunctionStatementSyntax)declaration).Body?.Statements ?? s_EmptyList; 2516return ((LocalFunctionStatementSyntax)declaration).WithBody(somebody).WithSemicolonToken(semicolon).WithExpressionBody(null);
CSharpAccessibilityFacts.cs (1)
314LocalFunctionStatementSyntax localFunc => localFunc.Modifiers,
CSharpCodeGenerationService.cs (3)
492else if (destinationMember is LocalFunctionStatementSyntax localFunctionStatement) 591TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, LocalFunctionStatementSyntax localFunctionStatement) where TDeclarationNode : SyntaxNode 603var finalMember = localFunctionStatement
CSharpHeaderFacts.cs (2)
79var node = TryGetAncestorForLocation<LocalFunctionStatementSyntax>(root, position);
CSharpMoveDeclarationNearReferenceService.cs (1)
35LocalFunctionStatementSyntax or
ElasticTriviaFormattingRule.cs (1)
462else if (currentToken.Parent is LocalFunctionStatementSyntax)
FindSymbols\CSharpDeclaredSymbolInfoFactoryService.cs (2)
185if (node.AsNode() is LocalFunctionStatementSyntax localFunction) 501private static string GetMethodSuffix(LocalFunctionStatementSyntax method)
ILocalSymbolExtensions.cs (3)
18var localFunctionStatement = destinationBlock.FirstAncestorOrSelf<LocalFunctionStatementSyntax>(); 38case LocalFunctionStatementSyntax localFunctionStatement:
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs\SyntaxNodeExtensions.cs (3)
169SyntaxKind.LocalFunctionStatement => ((LocalFunctionStatementSyntax)declaration).ParameterList, 870LocalFunctionStatementSyntax localFunction => localFunction.Modifiers, 883case LocalFunctionStatementSyntax localFunction: return localFunction.WithModifiers(modifiers);
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs\SyntaxTokenExtensions.cs (1)
504targetToken.GetAncestors<LocalFunctionStatementSyntax>().Any(f => f.GetModifiers().Any(SyntaxKind.UnsafeKeyword)));
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ExpressionSyntaxExtensions.cs\ExpressionSyntaxExtensions.cs (1)
170if (name.IsFoundUnder<LocalFunctionStatementSyntax>(d => d.ReturnType) ||
MethodGenerator.cs (8)
89public static LocalFunctionStatementSyntax GenerateLocalFunctionDeclaration( 95var reusableSyntax = GetReuseableSyntaxNodeForSymbol<LocalFunctionStatementSyntax>(method, info); 101var declaration = GenerateLocalFunctionDeclarationWorker( 137private static LocalFunctionStatementSyntax GenerateLocalFunctionDeclarationWorker( 141var localFunctionDeclaration = SyntaxFactory.LocalFunctionStatement( 174private static LocalFunctionStatementSyntax UseExpressionBodyIfDesired( 175CSharpCodeGenerationContextInfo info, LocalFunctionStatementSyntax localFunctionDeclaration)
SuppressFormattingRule.cs (1)
212LocalFunctionStatementSyntax)
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (2)
CodeGeneration\SyntaxGeneratorTests.cs (2)
3201var local = SyntaxFactory.LocalFunctionStatement(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.VoidKeyword)), "p"); 3237var local = SyntaxFactory.LocalFunctionStatement(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.VoidKeyword)), "p");