447 references to LocalFunctionStatementSyntax
ILLink.CodeFixProvider (1)
BaseAttributeCodeFixProvider.cs (1)
114
case
LocalFunctionStatementSyntax
or BaseMethodDeclarationSyntax or AccessorDeclarationSyntax when targets.HasFlag (AttributeableParentTargets.MethodOrConstructor):
Microsoft.CodeAnalysis.CSharp (57)
Binder\Binder_Statements.cs (3)
70
result = BindLocalFunctionStatement((
LocalFunctionStatementSyntax
)node, diagnostics);
554
private BoundStatement BindLocalFunctionStatement(
LocalFunctionStatementSyntax
node, BindingDiagnosticBag diagnostics)
3557
LocalFunctionStatementSyntax
=> (MessageID?)null,
Binder\LocalBinderFactory.cs (2)
405
public override void VisitLocalFunctionStatement(
LocalFunctionStatementSyntax
node)
440
private static LocalFunctionSymbol FindLocalFunction(
LocalFunctionStatementSyntax
node, Binder enclosing)
Binder\LocalScopeBinder.cs (5)
228
var
decl = (
LocalFunctionStatementSyntax
)innerStatement;
320
var
decl = (
LocalFunctionStatementSyntax
)innerStatement;
345
protected LocalFunctionSymbol MakeLocalFunction(
LocalFunctionStatementSyntax
declaration)
Compilation\CSharpSemanticModel.cs (2)
2942
public abstract IMethodSymbol GetDeclaredSymbol(
LocalFunctionStatementSyntax
declarationSyntax, CancellationToken cancellationToken = default(CancellationToken));
5095
return this.GetDeclaredSymbol((
LocalFunctionStatementSyntax
)node, cancellationToken);
Compilation\MemberSemanticModel.cs (6)
230
LocalFunctionStatementSyntax
ownerOfTypeParametersInScope = null;
254
var
localFunction = (
LocalFunctionStatementSyntax
)stmt;
621
public override IMethodSymbol GetDeclaredSymbol(
LocalFunctionStatementSyntax
declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
714
internal LocalFunctionSymbol GetDeclaredLocalFunction(
LocalFunctionStatementSyntax
declarationSyntax)
852
var localFunction = GetDeclaredSymbol((
LocalFunctionStatementSyntax
)paramList.Parent, cancellationToken).GetSymbol<MethodSymbol>();
Compilation\PublicSemanticModel.cs (1)
39
LocalFunctionStatementSyntax
or
Compilation\SpeculativeSemanticModelWithMemberModel.cs (1)
280
public override IMethodSymbol GetDeclaredSymbol(
LocalFunctionStatementSyntax
declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
Compilation\SyntaxTreeSemanticModel.cs (2)
1479
public override IMethodSymbol GetDeclaredSymbol(
LocalFunctionStatementSyntax
declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
2154
case
LocalFunctionStatementSyntax
localDecl:
CSharpExtensions.cs (1)
1627
public static IMethodSymbol? GetDeclaredSymbol(this SemanticModel? semanticModel,
LocalFunctionStatementSyntax
node, CancellationToken cancellationToken = default(CancellationToken))
FlowAnalysis\NullableWalker.cs (1)
1050
LocalFunctionStatementSyntax
localFunctionSyntax => localFunctionSyntax.GetLastToken(),
Lowering\ClosureConversion\ClosureConversion.cs (1)
1453
else if (syntax is
LocalFunctionStatementSyntax
localFunction)
Parser\LanguageParser.cs (9)
2584
if (tryParseLocalDeclarationStatementFromStartPoint<
LocalFunctionStatementSyntax
>(attributes, ref afterAttributesPoint, out result))
2781
tryParseLocalDeclarationStatementFromStartPoint<
LocalFunctionStatementSyntax
>(attributes, ref afterAttributesPoint, out result))
5004
out
var
localFunction);
5020
out
LocalFunctionStatementSyntax
localFunction)
5207
out
LocalFunctionStatementSyntax
localFunction,
10080
out
var
localFunction);
10261
out
var
localFunction);
10277
out
LocalFunctionStatementSyntax
localFunction)
10446
private
LocalFunctionStatementSyntax
TryParseLocalFunctionStatementBody(
Symbols\MethodSymbolExtensions.cs (1)
207
else if (node is
LocalFunctionStatementSyntax
statement)
Symbols\Source\LocalFunctionSymbol.cs (5)
41
LocalFunctionStatementSyntax
syntax)
103
internal
LocalFunctionStatementSyntax
Syntax => (
LocalFunctionStatementSyntax
)syntaxReferenceOpt.GetSyntax();
474
var
syntax = Syntax;
504
var
syntax = Syntax;
Symbols\Source\SourceMethodSymbolWithAttributes.cs (2)
57
case
LocalFunctionStatementSyntax
localFunction:
1535
LocalFunctionStatementSyntax
{ ReturnType: var localReturnType } => localReturnType,
Syntax\LambdaUtilities.cs (7)
116
return GetLocalFunctionBody((
LocalFunctionStatementSyntax
)newLambda);
127
LocalFunctionStatementSyntax
localFunctionStatementSyntax => (CSharpSyntaxNode?)localFunctionStatementSyntax.Body ?? localFunctionStatementSyntax.ExpressionBody!.Expression,
156
var
localFunction = (
LocalFunctionStatementSyntax
)parent;
161
return arrowExpressionClause.Expression == node && arrowExpressionClause.Parent is
LocalFunctionStatementSyntax
;
350
lambdaBody1 = GetLocalFunctionBody((
LocalFunctionStatementSyntax
)node);
484
private static SyntaxNode? GetLocalFunctionBody(
LocalFunctionStatementSyntax
localFunctionStatementSyntax)
Syntax\LocalFunctionStatementSyntax.cs (3)
12
public
LocalFunctionStatementSyntax
Update(SyntaxTokenList modifiers, TypeSyntax returnType, SyntaxToken identifier, TypeParameterListSyntax typeParameterList, ParameterListSyntax parameterList, SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses, BlockSyntax body, ArrowExpressionClauseSyntax expressionBody, SyntaxToken semicolonToken)
24
public static
LocalFunctionStatementSyntax
LocalFunctionStatement(SyntaxTokenList modifiers, TypeSyntax returnType, SyntaxToken identifier, TypeParameterListSyntax? typeParameterList, ParameterListSyntax parameterList, SyntaxList<TypeParameterConstraintClauseSyntax> constraintClauses, BlockSyntax? body, ArrowExpressionClauseSyntax? expressionBody)
30
public 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)
229
internal static bool IsInLocalFunctionTypeParameterScope(int position,
LocalFunctionStatementSyntax
localFunction)
442
LocalFunctionStatementSyntax
localFunctionStmt = (
LocalFunctionStatementSyntax
)statement;
Syntax\SyntaxFacts.cs (1)
188
return ((
LocalFunctionStatementSyntax
)parent).ReturnType == node;
Syntax\SyntaxNodeExtensions.cs (1)
267
(current.Parent is
LocalFunctionStatementSyntax
localFunction && localFunction.ReturnType == current) ||
Microsoft.CodeAnalysis.CSharp.CodeStyle (33)
src\Analyzers\CSharp\Analyzers\MakeLocalFunctionStatic\MakeLocalFunctionStaticDiagnosticAnalyzer.cs (2)
38
var
localFunction = (
LocalFunctionStatementSyntax
)context.Node;
src\Analyzers\CSharp\Analyzers\MakeLocalFunctionStatic\MakeLocalFunctionStaticHelper.cs (5)
17
private static bool TryGetDataFlowAnalysis(
LocalFunctionStatementSyntax
localFunction, SemanticModel semanticModel, [NotNullWhen(returnValue: true)] out DataFlowAnalysis? dataFlow)
23
private static bool CanBeCalledFromStaticContext(
LocalFunctionStatementSyntax
localFunction, DataFlowAnalysis dataFlow)
30
static bool IsChildOrSelf(
LocalFunctionStatementSyntax
containingLocalFunction, ISymbol calledLocationFunction)
38
public static bool CanMakeLocalFunctionStaticBecauseNoCaptures(
LocalFunctionStatementSyntax
localFunction, SemanticModel semanticModel)
43
public static bool CanMakeLocalFunctionStaticByRefactoringCaptures(
LocalFunctionStatementSyntax
localFunction, SemanticModel semanticModel, out ImmutableArray<ISymbol> captures)
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyForLocalFunctionHelper.cs (11)
18
UseExpressionBodyHelper<
LocalFunctionStatementSyntax
>
35
protected override BlockSyntax GetBody(
LocalFunctionStatementSyntax
statement)
38
protected override ArrowExpressionClauseSyntax GetExpressionBody(
LocalFunctionStatementSyntax
statement)
41
protected override SyntaxToken GetSemicolonToken(
LocalFunctionStatementSyntax
statement)
44
protected override
LocalFunctionStatementSyntax
WithSemicolonToken(
LocalFunctionStatementSyntax
statement, SyntaxToken token)
47
protected override
LocalFunctionStatementSyntax
WithExpressionBody(
LocalFunctionStatementSyntax
statement, ArrowExpressionClauseSyntax expressionBody)
50
protected override
LocalFunctionStatementSyntax
WithBody(
LocalFunctionStatementSyntax
statement, BlockSyntax body)
54
SemanticModel semanticModel,
LocalFunctionStatementSyntax
statement)
src\Analyzers\CSharp\Analyzers\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (1)
105
LocalFunctionStatementSyntax
localFunction => localFunction.ReturnType,
src\Analyzers\CSharp\Analyzers\UseSimpleUsingStatement\UseSimpleUsingStatementDiagnosticAnalyzer.cs (1)
239
while (index + 1 < statements.Count && statements[index + 1] is
LocalFunctionStatementSyntax
)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ILocalSymbolExtensions.cs (3)
18
var
localFunctionStatement = destinationBlock.FirstAncestorOrSelf<
LocalFunctionStatementSyntax
>();
38
case
LocalFunctionStatementSyntax
localFunctionStatement:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
472
public static IMethodSymbol GetRequiredDeclaredSymbol(this SemanticModel semanticModel,
LocalFunctionStatementSyntax
syntax, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (5)
151
LocalFunctionStatementSyntax
localFunction => localFunction.ParameterList,
280
=> node is MethodDeclarationSyntax or AnonymousFunctionExpressionSyntax or
LocalFunctionStatementSyntax
;
343
case
LocalFunctionStatementSyntax
localFunction when localFunction.Modifiers.Any(SyntaxKind.StaticKeyword):
743
LocalFunctionStatementSyntax
localFunction => localFunction.Modifiers,
755
LocalFunctionStatementSyntax
localFunction => localFunction.WithModifiers(modifiers),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (1)
470
else if (currentToken.Parent is
LocalFunctionStatementSyntax
)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (1)
212
if (node is AnonymousFunctionExpressionSyntax or
LocalFunctionStatementSyntax
)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (1)
314
LocalFunctionStatementSyntax
localFunc => localFunc.Modifiers,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (1)
79
var node = TryGetAncestorForLocation<
LocalFunctionStatementSyntax
>(root, position);
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (38)
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AssignOutParametersAboveReturnCodeFixProvider.cs (1)
48
if (exprOrStatement is
LocalFunctionStatementSyntax
{ ExpressionBody: { } localFunctionExpressionBody })
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AssignOutParametersAtStartCodeFixProvider.cs (1)
33
if (location is
LocalFunctionStatementSyntax
{ ExpressionBody: { } })
src\Analyzers\CSharp\CodeFixes\FixReturnType\CSharpFixReturnTypeCodeFixProvider.cs (1)
148
LocalFunctionStatementSyntax
localFunction => (localFunction.ReturnType, localFunction.Modifiers.Any(SyntaxKind.AsyncKeyword)),
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeFixHelper.cs (4)
30
LocalFunctionStatementSyntax
localFunction,
42
LocalFunctionStatementSyntax
localFunction,
175
var
localFunctionWithNewParameters = (
LocalFunctionStatementSyntax
)info.Service.AddParameters(
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\PassInCapturedVariablesAsArgumentsCodeFixProvider.cs (2)
65
Func<Document,
LocalFunctionStatementSyntax
, ImmutableArray<ISymbol>, Task> fixer,
77
.Select(d => root.FindNode(d.Location.SourceSpan).AncestorsAndSelf().OfType<
LocalFunctionStatementSyntax
>().FirstOrDefault())
src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (3)
80
LocalFunctionStatementSyntax
localFunction => FixLocalFunction(keepVoid, methodSymbol, localFunction, knownTypes, cancellationToken),
99
private static
LocalFunctionStatementSyntax
FixLocalFunction(
102
LocalFunctionStatementSyntax
localFunction,
src\Analyzers\CSharp\CodeFixes\MakeMethodSynchronous\CSharpMakeMethodSynchronousCodeFixProvider.cs (2)
37
case
LocalFunctionStatementSyntax
localFunction: return FixLocalFunction(methodSymbol, localFunction, knownTypes);
50
private static SyntaxNode FixLocalFunction(IMethodSymbol methodSymbol,
LocalFunctionStatementSyntax
localFunction, KnownTaskTypes knownTypes)
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (1)
146
LocalFunctionStatementSyntax
localFunction =>
src\Analyzers\CSharp\CodeFixes\RemoveAsyncModifier\CSharpRemoveAsyncModifierCodeFixProvider.cs (2)
42
LocalFunctionStatementSyntax
localFunction => localFunction.WithBody(block).WithExpressionBody(null).WithSemicolonToken(default),
55
LocalFunctionStatementSyntax
localFunction => RemoveAsyncModifierHelpers.WithoutAsyncModifier(localFunction, localFunction.ReturnType),
src\Analyzers\CSharp\CodeFixes\RemoveAsyncModifier\RemoveAsyncModifierHelpers.cs (1)
18
internal static SyntaxNode WithoutAsyncModifier(
LocalFunctionStatementSyntax
localFunction, TypeSyntax returnType)
src\Analyzers\CSharp\CodeFixes\RemoveUnusedLocalFunction\CSharpRemoveUnusedLocalFunctionCodeFixProvider.cs (1)
52
.Select(t => t.GetAncestor<
LocalFunctionStatementSyntax
>());
src\Analyzers\CSharp\CodeFixes\UseLocalFunction\CSharpUseLocalFunctionCodeFixProvider.cs (1)
197
private static
LocalFunctionStatementSyntax
CreateLocalFunctionStatement(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (3)
492
else if (destinationMember is
LocalFunctionStatementSyntax
localFunctionStatement)
613
TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements,
LocalFunctionStatementSyntax
localFunctionStatement) where TDeclarationNode : SyntaxNode
625
var
finalMember = localFunctionStatement
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (8)
92
public static
LocalFunctionStatementSyntax
GenerateLocalFunctionDeclaration(
98
var
reusableSyntax = GetReuseableSyntaxNodeForSymbol<
LocalFunctionStatementSyntax
>(method, info);
104
var
declaration = GenerateLocalFunctionDeclarationWorker(
164
private static
LocalFunctionStatementSyntax
GenerateLocalFunctionDeclarationWorker(
168
var
localFunctionDeclaration = LocalFunctionStatement(
201
private static
LocalFunctionStatementSyntax
UseExpressionBodyIfDesired(
202
CSharpCodeGenerationContextInfo info,
LocalFunctionStatementSyntax
localFunctionDeclaration, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (1)
507
targetToken.GetAncestors<
LocalFunctionStatementSyntax
>().Any(f => f.GetModifiers().Any(SyntaxKind.UnsafeKeyword))) ||
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (1)
1130
MethodDeclarationSyntax or
LocalFunctionStatementSyntax
or ConstructorDeclarationSyntax or DelegateDeclarationSyntax or TypeDeclarationSyntax => true,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ExpressionSyntaxExtensions.cs (1)
172
if (name.IsFoundUnder<
LocalFunctionStatementSyntax
>(d => d.ReturnType) ||
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpMoveDeclarationNearReferenceService.cs (1)
35
LocalFunctionStatementSyntax
or
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\InitializeParameter\InitializeParameterHelpers.cs (3)
135
=> node is BaseMethodDeclarationSyntax or
LocalFunctionStatementSyntax
or AnonymousFunctionExpressionSyntax;
141
LocalFunctionStatementSyntax
localFunction => (SyntaxNode?)localFunction.Body ?? localFunction.ExpressionBody!,
150
LocalFunctionStatementSyntax
localFunction => localFunction.SemicolonToken,
Microsoft.CodeAnalysis.CSharp.EditorFeatures (8)
AutomaticCompletion\AutomaticLineEnderCommandHandler.cs (2)
325
or
LocalFunctionStatementSyntax
401
or
LocalFunctionStatementSyntax
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (6)
467
LocalFunctionStatementSyntax
localFunctionStatementNode => ShouldAddBraceForLocalFunctionStatement(localFunctionStatementNode, caretPosition),
522
private static bool ShouldAddBraceForLocalFunctionStatement(
LocalFunctionStatementSyntax
localFunctionStatementNode, int caretPosition)
752
if (node is
LocalFunctionStatementSyntax
{ Body: { } localFunctionBody })
877
LocalFunctionStatementSyntax
localFunctionStatementNode => AddBlockToLocalFunctionDeclaration(localFunctionStatementNode, formattingOptions),
913
private static
LocalFunctionStatementSyntax
AddBlockToLocalFunctionDeclaration(
914
LocalFunctionStatementSyntax
localFunctionStatementNode,
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (31)
RefactoringHelpers\RefactoringHelpersTests.cs (31)
32
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
50
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
68
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
87
await TestMissingAsync<
LocalFunctionStatementSyntax
>(testText);
105
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
123
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
144
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
162
await TestMissingAsync<
LocalFunctionStatementSyntax
>(testText);
183
await TestMissingAsync<
LocalFunctionStatementSyntax
>(testText);
204
await TestMissingAsync<
LocalFunctionStatementSyntax
>(testText);
223
await TestMissingAsync<
LocalFunctionStatementSyntax
>(testText);
241
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
260
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
280
await TestMissingAsync<
LocalFunctionStatementSyntax
>(testText);
299
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
319
await TestMissingAsync<
LocalFunctionStatementSyntax
>(testText);
416
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
434
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
452
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
470
await TestMissingAsync<
LocalFunctionStatementSyntax
>(testText);
488
await TestMissingAsync<
LocalFunctionStatementSyntax
>(testText);
506
await TestMissingAsync<
LocalFunctionStatementSyntax
>(testText);
524
await TestMissingAsync<
LocalFunctionStatementSyntax
>(testText);
542
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
564
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
584
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
604
await TestMissingAsync<
LocalFunctionStatementSyntax
>(testText);
624
await TestMissingAsync<
LocalFunctionStatementSyntax
>(testText);
1235
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
1260
await TestAsync<
LocalFunctionStatementSyntax
>(testText);
1281
await TestMissingAsync<
LocalFunctionStatementSyntax
>(testText);
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (8)
CodeGen\CodeGenLocalFunctionTests.cs (8)
146
var
localFunction = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
5749
.GetDeclaredSymbol(syntaxTree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single())
5824
.GetDeclaredSymbol(syntaxTree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single())
5897
var localFunctions = syntaxTree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().ToList();
5905
void checkImplAttributes(
LocalFunctionStatementSyntax
localFunctionStatement, MethodImplAttributes expectedFlags)
6162
var
localFunctionSyntax = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (7)
Attributes\AttributeTests_WellKnownAttributes.cs (2)
5768
var
localFunctionSyntax = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
RefStructInterfacesTests.cs (2)
21245
var localFunctions = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().ToArray();
21248
foreach (
var
localFunction in localFunctions)
Semantics\OutVarTests.cs (3)
36416
Assert.Same(symbolInfo.Symbol, speculativeModel.GetDeclaredSymbol(tree2.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Where(l => l.Identifier.ValueText == "M2").Single()));
36498
Assert.Same(symbolInfo.Symbol, speculativeModel.GetDeclaredSymbol(tree2.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Where(l => l.Identifier.ValueText == "M2").Single()));
36571
Assert.Same(symbolInfo.Symbol, speculativeModel.GetDeclaredSymbol(tree2.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Where(l => l.Identifier.ValueText == "M2").Single()));
Microsoft.CodeAnalysis.CSharp.Features (91)
ChangeSignature\CSharpChangeSignatureService.cs (1)
332
if (updatedNode is
LocalFunctionStatementSyntax
localFunction)
CodeRefactorings\ConvertLocalFunctionToMethod\CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs (3)
39
var localFunction = await context.TryGetRelevantNodeAsync<
LocalFunctionStatementSyntax
>().ConfigureAwait(false);
69
LocalFunctionStatementSyntax
localFunction,
275
MethodDeclarationSyntax method,
LocalFunctionStatementSyntax
localFunction)
Completion\CompletionProviders\AwaitCompletionProvider.cs (3)
45
LocalFunctionStatementSyntax
local => local.ReturnType.SpanStart,
61
LocalFunctionStatementSyntax
local => local.ReturnType,
107
if (parent is NameSyntax { Parent:
LocalFunctionStatementSyntax
localFunction } name &&
Completion\CompletionProviders\DeclarationName\DeclarationNameInfo.cs (1)
334
result = IsLastTokenOfType<
LocalFunctionStatementSyntax
>(token, semanticModel,
Completion\KeywordRecommenders\MethodKeywordRecommender.cs (1)
29
or
LocalFunctionStatementSyntax
Completion\KeywordRecommenders\WhereKeywordRecommender.cs (1)
81
else if (tokenParent.Parent is
LocalFunctionStatementSyntax
{ TypeParameterList.Parameters.Count: > 0 })
ConvertLinq\CSharpConvertLinqQueryToForEachProvider.cs (1)
582
var
localFunctionDeclaration = LocalFunctionStatement(
EditAndContinue\BreakpointSpans.cs (2)
419
var
localFunction = (
LocalFunctionStatementSyntax
)node;
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (5)
483
if (root is
LocalFunctionStatementSyntax
localFunc)
1475
=> node is
LocalFunctionStatementSyntax
{ TypeParameterList: not null };
1478
=> node is AnonymousFunctionExpressionSyntax or
LocalFunctionStatementSyntax
;
1841
var
lfd = (
LocalFunctionStatementSyntax
)node;
EditAndContinue\SyntaxComparer.cs (2)
1018
var
localFunction = (
LocalFunctionStatementSyntax
)nestedFunction;
EditAndContinue\SyntaxUtilities.cs (1)
224
LocalFunctionStatementSyntax
localFunction => localFunction.Modifiers.Any(SyntaxKind.AsyncKeyword),
ExtractMethod\CSharpMethodExtractor.cs (1)
75
if (currentNode is
LocalFunctionStatementSyntax
localFunction)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (6)
709
LocalFunctionStatementSyntax
localFunction => TweakNewLinesInMethod(localFunction),
722
private static
LocalFunctionStatementSyntax
TweakNewLinesInMethod(
LocalFunctionStatementSyntax
method)
757
var nodeIsMethodOrLocalFunction = syntaxNode is MethodDeclarationSyntax or
LocalFunctionStatementSyntax
;
765
var returnType = syntaxNode is MethodDeclarationSyntax method ? method.ReturnType : ((
LocalFunctionStatementSyntax
)syntaxNode).ReturnType;
776
LocalFunctionStatementSyntax
_ => true,
ExtractMethod\CSharpMethodExtractor.TriviaResult.cs (3)
39
var isMethodOrLocalFunction = method is MethodDeclarationSyntax or
LocalFunctionStatementSyntax
;
50
var isMethodOrLocalFunction = method is MethodDeclarationSyntax or
LocalFunctionStatementSyntax
;
140
LocalFunctionStatementSyntax
localFunctionDeclaration => (localFunctionDeclaration.Body, localFunctionDeclaration.ExpressionBody, localFunctionDeclaration.SemicolonToken),
ExtractMethod\CSharpSelectionResult.cs (1)
93
if (current is AnonymousFunctionExpressionSyntax or
LocalFunctionStatementSyntax
)
ExtractMethod\CSharpSelectionResult.StatementResult.cs (1)
52
LocalFunctionStatementSyntax
or
ExtractMethod\CSharpSelectionValidator.cs (1)
141
if (current is AnonymousFunctionExpressionSyntax or
LocalFunctionStatementSyntax
or MemberDeclarationSyntax)
Highlighting\KeywordHighlighters\AsyncAwaitHighlighter.cs (1)
73
LocalFunctionStatementSyntax
localFunction => TryAddAsyncModifier(localFunction.Modifiers, spans),
IntroduceVariable\CSharpIntroduceVariableService.cs (1)
145
var localFunction = expression.GetAncestor<
LocalFunctionStatementSyntax
>();
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (4)
262
LocalFunctionStatementSyntax
localFunction => localFunction
284
var localFunction = expression.GetAncestor<
LocalFunctionStatementSyntax
>();
351
var localFunction = block.GetAncestor<
LocalFunctionStatementSyntax
>();
440
var localFunctionIdentifiers = localFunctions.Select(node => ((
LocalFunctionStatementSyntax
)node).Identifier.ValueText);
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (2)
71
case
LocalFunctionStatementSyntax
:
98
LocalFunctionStatementSyntax
or AccessorDeclarationSyntax or MemberDeclarationSyntax
MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeRefactoringProvider.cs (1)
33
var localFunction = await context.TryGetRelevantNodeAsync<
LocalFunctionStatementSyntax
>().ConfigureAwait(false);
src\Analyzers\CSharp\Analyzers\MakeLocalFunctionStatic\MakeLocalFunctionStaticDiagnosticAnalyzer.cs (2)
38
var
localFunction = (
LocalFunctionStatementSyntax
)context.Node;
src\Analyzers\CSharp\Analyzers\MakeLocalFunctionStatic\MakeLocalFunctionStaticHelper.cs (5)
17
private static bool TryGetDataFlowAnalysis(
LocalFunctionStatementSyntax
localFunction, SemanticModel semanticModel, [NotNullWhen(returnValue: true)] out DataFlowAnalysis? dataFlow)
23
private static bool CanBeCalledFromStaticContext(
LocalFunctionStatementSyntax
localFunction, DataFlowAnalysis dataFlow)
30
static bool IsChildOrSelf(
LocalFunctionStatementSyntax
containingLocalFunction, ISymbol calledLocationFunction)
38
public static bool CanMakeLocalFunctionStaticBecauseNoCaptures(
LocalFunctionStatementSyntax
localFunction, SemanticModel semanticModel)
43
public static bool CanMakeLocalFunctionStaticByRefactoringCaptures(
LocalFunctionStatementSyntax
localFunction, SemanticModel semanticModel, out ImmutableArray<ISymbol> captures)
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyForLocalFunctionHelper.cs (11)
18
UseExpressionBodyHelper<
LocalFunctionStatementSyntax
>
35
protected override BlockSyntax GetBody(
LocalFunctionStatementSyntax
statement)
38
protected override ArrowExpressionClauseSyntax GetExpressionBody(
LocalFunctionStatementSyntax
statement)
41
protected override SyntaxToken GetSemicolonToken(
LocalFunctionStatementSyntax
statement)
44
protected override
LocalFunctionStatementSyntax
WithSemicolonToken(
LocalFunctionStatementSyntax
statement, SyntaxToken token)
47
protected override
LocalFunctionStatementSyntax
WithExpressionBody(
LocalFunctionStatementSyntax
statement, ArrowExpressionClauseSyntax expressionBody)
50
protected override
LocalFunctionStatementSyntax
WithBody(
LocalFunctionStatementSyntax
statement, BlockSyntax body)
54
SemanticModel semanticModel,
LocalFunctionStatementSyntax
statement)
src\Analyzers\CSharp\Analyzers\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (1)
105
LocalFunctionStatementSyntax
localFunction => localFunction.ReturnType,
src\Analyzers\CSharp\Analyzers\UseSimpleUsingStatement\UseSimpleUsingStatementDiagnosticAnalyzer.cs (1)
239
while (index + 1 < statements.Count && statements[index + 1] is
LocalFunctionStatementSyntax
)
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AssignOutParametersAboveReturnCodeFixProvider.cs (1)
48
if (exprOrStatement is
LocalFunctionStatementSyntax
{ ExpressionBody: { } localFunctionExpressionBody })
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AssignOutParametersAtStartCodeFixProvider.cs (1)
33
if (location is
LocalFunctionStatementSyntax
{ ExpressionBody: { } })
src\Analyzers\CSharp\CodeFixes\FixReturnType\CSharpFixReturnTypeCodeFixProvider.cs (1)
148
LocalFunctionStatementSyntax
localFunction => (localFunction.ReturnType, localFunction.Modifiers.Any(SyntaxKind.AsyncKeyword)),
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeFixHelper.cs (4)
30
LocalFunctionStatementSyntax
localFunction,
42
LocalFunctionStatementSyntax
localFunction,
175
var
localFunctionWithNewParameters = (
LocalFunctionStatementSyntax
)info.Service.AddParameters(
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\PassInCapturedVariablesAsArgumentsCodeFixProvider.cs (2)
65
Func<Document,
LocalFunctionStatementSyntax
, ImmutableArray<ISymbol>, Task> fixer,
77
.Select(d => root.FindNode(d.Location.SourceSpan).AncestorsAndSelf().OfType<
LocalFunctionStatementSyntax
>().FirstOrDefault())
src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (3)
80
LocalFunctionStatementSyntax
localFunction => FixLocalFunction(keepVoid, methodSymbol, localFunction, knownTypes, cancellationToken),
99
private static
LocalFunctionStatementSyntax
FixLocalFunction(
102
LocalFunctionStatementSyntax
localFunction,
src\Analyzers\CSharp\CodeFixes\MakeMethodSynchronous\CSharpMakeMethodSynchronousCodeFixProvider.cs (2)
37
case
LocalFunctionStatementSyntax
localFunction: return FixLocalFunction(methodSymbol, localFunction, knownTypes);
50
private static SyntaxNode FixLocalFunction(IMethodSymbol methodSymbol,
LocalFunctionStatementSyntax
localFunction, KnownTaskTypes knownTypes)
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (1)
146
LocalFunctionStatementSyntax
localFunction =>
src\Analyzers\CSharp\CodeFixes\RemoveAsyncModifier\CSharpRemoveAsyncModifierCodeFixProvider.cs (2)
42
LocalFunctionStatementSyntax
localFunction => localFunction.WithBody(block).WithExpressionBody(null).WithSemicolonToken(default),
55
LocalFunctionStatementSyntax
localFunction => RemoveAsyncModifierHelpers.WithoutAsyncModifier(localFunction, localFunction.ReturnType),
src\Analyzers\CSharp\CodeFixes\RemoveAsyncModifier\RemoveAsyncModifierHelpers.cs (1)
18
internal static SyntaxNode WithoutAsyncModifier(
LocalFunctionStatementSyntax
localFunction, TypeSyntax returnType)
src\Analyzers\CSharp\CodeFixes\RemoveUnusedLocalFunction\CSharpRemoveUnusedLocalFunctionCodeFixProvider.cs (1)
52
.Select(t => t.GetAncestor<
LocalFunctionStatementSyntax
>());
src\Analyzers\CSharp\CodeFixes\UseLocalFunction\CSharpUseLocalFunctionCodeFixProvider.cs (1)
197
private static
LocalFunctionStatementSyntax
CreateLocalFunctionStatement(
src\Compilers\CSharp\Portable\Syntax\LambdaUtilities.cs (7)
116
return GetLocalFunctionBody((
LocalFunctionStatementSyntax
)newLambda);
127
LocalFunctionStatementSyntax
localFunctionStatementSyntax => (CSharpSyntaxNode?)localFunctionStatementSyntax.Body ?? localFunctionStatementSyntax.ExpressionBody!.Expression,
156
var
localFunction = (
LocalFunctionStatementSyntax
)parent;
161
return arrowExpressionClause.Expression == node && arrowExpressionClause.Parent is
LocalFunctionStatementSyntax
;
350
lambdaBody1 = GetLocalFunctionBody((
LocalFunctionStatementSyntax
)node);
484
private static SyntaxNode? GetLocalFunctionBody(
LocalFunctionStatementSyntax
localFunctionStatementSyntax)
UsePatternMatching\CSharpIsAndCastCheckWithoutNameDiagnosticAnalyzer.cs (1)
184
if (node is
LocalFunctionStatementSyntax
localFunction && localFunction.Modifiers.Any(SyntaxKind.StaticKeyword))
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (6)
EditAndContinue\SyntaxUtilitiesTests.cs (6)
189
var
f1 = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single(m => m.Identifier.ValueText == "f1");
190
var
f2 = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single(m => m.Identifier.ValueText == "f2");
255
var
f = m2.DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single(m => m.Identifier.ValueText == "f");
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (18)
IOperation\IOperationTests_ILocalFunctionStatement.cs (17)
49
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
77
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
105
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
140
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
181
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
217
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
266
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics, targetFramework: TargetFramework.Mscorlib46Extended);
295
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
331
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
365
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
404
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
436
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
468
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
503
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
547
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
640
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
703
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
IOperation\IOperationTests_IParameterReferenceExpression.cs (1)
1119
VerifyOperationTreeAndDiagnosticsForTest<
LocalFunctionStatementSyntax
>(source, expectedOperationTree, expectedDiagnostics);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (54)
Semantics\InitOnlyMemberTests.cs (2)
4143
var
localFunctionSyntax = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
Semantics\LocalFunctionTests.cs (17)
493
var
localFunction = tree.GetRoot().DescendantNodes()
494
.OfType<
LocalFunctionStatementSyntax
>()
541
var
localFunction = tree.GetRoot().DescendantNodes()
542
.OfType<
LocalFunctionStatementSyntax
>()
805
var
localFunction = tree.GetRoot().DescendantNodes()
806
.OfType<
LocalFunctionStatementSyntax
>()
852
var
localFunction = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
968
var
localFunction = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
2373
LocalFunctionStatementSyntax
declaration = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().First();
2587
var exprs = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().ToImmutableArray();
5105
var
localDecl = (
LocalFunctionStatementSyntax
)tree.FindNodeOrTokenByKind(SyntaxKind.LocalFunctionStatement).AsNode();
10385
var
localFunction = root.DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
Semantics\NullableReferenceTypesTests.cs (10)
65890
var
function1 = tree1.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Last();
65894
var
function2 = tree2.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
97757
var localSyntaxes = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().ToArray();
99086
var localSyntaxes = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().ToArray();
111770
var localSyntaxes = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>();
111775
void verifyLocalFunction(
LocalFunctionStatementSyntax
localSyntax, string expectedName, string[] expectedConstraintTypes)
111824
var localSyntaxes = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>();
111828
void verifyLocalFunction(
LocalFunctionStatementSyntax
localSyntax, string expectedName, string[] expectedConstraintTypes)
Semantics\RefFieldTests.cs (1)
11025
var decls = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().ToArray();
Semantics\TopLevelStatementsTests.cs (18)
235
var
localDecl = unit1.DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
358
var
localDecl = unit2.DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
2084
var
localDecl = tree1.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
2248
var
localDecl = tree1.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
4215
var
declarator = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
4510
var symbol1 = model1.GetDeclaredSymbol(tree1.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single());
4516
var symbol2 = model2.GetDeclaredSymbol(tree2.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().First());
4574
var symbol1 = model1.GetDeclaredSymbol(tree1.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().First());
4578
var symbol2 = model1.GetDeclaredSymbol(tree1.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Skip(1).First());
4623
var symbol1 = model1.GetDeclaredSymbol(tree1.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().First());
6086
var localFunctions = syntaxTree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().ToList();
6094
void checkImplAttributes(
LocalFunctionStatementSyntax
localFunctionStatement, MethodImplAttributes expectedFlags)
6160
.GetDeclaredSymbol(syntaxTree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single())
SourceGeneration\GeneratorDriverTests_Attributes_FullyQualifiedName.cs (6)
326
var input = ctx.ForAttributeWithMetadataName<
LocalFunctionStatementSyntax
>("System.CLSCompliantAttribute");
335
step => Assert.True(step.Outputs.Single().Value is
LocalFunctionStatementSyntax
{ Identifier.ValueText: "LocalFunc" }));
362
var input = ctx.ForAttributeWithMetadataName<
LocalFunctionStatementSyntax
>("System.CLSCompliantAttribute");
371
step => Assert.True(step.Outputs.Single().Value is
LocalFunctionStatementSyntax
{ Identifier.ValueText: "LocalFunc" }));
401
var input = ctx.ForAttributeWithMetadataName<
LocalFunctionStatementSyntax
>("System.CLSCompliantAttribute");
410
step => Assert.True(step.Outputs.Single().Value is
LocalFunctionStatementSyntax
{ Identifier.ValueText: "LocalFunc" }));
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (23)
Symbols\LocalFunctionTests.cs (7)
35
var
localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
56
var
localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
77
var
localSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
100
var localsSyntax = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().ToArray();
Symbols\Source\NullablePublicAPITests.cs (16)
570
return syntaxTree.GetRoot().DescendantNodes().OfType<CSharp.Syntax.
LocalFunctionStatementSyntax
>().Select(func => semanticModel.GetDeclaredSymbol(func)).Cast<IMethodSymbol>().ToArray();
3664
var
localFunction = lambda.DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
3697
var
localFunctionBody = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
3876
var
localFunction = lambda.DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
4062
var
localFunction = root.DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
4117
var
localFunction = lambda.DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
4179
var
localFunction = lambda.DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().First();
4181
var nestedLocalFunction = (IMethodSymbol)model.GetDeclaredSymbol(lambda.DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().ElementAt(1));
4933
var
localFunction = tree.GetRoot().DescendantNodes().OfType<
LocalFunctionStatementSyntax
>().Single();
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (18)
Generated\Syntax.Test.xml.Generated.cs (5)
10556
private static
LocalFunctionStatementSyntax
GenerateLocalFunctionStatement()
12250
var
node = GenerateLocalFunctionStatement();
12262
var
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);
16933
var
oldNode = GenerateLocalFunctionStatement();
16949
var
oldNode = GenerateLocalFunctionStatement();
IncrementalParsing\IncrementalParsingTests.cs (2)
565
var localFunc1 = tree.GetRoot().DescendantNodesAndSelf().Single(n => n is
LocalFunctionStatementSyntax
);
582
var localFunc2 = tree.GetRoot().DescendantNodesAndSelf().Single(n => n is
LocalFunctionStatementSyntax
);
Parsing\LocalFunctionParsingTests.cs (6)
1297
var
s1 = Assert.IsType<
LocalFunctionStatementSyntax
>(m.Body.Statements[0]);
1301
s1 = Assert.IsType<
LocalFunctionStatementSyntax
>(m.Body.Statements[0]);
1349
var
s1 = Assert.IsType<
LocalFunctionStatementSyntax
>(m.Body.Statements[0]);
1359
s1 = Assert.IsType<
LocalFunctionStatementSyntax
>(m2.Body.Statements[0]);
Parsing\ParserErrorMessageTests.cs (3)
3773
var
localFunctionStatement = (
LocalFunctionStatementSyntax
)tree.GetRoot().DescendantNodes().Single(node => node is
LocalFunctionStatementSyntax
);
Syntax\SyntaxNodeTests.cs (2)
3331
var
method = (
LocalFunctionStatementSyntax
)((GlobalStatementSyntax)root.Members[0]).Statement;
Microsoft.CodeAnalysis.CSharp.Workspaces (44)
Classification\ClassificationHelpers.cs (1)
218
else if (token.Parent is
LocalFunctionStatementSyntax
localFunctionStatement && localFunctionStatement.Identifier == token)
CodeGeneration\CSharpSyntaxGenerator.cs (9)
1655
LocalFunctionStatementSyntax
localFunc => localFunc.WithModifiers(modifiers),
2222
return ((
LocalFunctionStatementSyntax
)declaration).WithParameterList((ParameterListSyntax)list);
2286
var
local = (
LocalFunctionStatementSyntax
)declaration;
2342
var
local = (
LocalFunctionStatementSyntax
)declaration;
2464
SyntaxKind.LocalFunctionStatement => ((
LocalFunctionStatementSyntax
)declaration).Body?.Statements,
2483
LocalFunctionStatementSyntax
localFunction => localFunction.Body,
2496
LocalFunctionStatementSyntax
localFunction => localFunction.WithBody(somebody).WithSemicolonToken(semicolon).WithExpressionBody(null),
FindSymbols\CSharpDeclaredSymbolInfoFactoryService.cs (2)
184
if (node.AsNode() is
LocalFunctionStatementSyntax
localFunction)
500
private static string GetMethodSuffix(
LocalFunctionStatementSyntax
method)
Recommendations\CSharpRecommendationServiceRunner.cs (1)
511
LocalFunctionStatementSyntax
localFunction => localFunction.Modifiers.Any(SyntaxKind.StaticKeyword),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ILocalSymbolExtensions.cs (3)
18
var
localFunctionStatement = destinationBlock.FirstAncestorOrSelf<
LocalFunctionStatementSyntax
>();
38
case
LocalFunctionStatementSyntax
localFunctionStatement:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
472
public static IMethodSymbol GetRequiredDeclaredSymbol(this SemanticModel semanticModel,
LocalFunctionStatementSyntax
syntax, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (5)
151
LocalFunctionStatementSyntax
localFunction => localFunction.ParameterList,
280
=> node is MethodDeclarationSyntax or AnonymousFunctionExpressionSyntax or
LocalFunctionStatementSyntax
;
343
case
LocalFunctionStatementSyntax
localFunction when localFunction.Modifiers.Any(SyntaxKind.StaticKeyword):
743
LocalFunctionStatementSyntax
localFunction => localFunction.Modifiers,
755
LocalFunctionStatementSyntax
localFunction => localFunction.WithModifiers(modifiers),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (1)
470
else if (currentToken.Parent is
LocalFunctionStatementSyntax
)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (1)
212
if (node is AnonymousFunctionExpressionSyntax or
LocalFunctionStatementSyntax
)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (1)
314
LocalFunctionStatementSyntax
localFunc => localFunc.Modifiers,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (1)
79
var node = TryGetAncestorForLocation<
LocalFunctionStatementSyntax
>(root, position);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (3)
492
else if (destinationMember is
LocalFunctionStatementSyntax
localFunctionStatement)
613
TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements,
LocalFunctionStatementSyntax
localFunctionStatement) where TDeclarationNode : SyntaxNode
625
var
finalMember = localFunctionStatement
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (8)
92
public static
LocalFunctionStatementSyntax
GenerateLocalFunctionDeclaration(
98
var
reusableSyntax = GetReuseableSyntaxNodeForSymbol<
LocalFunctionStatementSyntax
>(method, info);
104
var
declaration = GenerateLocalFunctionDeclarationWorker(
164
private static
LocalFunctionStatementSyntax
GenerateLocalFunctionDeclarationWorker(
168
var
localFunctionDeclaration = LocalFunctionStatement(
201
private static
LocalFunctionStatementSyntax
UseExpressionBodyIfDesired(
202
CSharpCodeGenerationContextInfo info,
LocalFunctionStatementSyntax
localFunctionDeclaration, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (1)
507
targetToken.GetAncestors<
LocalFunctionStatementSyntax
>().Any(f => f.GetModifiers().Any(SyntaxKind.UnsafeKeyword))) ||
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (1)
1130
MethodDeclarationSyntax or
LocalFunctionStatementSyntax
or ConstructorDeclarationSyntax or DelegateDeclarationSyntax or TypeDeclarationSyntax => true,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ExpressionSyntaxExtensions.cs (1)
172
if (name.IsFoundUnder<
LocalFunctionStatementSyntax
>(d => d.ReturnType) ||
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpMoveDeclarationNearReferenceService.cs (1)
35
LocalFunctionStatementSyntax
or
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\InitializeParameter\InitializeParameterHelpers.cs (3)
135
=> node is BaseMethodDeclarationSyntax or
LocalFunctionStatementSyntax
or AnonymousFunctionExpressionSyntax;
141
LocalFunctionStatementSyntax
localFunction => (SyntaxNode?)localFunction.Body ?? localFunction.ExpressionBody!,
150
LocalFunctionStatementSyntax
localFunction => localFunction.SemicolonToken,
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (2)
CodeGeneration\SyntaxGeneratorTests.cs (2)
3305
var
local = LocalFunctionStatement(PredefinedType(VoidKeyword), "p");
3341
var
local = LocalFunctionStatement(PredefinedType(VoidKeyword), "p");
Microsoft.CodeAnalysis.Features.UnitTests (1)
FindUsages\DefinitionItemFactoryTests.cs (1)
1452
var f = model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().Single(n => n is
LocalFunctionStatementSyntax
));
Microsoft.Interop.LibraryImportGenerator (3)
LibraryImportGenerator.cs (3)
364
LocalFunctionStatementSyntax
dllImport = CreateTargetDllImportAsLocalStatement(
432
private static
LocalFunctionStatementSyntax
CreateTargetDllImportAsLocalStatement(
442
LocalFunctionStatementSyntax
localDllImport = LocalFunctionStatement(returnType, stubTargetName)
Microsoft.Interop.LibraryImportGenerator.Downlevel (3)
DownlevelLibraryImportGenerator.cs (3)
259
LocalFunctionStatementSyntax
dllImport = CreateTargetDllImportAsLocalStatement(
311
private static
LocalFunctionStatementSyntax
CreateTargetDllImportAsLocalStatement(
318
LocalFunctionStatementSyntax
localDllImport = LocalFunctionStatement(returnType, stubTargetName)
System.Private.CoreLib.Generators (1)
IntrinsicsInSystemPrivateCoreLibAnalyzer.cs (1)
574
if (ancestorNode is
LocalFunctionStatementSyntax
)