1476 references to MethodDeclarationSyntax
ILLink.RoslynAnalyzer (3)
TrimAnalysis\TrimDataFlowAnalysis.cs (3)
96
var
method = op.Syntax.FirstAncestorOrSelf<
MethodDeclarationSyntax
> ();
97
if (method is
MethodDeclarationSyntax
)
Microsoft.Analyzers.Extra (2)
CallAnalysis\Fixers\LegacyLoggingFixer.cs (2)
169
foreach (
var
method in targetClass.Members.Where(m => m.IsKind(SyntaxKind.MethodDeclaration)).OfType<
MethodDeclarationSyntax
>())
Microsoft.AspNetCore.App.Analyzers (5)
RouteEmbeddedLanguage\FrameworkParametersCompletionProvider.cs (4)
190
var
methodSyntax = container.FirstAncestorOrSelf<
MethodDeclarationSyntax
>();
293
private static SyntaxToken? TryGetMvcActionRouteToken(CompletionContext context, SemanticModel semanticModel,
MethodDeclarationSyntax
method)
430
MethodDeclarationSyntax
methodDeclaration => methodDeclaration.ParameterList,
RouteEmbeddedLanguage\Infrastructure\RouteUsageDetector.cs (1)
113
if (attributeParent is
MethodDeclarationSyntax
methodDeclarationSyntax)
Microsoft.AspNetCore.Mvc.Api.Analyzers (4)
AddResponseTypeAttributeCodeFixAction.cs (4)
132
var
methodSyntax = diagnosticNode.FirstAncestorOrSelf<
MethodDeclarationSyntax
>();
258
MethodDeclarationSyntax
methodSyntax,
270
public
MethodDeclarationSyntax
MethodSyntax { get; }
Microsoft.AspNetCore.SignalR.Client.SourceGenerator (14)
HubClientProxyGenerator.cs (1)
35
private static void Execute(Compilation compilation, ImmutableArray<
MethodDeclarationSyntax
> methodDeclarationSyntaxes, ImmutableArray<MemberAccessExpressionSyntax> memberAccessExpressionSyntaxes, SourceProductionContext context)
HubClientProxyGenerator.Parser.cs (6)
29
Parent:
MethodDeclarationSyntax
36
internal static
MethodDeclarationSyntax
? GetSemanticTargetForAttribute(GeneratorSyntaxContext context)
47
return (
MethodDeclarationSyntax
)attributeSyntax.Parent.Parent;
183
internal SourceGenerationSpec Parse(ImmutableArray<
MethodDeclarationSyntax
> methodDeclarationSyntaxes, ImmutableArray<MemberAccessExpressionSyntax> syntaxList)
194
foreach (
var
extraneous in methodDeclarationSyntaxes)
206
var
methodDeclarationSyntax = methodDeclarationSyntaxes[0];
HubServerProxyGenerator.cs (1)
35
private static void Execute(Compilation compilation, ImmutableArray<
MethodDeclarationSyntax
> methodDeclarationSyntaxes, ImmutableArray<MemberAccessExpressionSyntax> memberAccessExpressionSyntaxes, SourceProductionContext context)
HubServerProxyGenerator.Parser.cs (6)
29
Parent:
MethodDeclarationSyntax
36
internal static
MethodDeclarationSyntax
? GetSemanticTargetForAttribute(GeneratorSyntaxContext context)
47
return (
MethodDeclarationSyntax
)attributeSyntax.Parent.Parent;
173
internal SourceGenerationSpec Parse(ImmutableArray<
MethodDeclarationSyntax
> methodDeclarationSyntaxes, ImmutableArray<MemberAccessExpressionSyntax> syntaxList)
184
foreach (
var
extraneous in methodDeclarationSyntaxes)
195
var
methodDeclarationSyntax = methodDeclarationSyntaxes[0];
Microsoft.CodeAnalysis.CSharp (45)
Binder\BinderFactory.BinderFactoryVisitor.cs (5)
135
public override Binder VisitMethodDeclaration(
MethodDeclarationSyntax
methodDecl)
474
MethodDeclarationSyntax
methodDeclSyntax = (
MethodDeclarationSyntax
)baseMethodDeclarationSyntax;
1333
MethodDeclarationSyntax
methodDeclSyntax = (
MethodDeclarationSyntax
)memberSyntax;
Binder\LocalBinderFactory.cs (1)
148
public override void VisitMethodDeclaration(
MethodDeclarationSyntax
node)
Compilation\CSharpSemanticModel.cs (2)
461
var
methodDecl = node.FirstAncestorOrSelf<
MethodDeclarationSyntax
>();
Compilation\SyntaxTreeSemanticModel.cs (2)
1628
var
methodDecl = (
MethodDeclarationSyntax
)declaration;
Lowering\Instrumentation\CodeCoverageInstrumenter.cs (2)
598
MethodDeclarationSyntax
methodSyntax = (
MethodDeclarationSyntax
)syntax;
Parser\LanguageParser.cs (2)
3465
private
MethodDeclarationSyntax
ParseMethodDeclaration(
5122
return ((CSharp.Syntax.
MethodDeclarationSyntax
)decl).Modifiers;
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (2)
295
if (node is
MethodDeclarationSyntax
methodDecl && methodDecl.TypeParameterList != null)
389
arrowExpr = ((
MethodDeclarationSyntax
)node).ExpressionBody;
Symbols\MethodSymbolExtensions.cs (1)
203
if (node is
MethodDeclarationSyntax
methodDeclaration)
Symbols\Source\ModifierUtils.cs (1)
29
if (readonlyToken.Parent is
MethodDeclarationSyntax
or AccessorDeclarationSyntax or BasePropertyDeclarationSyntax or EventDeclarationSyntax)
Symbols\Source\SourceMemberContainerSymbol.cs (2)
4978
var
methodSyntax = (
MethodDeclarationSyntax
)m;
Symbols\Source\SourceMethodSymbolWithAttributes.cs (1)
1534
MethodDeclarationSyntax
{ ReturnType: var methodReturnType } => methodReturnType,
Symbols\Source\SourceOrdinaryMethodSymbol.cs (16)
25
MethodDeclarationSyntax
syntax,
51
MethodDeclarationSyntax
syntax,
90
NamedTypeSymbol containingType, Location location,
MethodDeclarationSyntax
syntax, MethodKind methodKind,
115
var
syntax = GetSyntax();
207
var
syntax = GetSyntax();
268
internal
MethodDeclarationSyntax
GetSyntax()
271
return (
MethodDeclarationSyntax
)syntaxReferenceOpt.GetSyntax();
424
private static DeclarationModifiers MakeDeclarationModifiers(
MethodDeclarationSyntax
syntax, NamedTypeSymbol containingType, Location location, DeclarationModifiers allowedModifiers, BindingDiagnosticBag diagnostics)
687
private static (DeclarationModifiers mods, bool hasExplicitAccessMod) MakeModifiers(
MethodDeclarationSyntax
syntax, NamedTypeSymbol containingType, MethodKind methodKind, bool hasBody, Location location, BindingDiagnosticBag diagnostics)
921
MethodDeclarationSyntax
syntax,
979
MethodDeclarationSyntax
syntax,
1015
var
syntax = GetSyntax();
1035
var
syntax = GetSyntax();
1062
var
syntax = GetSyntax();
1085
var
syntax = this.GetSyntax();
1091
private ImmutableArray<TypeParameterSymbol> MakeTypeParameters(
MethodDeclarationSyntax
syntax, BindingDiagnosticBag diagnostics)
Symbols\VarianceSafety.cs (2)
142
var
syntax = m.GetDeclaringSyntax<
MethodDeclarationSyntax
>();
Syntax\LookupPosition.cs (1)
198
internal static bool IsInMethodTypeParameterScope(int position,
MethodDeclarationSyntax
methodDecl)
Syntax\MethodDeclarationSyntax.cs (1)
27
public static
MethodDeclarationSyntax
MethodDeclaration(
Syntax\SyntaxExtensions.cs (2)
311
public static
MethodDeclarationSyntax
Update(
312
this
MethodDeclarationSyntax
syntax,
Syntax\SyntaxFacts.cs (1)
167
return ((
MethodDeclarationSyntax
)parent).ReturnType == node;
Syntax\SyntaxNodeExtensions.cs (1)
268
(current.Parent is
MethodDeclarationSyntax
method && method.ReturnType == current) ||
Microsoft.CodeAnalysis.CSharp.CodeStyle (31)
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_TopLevelStatements.cs (4)
30
public static Location GetUseTopLevelStatementsDiagnosticLocation(
MethodDeclarationSyntax
methodDeclaration, bool isHidden)
46
MethodDeclarationSyntax
methodDeclaration,
138
if (member is not FieldDeclarationSyntax and not
MethodDeclarationSyntax
)
142
if (member is
MethodDeclarationSyntax
{ Body: null, ExpressionBody: null })
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertToTopLevelStatementsDiagnosticAnalyzer.cs (2)
66
var methodDeclarations = root.DescendantNodes(n => n is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax or ClassDeclarationSyntax).OfType<
MethodDeclarationSyntax
>();
67
foreach (
var
methodDeclaration in methodDeclarations)
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (1)
200
MethodDeclarationSyntax
methodDeclaration => methodDeclaration.Identifier,
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyForMethodsHelper.cs (11)
18
UseExpressionBodyHelper<
MethodDeclarationSyntax
>
35
protected override BlockSyntax GetBody(
MethodDeclarationSyntax
declaration)
38
protected override ArrowExpressionClauseSyntax GetExpressionBody(
MethodDeclarationSyntax
declaration)
41
protected override SyntaxToken GetSemicolonToken(
MethodDeclarationSyntax
declaration)
44
protected override
MethodDeclarationSyntax
WithSemicolonToken(
MethodDeclarationSyntax
declaration, SyntaxToken token)
47
protected override
MethodDeclarationSyntax
WithExpressionBody(
MethodDeclarationSyntax
declaration, ArrowExpressionClauseSyntax expressionBody)
50
protected override
MethodDeclarationSyntax
WithBody(
MethodDeclarationSyntax
declaration, BlockSyntax body)
54
SemanticModel semanticModel,
MethodDeclarationSyntax
declaration)
src\Analyzers\CSharp\Analyzers\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (1)
106
MethodDeclarationSyntax
method => method.ReturnType,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ILocalSymbolExtensions.cs (1)
35
case
MethodDeclarationSyntax
methodDeclaration:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberDeclarationSyntaxExtensions.cs (5)
52
return ((
MethodDeclarationSyntax
)member).Identifier;
83
return ((
MethodDeclarationSyntax
)member).Arity;
105
return ((
MethodDeclarationSyntax
)member).TypeParameterList;
123
return ((
MethodDeclarationSyntax
)member).WithParameterList((ParameterListSyntax)parameterList);
147
return ((
MethodDeclarationSyntax
)member).ReturnType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (1)
280
=> node is
MethodDeclarationSyntax
or AnonymousFunctionExpressionSyntax or LocalFunctionStatementSyntax;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (2)
70
var
method = (
MethodDeclarationSyntax
)declaration;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (1)
66
var node = TryGetAncestorForLocation<
MethodDeclarationSyntax
>(root, position);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (1)
1545
=> node is
MethodDeclarationSyntax
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
124
MethodDeclarationSyntax
or
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (46)
src\Analyzers\CSharp\CodeFixes\ConvertToAsync\CSharpConvertToAsyncMethodCodeFixProvider.cs (4)
60
private static async Task<
MethodDeclarationSyntax
?> GetMethodDeclarationAsync(
82
if ((await methodReference.GetSyntaxAsync(cancellationToken).ConfigureAwait(false)) is not
MethodDeclarationSyntax
methodDeclaration)
95
private static
MethodDeclarationSyntax
ConvertToAsyncFunction(
MethodDeclarationSyntax
methodDeclaration)
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (2)
219
foreach (
var
method in typeDeclaration.Members.OfType<
MethodDeclarationSyntax
>())
src\Analyzers\CSharp\CodeFixes\FixReturnType\CSharpFixReturnTypeCodeFixProvider.cs (1)
145
MethodDeclarationSyntax
method => (method.ReturnType, method.Modifiers.Any(SyntaxKind.AsyncKeyword)),
src\Analyzers\CSharp\CodeFixes\GenerateParameterizedMember\CSharpGenerateMethodService.cs (3)
30
=> node is
MethodDeclarationSyntax
;
55
var
methodDeclaration = (
MethodDeclarationSyntax
)node;
src\Analyzers\CSharp\CodeFixes\HideBase\HideBaseCodeFixProvider.cs (1)
38
token.GetAncestor<
MethodDeclarationSyntax
>() ??
src\Analyzers\CSharp\CodeFixes\Iterator\CSharpChangeToIEnumerableCodeFixProvider.cs (2)
75
var
newMethodDeclarationSyntax = (node as
MethodDeclarationSyntax
)?.WithReturnType(newReturnType);
src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (3)
79
MethodDeclarationSyntax
method => FixMethod(keepVoid, methodSymbol, method, knownTypes, cancellationToken),
86
private static
MethodDeclarationSyntax
FixMethod(
89
MethodDeclarationSyntax
method,
src\Analyzers\CSharp\CodeFixes\MakeMethodSynchronous\CSharpMakeMethodSynchronousCodeFixProvider.cs (2)
36
case
MethodDeclarationSyntax
method: return FixMethod(methodSymbol, method, knownTypes);
44
private static SyntaxNode FixMethod(IMethodSymbol methodSymbol,
MethodDeclarationSyntax
method, KnownTaskTypes knownTypes)
src\Analyzers\CSharp\CodeFixes\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyCodeFixProvider.cs (1)
47
if (declaration is
MethodDeclarationSyntax
or BasePropertyDeclarationSyntax)
src\Analyzers\CSharp\CodeFixes\MakeTypeAbstract\CSharpMakeTypeAbstractCodeFixProvider.cs (1)
26
case
MethodDeclarationSyntax
method:
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (2)
140
MethodDeclarationSyntax
method =>
262
node.Parent?.Parent is
MethodDeclarationSyntax
arrowMethod)
src\Analyzers\CSharp\CodeFixes\RemoveAsyncModifier\CSharpRemoveAsyncModifierCodeFixProvider.cs (2)
41
MethodDeclarationSyntax
method => method.WithBody(block).WithExpressionBody(null).WithSemicolonToken(default),
54
MethodDeclarationSyntax
method => RemoveAsyncModifierHelpers.WithoutAsyncModifier(method, method.ReturnType),
src\Analyzers\CSharp\CodeFixes\RemoveAsyncModifier\RemoveAsyncModifierHelpers.cs (1)
12
internal static SyntaxNode WithoutAsyncModifier(
MethodDeclarationSyntax
method, TypeSyntax returnType)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (2)
155
=> members.FirstOrDefault(m => m is
MethodDeclarationSyntax
);
164
=> members.LastOrDefault(m => m is
MethodDeclarationSyntax
);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (2)
796
var
methodDeclarationSyntax = (
MethodDeclarationSyntax
)syntaxNode;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpDeclarationComparer.cs (4)
118
return Compare((
MethodDeclarationSyntax
)x, (
MethodDeclarationSyntax
)y);
199
private int Compare(
MethodDeclarationSyntax
x,
MethodDeclarationSyntax
y)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (11)
37
var
declaration = GenerateMethodDeclaration(method, CodeGenerationDestination.Namespace, info, cancellationToken);
50
var
declaration = GenerateMethodDeclaration(
65
var
methodDeclaration = GenerateMethodDeclaration(
74
public static
MethodDeclarationSyntax
GenerateMethodDeclaration(
79
var
reusableSyntax = GetReuseableSyntaxNodeForSymbol<
MethodDeclarationSyntax
>(method, info);
85
var
declaration = GenerateMethodDeclarationWorker(
111
private static
MethodDeclarationSyntax
GenerateMethodDeclarationWorker(
126
var
methodDeclaration = MethodDeclaration(
183
private static
MethodDeclarationSyntax
UseExpressionBodyIfDesired(
184
CSharpCodeGenerationContextInfo info,
MethodDeclarationSyntax
methodDeclaration, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (2)
1130
MethodDeclarationSyntax
or LocalFunctionStatementSyntax or ConstructorDeclarationSyntax or DelegateDeclarationSyntax or TypeDeclarationSyntax => true,
1213
var method = tokenOnLeftOfPosition.Parent.GetAncestorOrThis<
MethodDeclarationSyntax
>();
Microsoft.CodeAnalysis.CSharp.EditorFeatures (1)
CompleteStatement\CompleteStatementCommandHandler.cs (1)
291
if (currentNode is
MethodDeclarationSyntax
method)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (21)
RefactoringHelpers\RefactoringHelpersTests.cs (19)
714
await TestMissingAsync<
MethodDeclarationSyntax
>(testText);
727
await TestAsync<
MethodDeclarationSyntax
>(testText);
740
await TestAsync<
MethodDeclarationSyntax
>(testText);
771
await TestMissingAsync<
MethodDeclarationSyntax
>(testText);
785
await TestAsync<
MethodDeclarationSyntax
>(testText);
804
await TestAsync<
MethodDeclarationSyntax
>(testText);
822
await TestAsync<
MethodDeclarationSyntax
>(testText);
842
await TestAsync<
MethodDeclarationSyntax
>(testText);
864
await TestAsync<
MethodDeclarationSyntax
>(testText);
884
await TestMissingAsync<
MethodDeclarationSyntax
>(testText);
902
await TestMissingAsync<
MethodDeclarationSyntax
>(testText);
922
await TestMissingAsync<
MethodDeclarationSyntax
>(testText);
940
await TestMissingAsync<
MethodDeclarationSyntax
>(testText);
962
await TestAsync<
MethodDeclarationSyntax
>(testText);
984
await TestAsync<
MethodDeclarationSyntax
>(testText);
1537
await TestMissingAsync<
MethodDeclarationSyntax
>(testText);
1551
await TestAsync<
MethodDeclarationSyntax
>(testText);
1565
await TestAsync<
MethodDeclarationSyntax
>(testText);
1579
await TestAsync<
MethodDeclarationSyntax
>(testText);
Structure\MetadataAsSource\MethodDeclarationStructureTests.cs (1)
14
public class MethodDeclarationStructureTests : AbstractCSharpSyntaxNodeStructureTests<
MethodDeclarationSyntax
>
Structure\MethodDeclarationStructureTests.cs (1)
16
public class MethodDeclarationStructureTests : AbstractCSharpSyntaxNodeStructureTests<
MethodDeclarationSyntax
>
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (3)
CodeGen\CodeGenOperators.cs (3)
5409
ControlFlowGraph.Create((IMethodBodyOperation)model.GetOperation(tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Calculate").Single()));
5699
ControlFlowGraph.Create((IMethodBodyOperation)model.GetOperation(tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Calculate").Single()));
5735
ControlFlowGraph.Create((IMethodBodyOperation)model.GetOperation(tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Calculate").Single()));
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (2)
Emit\NumericIntPtrTests.cs (2)
10686
var methods = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().ToArray();
10688
foreach (
var
method in methods)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (218)
Attributes\AttributeTests.cs (1)
710
var m0 = semanticModel.GetDeclaredSymbol(root.DescendantNodes().OfType<
MethodDeclarationSyntax
>().Last());
Attributes\AttributeTests_RefReadOnly.cs (8)
1379
var
userFunction = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(method => method.Identifier.Text == "User");
1421
var
userFunction = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(method => method.Identifier.Text == "User");
1450
var
userFunction = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(method => method.Identifier.Text == "User");
1477
var
userFunction = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(method => method.Identifier.Text == "User");
Diagnostics\GetDiagnosticsTests.cs (1)
1028
MethodDeclarationSyntax
methodDecl => methodDecl.Identifier.GetLocation(),
RefStructInterfacesTests.cs (118)
6629
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
6766
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test1").Single();
6882
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
7014
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
7143
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
7473
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
7663
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
7882
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test1").Single();
8076
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
8269
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
8442
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
8548
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
8932
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
9136
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
9332
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
9500
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
9715
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
9936
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
10151
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
10348
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
10443
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
10543
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
10740
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
10980
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test1").Single();
11199
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
11423
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
12149
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
12417
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test1").Single();
12662
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
12925
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
13192
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
13454
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
14152
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
14493
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
14855
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test1").Single();
15206
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
15554
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
15733
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
15988
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
16759
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
16824
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
16889
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
16973
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
17061
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
17154
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
17251
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
17335
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
17656
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
17853
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
18076
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test1").Single();
18276
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
18477
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
18653
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
18761
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
19129
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
19300
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
19473
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
19625
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Main").Single();
19967
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test").Single();
Semantics\CollectionExpressionTests.cs (41)
7534
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
8257
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
8328
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
8412
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
8497
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
26013
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
26139
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
26253
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
26311
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
26382
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
26464
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
26530
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
26591
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
26661
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
26836
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
26901
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "CreateCollection");
26957
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
27274
var method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
27352
var method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
27439
var method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
27523
var method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
27616
var method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
27701
var method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
27769
var method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.Text == "Create");
Semantics\OutVarTests.cs (18)
1287
MethodDeclarationSyntax
methodDeclParent;
1290
((methodDeclParent = containingReturnOrThrow.Parent.Parent as
MethodDeclarationSyntax
) == null ||
34329
var
method = syntaxTree.GetCompilationUnitRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().ElementAt(i + 2);
34543
var
method = syntaxTree.GetCompilationUnitRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().ElementAt(i + 2);
36363
var
method = tree2.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
36409
var
method = tree2.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
36449
var
method = tree2.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
36491
var
method = tree2.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
36526
var
method = tree2.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
36564
var
method = tree2.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
Semantics\ParamsCollectionTests.cs (10)
3596
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test1").Single();
3886
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(m => m.Identifier.ValueText == "Test1").Single();
14555
VerifyFlowGraphForTest<
MethodDeclarationSyntax
>(comp, """
14585
VerifyOperationTreeForTest<
MethodDeclarationSyntax
>(comp, """
14646
VerifyFlowGraphForTest<
MethodDeclarationSyntax
>(comp, """
14676
VerifyOperationTreeForTest<
MethodDeclarationSyntax
>(comp, """
14763
VerifyFlowGraphForTest<
MethodDeclarationSyntax
>(comp, """
14803
VerifyOperationTreeForTest<
MethodDeclarationSyntax
>(comp, """
Semantics\PrimaryConstructorTests.cs (8)
4863
case
MethodDeclarationSyntax
{ Identifier: { ValueText: "M" } }:
5008
case
MethodDeclarationSyntax
{ Identifier: { ValueText: "M" } }:
5076
case
MethodDeclarationSyntax
{ Identifier: { ValueText: "M" } }:
5860
case
MethodDeclarationSyntax
{ Identifier: { ValueText: "M" } }:
5952
case
MethodDeclarationSyntax
{ Identifier: { ValueText: "M" } }:
6010
case
MethodDeclarationSyntax
{ Identifier: { ValueText: "M" } }:
6861
var
mDefinition = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
Semantics\RecordTests.cs (13)
1816
var
main = root.DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
8130
var
main = root.DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
8630
var
main = root.DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
8735
var
main = root.DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
27370
case
MethodDeclarationSyntax
{ Identifier: { ValueText: "M" } }:
27515
case
MethodDeclarationSyntax
{ Identifier: { ValueText: "M" } }:
27583
case
MethodDeclarationSyntax
{ Identifier: { ValueText: "M" } }:
30442
var
mDefinition = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
Microsoft.CodeAnalysis.CSharp.EndToEnd.UnitTests (2)
EndToEndTests.cs (2)
493
var
node = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
Microsoft.CodeAnalysis.CSharp.Features (129)
AddDebuggerDisplay\CSharpAddDebuggerDisplayCodeRefactoringProvider.cs (1)
20
: AbstractAddDebuggerDisplayCodeRefactoringProvider<TypeDeclarationSyntax,
MethodDeclarationSyntax
>
ChangeSignature\CSharpChangeSignatureService.cs (1)
320
if (updatedNode is
MethodDeclarationSyntax
method)
CodeLens\CSharpCodeLensMemberFinder.cs (1)
66
public override void VisitMethodDeclaration(
MethodDeclarationSyntax
node)
CodeRefactorings\AddAwait\CSharpAddAwaitCodeRefactoringProvider.cs (1)
38
case
MethodDeclarationSyntax
methodDeclaration:
CodeRefactorings\ConvertLocalFunctionToMethod\CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs (3)
130
var
method = MethodGenerator.GenerateMethodDeclaration(methodSymbol, CodeGenerationDestination.Unspecified, info, cancellationToken);
274
private static
MethodDeclarationSyntax
WithBodyFrom(
275
MethodDeclarationSyntax
method, LocalFunctionStatementSyntax localFunction)
Completion\CompletionProviders\AwaitCompletionProvider.cs (2)
44
MethodDeclarationSyntax
method => method.ReturnType.SpanStart,
60
MethodDeclarationSyntax
method => method.ReturnType,
Completion\CompletionProviders\DeclarationName\DeclarationNameInfo.cs (1)
207
result = IsLastTokenOfType<
MethodDeclarationSyntax
>(
Completion\CompletionProviders\DeclarationName\DeclarationNameRecommender.cs (1)
321
MethodDeclarationSyntax
method => [.. namedType.GetMembers(method.Identifier.ValueText).OfType<IMethodSymbol>()],
Completion\CompletionProviders\OverrideCompletionProvider.cs (1)
35
?? (SyntaxNode?)token.GetAncestor<
MethodDeclarationSyntax
>()
Completion\CompletionProviders\PartialMethodCompletionProvider.cs (6)
38
var
declaration = (
MethodDeclarationSyntax
)method.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken);
60
?? (SyntaxNode?)token.GetAncestor<
MethodDeclarationSyntax
>()
66
var
methodDeclaration = (
MethodDeclarationSyntax
)caretTarget;
84
var declarations = method.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).OfType<
MethodDeclarationSyntax
>();
Completion\KeywordRecommenders\TypeVarKeywordRecommender.cs (1)
40
var method = typeParameters.GetAncestorOrThis<
MethodDeclarationSyntax
>();
Completion\KeywordRecommenders\WhereKeywordRecommender.cs (1)
74
if (tokenParent.IsParentKind<
MethodDeclarationSyntax
>(SyntaxKind.MethodDeclaration, out var methodDeclaration))
ConvertProgram\ConvertProgramTransform_ProgramMain.cs (3)
87
var
method = (
MethodDeclarationSyntax
)generator.MethodDeclaration(
91
method = (
MethodDeclarationSyntax
)generator.WithAccessibility(
ConvertProgram\ConvertProgramTransform_TopLevelStatements.cs (4)
30
Document document,
MethodDeclarationSyntax
methodDeclaration, CancellationToken cancellationToken)
102
MethodDeclarationSyntax
methodDeclaration,
156
MethodDeclarationSyntax
methodDeclaration,
193
else if (member is
MethodDeclarationSyntax
otherMethod)
ConvertProgram\ConvertToTopLevelStatementsCodeFixProvider.cs (2)
51
var
methodDeclaration = (
MethodDeclarationSyntax
)diagnostics[0].AdditionalLocations[0].FindNode(cancellationToken);
ConvertProgram\ConvertToTopLevelStatementsCodeRefactoringProvider.cs (1)
42
var methodDeclaration = await context.TryGetRelevantNodeAsync<
MethodDeclarationSyntax
>().ConfigureAwait(false);
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (2)
1682
var
methodDeclaration = (
MethodDeclarationSyntax
)node;
EditAndContinue\SyntaxComparer.cs (1)
1447
return ((
MethodDeclarationSyntax
)node).Identifier;
EditAndContinue\SyntaxUtilities.cs (2)
24
MethodDeclarationSyntax
methodDeclaration => CreateSimpleBody(BlockOrExpression(methodDeclaration.Body, methodDeclaration.ExpressionBody)),
223
MethodDeclarationSyntax
method => method.Modifiers.Any(SyntaxKind.AsyncKeyword),
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (5)
1013
MethodDeclarationSyntax
method => TweakNewLinesInMethod(method),
1024
private static
MethodDeclarationSyntax
TweakNewLinesInMethod(
MethodDeclarationSyntax
method)
1062
var nodeIsMethodOrLocalFunction = syntaxNode is
MethodDeclarationSyntax
or LocalFunctionStatementSyntax;
1070
var returnType = syntaxNode is
MethodDeclarationSyntax
method ? method.ReturnType : ((LocalFunctionStatementSyntax)syntaxNode).ReturnType;
ExtractMethod\CSharpMethodExtractor.TriviaResult.cs (3)
27
var isMethodOrLocalFunction = method is
MethodDeclarationSyntax
or LocalFunctionStatementSyntax;
38
var isMethodOrLocalFunction = method is
MethodDeclarationSyntax
or LocalFunctionStatementSyntax;
127
MethodDeclarationSyntax
methodDeclaration => (methodDeclaration.Body, methodDeclaration.ExpressionBody, methodDeclaration.SemicolonToken),
ExtractMethod\CSharpSelectionResult.StatementResult.cs (1)
32
MethodDeclarationSyntax
method => method.Modifiers.Any(SyntaxKind.AsyncKeyword),
Highlighting\KeywordHighlighters\AsyncAwaitHighlighter.cs (1)
72
MethodDeclarationSyntax
methodDeclaration => TryAddAsyncModifier(methodDeclaration.Modifiers, spans),
ImplementInterface\AbstractChangeImplementationCodeRefactoringProvider.cs (1)
160
MethodDeclarationSyntax
member => (member, member.ExplicitInterfaceSpecifier, member.Identifier),
ImplementInterface\CSharpImplementImplicitlyCodeRefactoringProvider.cs (1)
54
MethodDeclarationSyntax
member => member.WithExplicitInterfaceSpecifier(null),
InheritanceMargin\CSharpInheritanceMarginService.cs (1)
68
MethodDeclarationSyntax
methodDeclarationNode => methodDeclarationNode.Identifier,
LineSeparators\CSharpLineSeparatorService.cs (1)
129
if (node is
MethodDeclarationSyntax
methodDecl)
Organizing\Organizers\MethodDeclarationOrganizer.cs (3)
17
internal class MethodDeclarationOrganizer : AbstractSyntaxNodeOrganizer<
MethodDeclarationSyntax
>
25
protected override
MethodDeclarationSyntax
Organize(
26
MethodDeclarationSyntax
syntax,
ReplaceMethodWithProperty\CSharpReplaceMethodWithPropertyService.cs (9)
28
internal class CSharpReplaceMethodWithPropertyService : AbstractReplaceMethodWithPropertyService<
MethodDeclarationSyntax
>, IReplaceMethodWithPropertyService
48
if (getAndSetMethods.GetMethodDeclaration is not
MethodDeclarationSyntax
getMethodDeclaration)
120
var
getMethodDeclaration = (
MethodDeclarationSyntax
)getAndSetMethods.GetMethodDeclaration;
121
var
setMethodDeclaration = getAndSetMethods.SetMethodDeclaration as
MethodDeclarationSyntax
;
211
var
getMethodDeclaration = getAndSetMethods.GetMethodDeclaration as
MethodDeclarationSyntax
;
246
if (getAndSetMethods.SetMethodDeclaration is not
MethodDeclarationSyntax
setMethodDeclaration || setMethod?.Parameters.Length != 1)
ReplacePropertyWithMethods\CSharpReplacePropertyWithMethodsService.cs (12)
114
var
methodDeclaration = GetSetMethodWorker();
123
MethodDeclarationSyntax
GetSetMethodWorker()
126
var
methodDeclaration = (
MethodDeclarationSyntax
)generator.MethodDeclaration(setMethod, desiredSetMethodName);
171
var
methodDeclaration = GetGetMethodWorker();
179
MethodDeclarationSyntax
GetGetMethodWorker()
181
var
methodDeclaration = (
MethodDeclarationSyntax
)generator.MethodDeclaration(getMethod, desiredGetMethodName);
226
private static
MethodDeclarationSyntax
CopyLeadingTrivia(
228
MethodDeclarationSyntax
methodDeclaration,
250
private static
MethodDeclarationSyntax
UseExpressionOrBlockBodyIfDesired(
252
MethodDeclarationSyntax
methodDeclaration,
Snippets\AbstractCSharpMainMethodSnippetProvider.cs (1)
16
: AbstractMainMethodSnippetProvider<
MethodDeclarationSyntax
, StatementSyntax, TypeSyntax>
Snippets\CSharpIntMainSnippetProvider.cs (2)
39
protected override int GetTargetCaretPosition(
MethodDeclarationSyntax
methodDeclaration, SourceText sourceText)
50
protected override async Task<Document> AddIndentationToDocumentAsync(Document document,
MethodDeclarationSyntax
methodDeclaration, CancellationToken cancellationToken)
Snippets\CSharpVoidMainSnippetProvider.cs (2)
36
protected override int GetTargetCaretPosition(
MethodDeclarationSyntax
methodDeclaration, SourceText sourceText)
42
protected override Task<Document> AddIndentationToDocumentAsync(Document document,
MethodDeclarationSyntax
methodDeclaration, CancellationToken cancellationToken)
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_TopLevelStatements.cs (4)
30
public static Location GetUseTopLevelStatementsDiagnosticLocation(
MethodDeclarationSyntax
methodDeclaration, bool isHidden)
46
MethodDeclarationSyntax
methodDeclaration,
138
if (member is not FieldDeclarationSyntax and not
MethodDeclarationSyntax
)
142
if (member is
MethodDeclarationSyntax
{ Body: null, ExpressionBody: null })
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertToTopLevelStatementsDiagnosticAnalyzer.cs (2)
66
var methodDeclarations = root.DescendantNodes(n => n is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax or ClassDeclarationSyntax).OfType<
MethodDeclarationSyntax
>();
67
foreach (
var
methodDeclaration in methodDeclarations)
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (1)
200
MethodDeclarationSyntax
methodDeclaration => methodDeclaration.Identifier,
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyForMethodsHelper.cs (11)
18
UseExpressionBodyHelper<
MethodDeclarationSyntax
>
35
protected override BlockSyntax GetBody(
MethodDeclarationSyntax
declaration)
38
protected override ArrowExpressionClauseSyntax GetExpressionBody(
MethodDeclarationSyntax
declaration)
41
protected override SyntaxToken GetSemicolonToken(
MethodDeclarationSyntax
declaration)
44
protected override
MethodDeclarationSyntax
WithSemicolonToken(
MethodDeclarationSyntax
declaration, SyntaxToken token)
47
protected override
MethodDeclarationSyntax
WithExpressionBody(
MethodDeclarationSyntax
declaration, ArrowExpressionClauseSyntax expressionBody)
50
protected override
MethodDeclarationSyntax
WithBody(
MethodDeclarationSyntax
declaration, BlockSyntax body)
54
SemanticModel semanticModel,
MethodDeclarationSyntax
declaration)
src\Analyzers\CSharp\Analyzers\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (1)
106
MethodDeclarationSyntax
method => method.ReturnType,
src\Analyzers\CSharp\CodeFixes\ConvertToAsync\CSharpConvertToAsyncMethodCodeFixProvider.cs (4)
60
private static async Task<
MethodDeclarationSyntax
?> GetMethodDeclarationAsync(
82
if ((await methodReference.GetSyntaxAsync(cancellationToken).ConfigureAwait(false)) is not
MethodDeclarationSyntax
methodDeclaration)
95
private static
MethodDeclarationSyntax
ConvertToAsyncFunction(
MethodDeclarationSyntax
methodDeclaration)
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (2)
219
foreach (
var
method in typeDeclaration.Members.OfType<
MethodDeclarationSyntax
>())
src\Analyzers\CSharp\CodeFixes\FixReturnType\CSharpFixReturnTypeCodeFixProvider.cs (1)
145
MethodDeclarationSyntax
method => (method.ReturnType, method.Modifiers.Any(SyntaxKind.AsyncKeyword)),
src\Analyzers\CSharp\CodeFixes\GenerateParameterizedMember\CSharpGenerateMethodService.cs (3)
30
=> node is
MethodDeclarationSyntax
;
55
var
methodDeclaration = (
MethodDeclarationSyntax
)node;
src\Analyzers\CSharp\CodeFixes\HideBase\HideBaseCodeFixProvider.cs (1)
38
token.GetAncestor<
MethodDeclarationSyntax
>() ??
src\Analyzers\CSharp\CodeFixes\Iterator\CSharpChangeToIEnumerableCodeFixProvider.cs (1)
75
var newMethodDeclarationSyntax = (node as
MethodDeclarationSyntax
)?.WithReturnType(newReturnType);
src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (3)
79
MethodDeclarationSyntax
method => FixMethod(keepVoid, methodSymbol, method, knownTypes, cancellationToken),
86
private static
MethodDeclarationSyntax
FixMethod(
89
MethodDeclarationSyntax
method,
src\Analyzers\CSharp\CodeFixes\MakeMethodSynchronous\CSharpMakeMethodSynchronousCodeFixProvider.cs (2)
36
case
MethodDeclarationSyntax
method: return FixMethod(methodSymbol, method, knownTypes);
44
private static SyntaxNode FixMethod(IMethodSymbol methodSymbol,
MethodDeclarationSyntax
method, KnownTaskTypes knownTypes)
src\Analyzers\CSharp\CodeFixes\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyCodeFixProvider.cs (1)
47
if (declaration is
MethodDeclarationSyntax
or BasePropertyDeclarationSyntax)
src\Analyzers\CSharp\CodeFixes\MakeTypeAbstract\CSharpMakeTypeAbstractCodeFixProvider.cs (1)
26
case
MethodDeclarationSyntax
method:
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (2)
140
MethodDeclarationSyntax
method =>
262
node.Parent?.Parent is
MethodDeclarationSyntax
arrowMethod)
src\Analyzers\CSharp\CodeFixes\RemoveAsyncModifier\CSharpRemoveAsyncModifierCodeFixProvider.cs (2)
41
MethodDeclarationSyntax
method => method.WithBody(block).WithExpressionBody(null).WithSemicolonToken(default),
54
MethodDeclarationSyntax
method => RemoveAsyncModifierHelpers.WithoutAsyncModifier(method, method.ReturnType),
src\Analyzers\CSharp\CodeFixes\RemoveAsyncModifier\RemoveAsyncModifierHelpers.cs (1)
12
internal static SyntaxNode WithoutAsyncModifier(
MethodDeclarationSyntax
method, TypeSyntax returnType)
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (2)
295
if (node is
MethodDeclarationSyntax
methodDecl && methodDecl.TypeParameterList != null)
389
arrowExpr = ((
MethodDeclarationSyntax
)node).ExpressionBody;
Structure\CSharpBlockStructureProvider.cs (1)
41
builder.Add<
MethodDeclarationSyntax
, MethodDeclarationStructureProvider>();
Structure\CSharpStructureHelpers.cs (1)
280
MethodDeclarationSyntax
methodDeclaration => methodDeclaration.Modifiers.FirstOrNull() ?? methodDeclaration.ReturnType.GetFirstToken(),
Structure\Providers\MethodDeclarationStructureProvider.cs (2)
12
internal class MethodDeclarationStructureProvider : AbstractSyntaxNodeStructureProvider<
MethodDeclarationSyntax
>
16
MethodDeclarationSyntax
methodDeclaration,
Testing\CSharpTestMethodFinder.cs (2)
19
internal class CSharpTestMethodFinder([ImportMany] IEnumerable<ITestFrameworkMetadata> testFrameworks) : AbstractTestMethodFinder<
MethodDeclarationSyntax
>(testFrameworks)
27
protected override bool IsTestMethod(
MethodDeclarationSyntax
method)
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (30)
Diagnostics\Suppression\SuppressionTests.cs (4)
1085
var
method = (
MethodDeclarationSyntax
)context.Node;
2079
var
method = (
MethodDeclarationSyntax
)context.Node;
EditAndContinue\ActiveStatementTests.cs (1)
12557
if (node.Parent is
MethodDeclarationSyntax
methodDecl && methodDecl.Identifier.Text == "G")
EditAndContinue\BreakpointSpansTests.cs (8)
111
VerifyAllSpansInDeclaration<
MethodDeclarationSyntax
>(@"
145
VerifyAllSpansInDeclaration<
MethodDeclarationSyntax
>(@"
171
VerifyAllSpansInDeclaration<
MethodDeclarationSyntax
>(@"
200
VerifyAllSpansInDeclaration<
MethodDeclarationSyntax
>(@"
224
VerifyAllSpansInDeclaration<
MethodDeclarationSyntax
>(@"
235
VerifyAllSpansInDeclaration<
MethodDeclarationSyntax
>(@"
272
VerifyAllSpansInDeclaration<
MethodDeclarationSyntax
>(@"
284
VerifyAllSpansInDeclaration<
MethodDeclarationSyntax
>(@"
EditAndContinue\Helpers\EditingTestBase.cs (4)
242
var
oldDeclaration = (
MethodDeclarationSyntax
)((ClassDeclarationSyntax)((CompilationUnitSyntax)edits.Match.OldRoot).Members[0]).Members[0];
246
var
newDeclaration = (
MethodDeclarationSyntax
)((ClassDeclarationSyntax)((CompilationUnitSyntax)edits.Match.NewRoot).Members[0]).Members[0];
EditAndContinue\SyntaxUtilitiesTests.cs (12)
184
var
m0 = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.ValueText == "M0");
185
var
m1 = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.ValueText == "M1");
186
var
m2 = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.ValueText == "M2");
187
var
m3 = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.ValueText == "M3");
253
var
m1 = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.ValueText == "M1");
254
var
m2 = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.ValueText == "M2");
Testing\CSharpTestMethodFinderTests.cs (1)
559
var testMethodNames = testMethods.Cast<
MethodDeclarationSyntax
>().Select(m => m.Identifier.Text).ToArray();
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (54)
IOperation\IOperationTests.cs (4)
589
var
methodDeclSyntax = literal.Ancestors().OfType<
MethodDeclarationSyntax
>().Single();
617
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
IOperation\IOperationTests_IAnonymousFunctionExpression.cs (2)
847
var graphM = ControlFlowGraph.Create((IMethodBodyOperation)semanticModel.GetOperation(tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single()));
902
var graphM = ControlFlowGraph.Create((IMethodBodyOperation)semanticModel.GetOperation(tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single()));
IOperation\IOperationTests_ICoalesceAssignmentOperation.cs (2)
253
var
m = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
IOperation\IOperationTests_IDynamicObjectCreationExpression.cs (3)
421
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
540
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
665
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
IOperation\IOperationTests_IFieldReferenceExpression.cs (2)
711
var
methodDecl = root.DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
IOperation\IOperationTests_ILocalFunctionStatement.cs (2)
1793
var graphM = ControlFlowGraph.Create((IMethodBodyOperation)semanticModel.GetOperation(tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First()));
1848
var graphM = ControlFlowGraph.Create((IMethodBodyOperation)semanticModel.GetOperation(tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First()));
IOperation\IOperationTests_INoPiaObjectCreationOperation.cs (4)
272
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(consumer, expectedFlowGraph, expectedDiagnostics, references: new[] { piaCompilation.EmitToImageReference(embedInteropTypes: true) });
363
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(consumer, expectedFlowGraph, expectedDiagnostics, references: new[] { piaCompilation.EmitToImageReference(embedInteropTypes: true) });
429
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(consumer, expectedFlowGraph, expectedDiagnostics, references: new[] { piaCompilation.EmitToImageReference(embedInteropTypes: true) });
573
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(consumer, expectedFlowGraph, expectedDiagnostics, references: new[] { piaCompilation.EmitToImageReference(embedInteropTypes: true) });
IOperation\IOperationTests_IObjectCreationExpression.cs (31)
782
var
m1 = comp.SyntaxTrees[0].GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
1069
var
main = comp.SyntaxTrees[0].GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
1295
var
m1 = comp.SyntaxTrees[0].GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
1574
var
main = comp.SyntaxTrees[0].GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
2276
var
m = comp.SyntaxTrees[0].GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
2400
var
m = comp.SyntaxTrees[0].GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(m => m.Identifier.ValueText == "M");
11672
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
11838
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
12082
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
12388
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
12685
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
12995
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
13269
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
13355
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
13480
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
13649
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics, useLatestFrameworkReferences: true);
13825
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics, useLatestFrameworkReferences: true);
13901
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
13974
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
14110
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
14235
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
14309
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
14456
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
14581
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
14666
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
IOperation\IOperationTests_ITypeParameterObjectCreationTests.cs (4)
274
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
390
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
468
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
549
VerifyFlowGraphAndDiagnosticsForTest<
MethodDeclarationSyntax
>(source, expectedFlowGraph, expectedDiagnostics);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (88)
Semantics\ArglistTests.cs (2)
961
var
meth = clss.Members[0] as
MethodDeclarationSyntax
;
Semantics\ConditionalOperatorTests.cs (2)
1290
var
methodTest = (
MethodDeclarationSyntax
)classC.Members.First();
Semantics\ExpressionBodiedMemberTests.cs (2)
41
var
node = tree.GetRoot()
43
.OfType<
MethodDeclarationSyntax
>()
Semantics\FunctionPointerTests.cs (3)
3678
.OfType<
MethodDeclarationSyntax
>()
3816
.OfType<
MethodDeclarationSyntax
>()
3950
.OfType<
MethodDeclarationSyntax
>()
Semantics\LambdaTests.cs (9)
3986
var
m = newTree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
7646
var
methodSyntax = (
MethodDeclarationSyntax
)method.DeclaringSyntaxReferences.Single().GetSyntax();
8083
var
m2Syntax = (
MethodDeclarationSyntax
)m2.DeclaringSyntaxReferences.Single().GetSyntax();
8085
var
newMethod = m2Syntax.WithBody(SyntaxFactory.Block(newStmt));
8163
var
methodSyntax = (
MethodDeclarationSyntax
)comp.GetMember<MethodSymbol>("C.M").GetNonNullSyntaxNode();
Semantics\LocalFunctionTests.cs (8)
348
var
m = newTree.GetRoot()
349
.DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
404
var
m = newTree.GetRoot()
405
.DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
444
var
mMethod = (
MethodDeclarationSyntax
)newTree.FindNodeOrTokenByKind(SyntaxKind.MethodDeclaration, occurrence: 1).AsNode();
8739
var
method = tree2.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
Semantics\NativeIntegerTests.cs (1)
3639
var method = model.GetDeclaredSymbol(nodes.OfType<
MethodDeclarationSyntax
>().Single());
Semantics\NullableContextTests.cs (4)
68
var methodDeclPosition = syntaxTree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single().SpanStart;
581
verifyContextState(tree, syntaxNodes.OfType<
MethodDeclarationSyntax
>().Single(), expectedWarningsStateForMethod, expectedAnnotationsStateForMethod);
731
var methodDeclarations = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().ToArray();
732
foreach (
var
methodDeclaration in methodDeclarations)
Semantics\NullableReferenceTypesTests.cs (1)
157629
var method1 = model.GetDeclaredSymbol(tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single());
Semantics\ObjectAndCollectionInitializerTests.cs (4)
4058
var
node1 = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
4136
var
node1 = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
Semantics\OperatorTests.cs (3)
7330
var methodBody = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Last().Body;
8812
var
methodDecl = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
Semantics\QueryTests.cs (16)
1454
dynamic methodM = (
MethodDeclarationSyntax
)classC.Members[0];
1663
dynamic methodM = (
MethodDeclarationSyntax
)classC.Members[0];
1723
dynamic methodM = (
MethodDeclarationSyntax
)classC.Members[0];
1761
dynamic methodM = (
MethodDeclarationSyntax
)classC.Members[0];
2898
dynamic main = (
MethodDeclarationSyntax
)classC.Members[0];
2931
dynamic main = (
MethodDeclarationSyntax
)classC.Members[0];
3421
var
methodM = (
MethodDeclarationSyntax
)classC.Members[0];
3465
var
methodM = (
MethodDeclarationSyntax
)classC.Members[0];
3512
var
methodM = (
MethodDeclarationSyntax
)classC.Members[0];
3551
var
methodM = (
MethodDeclarationSyntax
)classC.Members[0];
3599
var
methodM = (
MethodDeclarationSyntax
)classC.Members[0];
Semantics\ReadOnlyStructsTests.cs (2)
1265
var
testMethodSyntax = (
MethodDeclarationSyntax
)c.DeclaringSyntaxReferences.Single().GetSyntax();
Semantics\RecordStructTests.cs (9)
554
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
574
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
596
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
6585
case
MethodDeclarationSyntax
{ Identifier: { ValueText: "M" } }:
6677
case
MethodDeclarationSyntax
{ Identifier: { ValueText: "M" } }:
6735
case
MethodDeclarationSyntax
{ Identifier: { ValueText: "M" } }:
Semantics\SemanticErrorTests.cs (2)
3328
var
mainMethod = (
MethodDeclarationSyntax
)classError.Members[1];
Semantics\TargetTypedConditionalOperatorTests.cs (2)
338
var
methodTest = (
MethodDeclarationSyntax
)classC.Members.First();
Semantics\UnsafeTests.cs (2)
5197
var
methodDecl = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
SourceGeneration\GeneratorDriverTests_Attributes_FullyQualifiedName.cs (14)
463
var input = ctx.ForAttributeWithMetadataName<
MethodDeclarationSyntax
>("System.CLSCompliantAttribute");
472
step => Assert.True(step.Outputs.Single().Value is
MethodDeclarationSyntax
{ Identifier.ValueText: "M" }));
496
var input = ctx.ForAttributeWithMetadataName<
MethodDeclarationSyntax
>("System.CLSCompliantAttribute");
505
step => Assert.True(step.Outputs.Single().Value is
MethodDeclarationSyntax
{ Identifier.ValueText: "M" }));
528
var input = ctx.ForAttributeWithMetadataName<
MethodDeclarationSyntax
>("System.CLSCompliantAttribute");
537
step => Assert.True(step.Outputs.Single().Value is
MethodDeclarationSyntax
{ Identifier.ValueText: "M", Body: null, ExpressionBody: null }));
560
var input = ctx.ForAttributeWithMetadataName<
MethodDeclarationSyntax
>("System.CLSCompliantAttribute");
569
step => Assert.True(step.Outputs.Single().Value is
MethodDeclarationSyntax
{ Identifier.ValueText: "M", Body: not null }));
1336
var input = ctx.ForAttributeWithMetadataName<
MethodDeclarationSyntax
>("System.Runtime.InteropServices.LibraryImportAttribute");
1346
{ Value:
MethodDeclarationSyntax
{ Identifier.ValueText: "SomeFunction" } },
1347
{ Value:
MethodDeclarationSyntax
{ Identifier.ValueText: "SomeFunction2" } }]));
1382
var input = ctx.ForAttributeWithMetadataName<
MethodDeclarationSyntax
>("System.Runtime.InteropServices.LibraryImportAttribute");
1392
{ Value:
MethodDeclarationSyntax
{ Identifier.ValueText: "SomeFunction" } },
1393
{ Value:
MethodDeclarationSyntax
{ Identifier.ValueText: "SomeFunction2" } }]));
SourceGeneration\SyntaxAwareGeneratorTests.cs (2)
475
Assert.DoesNotContain(receiver1.VisitedNodes, n => n is
MethodDeclarationSyntax
);
476
Assert.Contains(receiver2.VisitedNodes, n => n is
MethodDeclarationSyntax
);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (196)
Compilation\GetSemanticInfoTests.cs (14)
244
var
mainMethod = testClass.Members[1] as
MethodDeclarationSyntax
;
297
var
main = (
MethodDeclarationSyntax
)c.Members[1];
376
var
mainMethod = testClass.Members[1] as
MethodDeclarationSyntax
;
479
var
mainMethod = testClass.Members[1] as
MethodDeclarationSyntax
;
532
var
mainMethod = testClass.Members[0] as
MethodDeclarationSyntax
;
973
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
997
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
Compilation\SemanticModelAPITests.cs (56)
43
var
m = root.DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single(decl => decl.Identifier.ValueText == "M");
44
var
m2 = m.WithoutTrailingTrivia();
702
var
method = decl.Members[0] as
MethodDeclarationSyntax
;
880
var
pMethod01 = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
881
var
pMethod02 = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Last();
1500
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
1549
var
methodDecl = (
MethodDeclarationSyntax
)interfaceDecl.Members[0];
1646
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
1777
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
1828
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
1878
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
1917
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
1954
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
1991
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
2172
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[2];
2217
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[2];
2257
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
2349
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
2352
var
speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement);
2562
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
2567
var
speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement);
2634
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
2638
var
speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement);
2671
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
2675
var
speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement);
2762
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
2774
var
speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement);
2863
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[1];
3087
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
3873
var
methodDecl = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
3910
var
method = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (88)
278
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
566
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
588
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
821
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
857
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
901
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
973
var
memDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
980
memDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
1083
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[2];
1173
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[2];
1223
var
methodM = (
MethodDeclarationSyntax
)typeDeclC.Members[1];
1332
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
1435
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
1488
var
methodDecl = (
MethodDeclarationSyntax
)classDecl.Members[0];
1496
methodDecl = (
MethodDeclarationSyntax
)structDecl.Members[0];
1537
var
methodDecl = (
MethodDeclarationSyntax
)interfaceDecl.Members[0];
1549
methodDecl = (
MethodDeclarationSyntax
)interfaceDecl.Members[0];
1712
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
1815
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
1871
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
2008
var
methodDecl = (
MethodDeclarationSyntax
)typeDecl.Members[0];
2052
var
methodM = (
MethodDeclarationSyntax
)typeDeclA.Members[0];
2250
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
2286
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
2323
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
2359
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
2395
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
2425
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
2457
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
2494
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
2531
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
2562
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[1];
2591
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[1];
2616
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
2641
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
2671
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
2699
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
2849
var
explicitMethodNode = (
MethodDeclarationSyntax
)classMemberNodes[0];
2975
var dsyma1 = model.GetDeclaredSymbol(node1.Members[0] as
MethodDeclarationSyntax
);
2994
var dsymc1 = model.GetDeclaredSymbol(node3.Members[0] as
MethodDeclarationSyntax
);
2995
var dsymc2 = model.GetDeclaredSymbol(node3.Members[1] as
MethodDeclarationSyntax
);
2996
var dsymc3 = model.GetDeclaredSymbol(node3.Members[2] as
MethodDeclarationSyntax
);
3211
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[2]).Members[0];
3234
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
3265
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
3668
dynamic methodDecl = (
MethodDeclarationSyntax
)tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf("Main", StringComparison.Ordinal)).Parent;
3709
var
methodDecl = (
MethodDeclarationSyntax
)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
5175
var
methodDeclM = (
MethodDeclarationSyntax
)typeDeclC.Members.Single();
SymbolDisplay\SymbolDisplayTests.cs (3)
6062
var
methodDecl = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
6072
methodDecl = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
Symbols\AccessorOverriddenOrHiddenMembersTests.cs (2)
1042
var
explicitInterfaceImplementation = nodes.OfType<
MethodDeclarationSyntax
>().Single(d => d.ExplicitInterfaceSpecifier != null);
Symbols\AnonymousTypesSymbolTests.cs (2)
1683
var
mainSyntax = mainMethod.DeclaringSyntaxReferences.Single().GetSyntax() as
MethodDeclarationSyntax
;
Symbols\FunctionPointerTypeSymbolTests.cs (12)
53
.OfType<
MethodDeclarationSyntax
>()
125
.OfType<
MethodDeclarationSyntax
>()
205
.OfType<
MethodDeclarationSyntax
>()
406
.OfType<
MethodDeclarationSyntax
>()
486
.OfType<
MethodDeclarationSyntax
>()
603
.OfType<
MethodDeclarationSyntax
>()
686
.OfType<
MethodDeclarationSyntax
>()
1685
var
mDeclSyntax = syntaxTree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Skip(2).Single();
1796
var methodDecls = syntaxTree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().ToArray();
1819
var
m2DeclSyntax = methodDecls[1];
1865
var
m3DeclSyntax = methodDecls[2];
Symbols\ImplicitClassTests.cs (2)
117
var
methodDecl = tree.GetCompilationUnitRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
Symbols\MethodEqualityTests.cs (2)
210
var
mDecl = (
MethodDeclarationSyntax
)cDecl.Members[0];
Symbols\Source\FileModifierTests.cs (4)
3641
var body = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Last().Body!;
3711
var body = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Last().Body!;
3773
var body = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Last().Body!;
3814
var body = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Last().Body!;
Symbols\Source\MethodTests.cs (2)
2540
var methods = syntax.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().ToArray();
2572
var methods = syntax.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().ToArray();
Symbols\Source\NullablePublicAPITests.cs (6)
3507
var
mDeclaration = root.DescendantNodes().OfType<
MethodDeclarationSyntax
>().First(m => m.Identifier.ValueText == "M");
4513
var
methodDeclaration = (
MethodDeclarationSyntax
)SyntaxFactory.ParseMemberDeclaration(@"
4545
var
methodDeclaration = (
MethodDeclarationSyntax
)SyntaxFactory.ParseMemberDeclaration(@"
Symbols\Source\UpdatedContainingSymbolAndNullableAnntotationTests.cs (1)
41
Symbol m2 = model.GetDeclaredSymbol(root.DescendantNodes().OfType<
MethodDeclarationSyntax
>().ElementAt(1)).GetSymbol();
Symbols\TypeTests.cs (2)
1679
var
mnode = (
MethodDeclarationSyntax
)tree.FindNodeOrTokenByKind(SyntaxKind.MethodDeclaration);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (321)
Generated\Syntax.Test.xml.Generated.cs (5)
10778
private static
MethodDeclarationSyntax
GenerateMethodDeclaration()
13261
var
node = GenerateMethodDeclaration();
13274
var
newNode = node.WithAttributeLists(node.AttributeLists).WithModifiers(node.Modifiers).WithReturnType(node.ReturnType).WithExplicitInterfaceSpecifier(node.ExplicitInterfaceSpecifier).WithIdentifier(node.Identifier).WithTypeParameterList(node.TypeParameterList).WithParameterList(node.ParameterList).WithConstraintClauses(node.ConstraintClauses).WithBody(node.Body).WithExpressionBody(node.ExpressionBody).WithSemicolonToken(node.SemicolonToken);
18857
var
oldNode = GenerateMethodDeclaration();
18873
var
oldNode = GenerateMethodDeclaration();
IncrementalParsing\BinaryExpression.cs (4)
32
var
method = type.Members[0] as
MethodDeclarationSyntax
;
208
MethodDeclarationSyntax
method = classType.Members[0] as
MethodDeclarationSyntax
;
IncrementalParsing\ChangingIdentifiers.cs (4)
275
MethodDeclarationSyntax
method = classType.Members[0] as
MethodDeclarationSyntax
;
282
var
method = newTree.GetCompilationUnitRoot().Members[0] as
MethodDeclarationSyntax
;
IncrementalParsing\CompoundAssignment.cs (2)
147
var
method = classType.Members[0] as
MethodDeclarationSyntax
;
IncrementalParsing\UnaryExpression.cs (2)
90
var
method = classType.Members[0] as
MethodDeclarationSyntax
;
LexicalAndXml\XmlDocCommentTests.cs (9)
1832
Assert.Equal(typeof(
MethodDeclarationSyntax
), (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0].GetType());
1834
var keyword = ((tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0] as
MethodDeclarationSyntax
).ReturnType;
1867
Assert.Equal(typeof(
MethodDeclarationSyntax
), (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0].GetType());
1869
var keyword = ((tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0] as
MethodDeclarationSyntax
).ReturnType;
1972
Assert.Equal(typeof(
MethodDeclarationSyntax
), (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0].GetType());
1975
var
method = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0] as
MethodDeclarationSyntax
;
2047
Assert.Equal(typeof(
MethodDeclarationSyntax
), (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0].GetType());
2049
var keyword = ((tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0] as
MethodDeclarationSyntax
).ReturnType;
Parsing\DeclarationParsingTests.cs (32)
2499
var
ms = (
MethodDeclarationSyntax
)cs.Members[0];
2545
var
ms = (
MethodDeclarationSyntax
)cs.Members[0];
2591
var
ms = (
MethodDeclarationSyntax
)cs.Members[0];
2694
var
ms = (
MethodDeclarationSyntax
)cs.Members[0];
2762
var
ms = (
MethodDeclarationSyntax
)cs.Members[0];
2809
var
ms = (
MethodDeclarationSyntax
)structDecl.Members[0];
2856
var
ms = (
MethodDeclarationSyntax
)structDecl.Members[0];
3008
var
ms = (
MethodDeclarationSyntax
)cs.Members[0];
3060
var
ms = (
MethodDeclarationSyntax
)cs.Members[0];
3121
var
ms = (
MethodDeclarationSyntax
)cs.Members[0];
3186
var
ms = (
MethodDeclarationSyntax
)cs.Members[0];
3260
var
ms = (
MethodDeclarationSyntax
)cs.Members[0];
3325
var
ms = (
MethodDeclarationSyntax
)cs.Members[0];
3377
var
ms = (
MethodDeclarationSyntax
)cs.Members[0];
3423
var
ms = (
MethodDeclarationSyntax
)cs.Members[0];
5885
var
mainMethod = (
MethodDeclarationSyntax
)@class.Members[0];
Parsing\LocalFunctionParsingTests.cs (10)
1228
var
m = Assert.IsType<
MethodDeclarationSyntax
>(file.DescendantNodes()
1296
var
m = Assert.IsType<
MethodDeclarationSyntax
>(c.Members[0]);
1300
var
m2 = Assert.IsType<
MethodDeclarationSyntax
>(c.Members[1]);
1348
var
m = Assert.IsType<
MethodDeclarationSyntax
>(c.Members[0]);
1358
var
m2 = Assert.IsType<
MethodDeclarationSyntax
>(c.Members[1]);
Parsing\ParserErrorMessageTests.cs (3)
3767
var
methodDeclaration = (
MethodDeclarationSyntax
)tree.GetRoot().DescendantNodes().Single(node => node is
MethodDeclarationSyntax
);
Parsing\ParsingErrorRecoveryTests.cs (224)
3042
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3065
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3089
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3113
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3135
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3158
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3181
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3204
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3227
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3250
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3271
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3292
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3313
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3334
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3355
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3376
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3398
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3421
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3444
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3467
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3491
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3514
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3537
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3554
var
md = (file.Members[0] as TypeDeclarationSyntax).Members[0] as
MethodDeclarationSyntax
;
3580
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3605
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3630
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3656
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3680
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3704
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3729
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3753
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3777
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3801
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3826
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3850
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3874
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3899
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3925
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3951
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
3978
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4003
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4028
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4054
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4075
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4120
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4141
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4162
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4183
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4205
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4227
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4250
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4273
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4294
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4317
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4340
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4366
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4388
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4414
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4441
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4462
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4485
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4510
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4535
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4557
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4582
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4608
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4635
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4662
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4690
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4717
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4744
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4773
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4802
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4832
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4861
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4890
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4917
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4944
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4971
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
4999
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
5026
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
5054
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
5080
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
5110
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
5139
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
5169
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
5822
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
5861
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
5890
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
5919
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
5949
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
5978
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
6012
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
6039
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
6066
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
6093
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
6121
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
6148
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
6178
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
6209
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
6237
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
6284
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
6318
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
6348
var
ms = (
MethodDeclarationSyntax
)agg.Members[0];
6631
var
md = (
MethodDeclarationSyntax
)agg.Members[0];
6676
var
md = (
MethodDeclarationSyntax
)agg.Members[0];
6720
var
md = (
MethodDeclarationSyntax
)agg.Members[0];
6770
var
md = (
MethodDeclarationSyntax
)agg.Members[0];
6818
var
md = (
MethodDeclarationSyntax
)agg.Members[0];
6865
var
md = (
MethodDeclarationSyntax
)agg.Members[0];
6920
var
subitem1 = (
MethodDeclarationSyntax
)item1.Members[0];
Syntax\LambdaUtilitiesTests.cs (2)
57
var
methodDef = tree.GetRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Where(d => d.Identifier.ValueText == "M").Single();
Syntax\SyntaxFactoryTests.cs (1)
561
var
syntaxNode = SyntaxFactory.MethodDeclaration(
Syntax\SyntaxListTests.cs (1)
236
var
newMethodDeclaration = SyntaxFactory.MethodDeclaration(SyntaxFactory.ParseTypeName("void"), "M");
Syntax\SyntaxNodeTests.cs (22)
911
tree1.GetCompilationUnitRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single().IsIncrementallyIdenticalTo(
912
tree2.GetCompilationUnitRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single()));
922
tree1.GetCompilationUnitRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single().IsIncrementallyIdenticalTo(
923
tree2.GetCompilationUnitRoot().DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single()));
2075
MethodDeclarationSyntax
method = root.Members[0].Members[0];
2725
var
m = cu.DescendantNodes().OfType<
MethodDeclarationSyntax
>().FirstOrDefault();
2729
var
m2 = m.RemoveNode(m.Body, SyntaxRemoveOptions.KeepExteriorTrivia);
2759
var
m = cu.DescendantNodes().OfType<
MethodDeclarationSyntax
>().FirstOrDefault();
2794
var
m = cu.DescendantNodes().OfType<
MethodDeclarationSyntax
>().FirstOrDefault();
2832
var
m = cu.DescendantNodes().OfType<
MethodDeclarationSyntax
>().FirstOrDefault();
2872
var
m = cu.DescendantNodes().OfType<
MethodDeclarationSyntax
>().FirstOrDefault();
2904
var
m = cu.DescendantNodes().OfType<
MethodDeclarationSyntax
>().FirstOrDefault();
3503
var
method = (
MethodDeclarationSyntax
)@class.Members.Single();
3590
var
method = root.DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
Microsoft.CodeAnalysis.CSharp.Test.Utilities (2)
Extensions.cs (2)
42
public static
MethodDeclarationSyntax
AsMethodDeclarationSyntax(this SyntaxNode node)
44
return node as
MethodDeclarationSyntax
;
Microsoft.CodeAnalysis.CSharp.Workspaces (64)
Classification\ClassificationHelpers.cs (2)
206
else if (token.Parent is
MethodDeclarationSyntax
methodDeclaration && methodDeclaration.Identifier == token)
331
private static bool IsExtensionMethod(
MethodDeclarationSyntax
methodDeclaration)
CodeGeneration\CSharpSyntaxGenerator.cs (20)
612
if (declaration is
MethodDeclarationSyntax
method)
626
SyntaxKind.MethodDeclaration => ((
MethodDeclarationSyntax
)declaration).WithExplicitInterfaceSpecifier(specifier),
815
return ((
MethodDeclarationSyntax
)member)
1756
MethodDeclarationSyntax
method => method.WithTypeParameterList(typeParameterList),
1769
MethodDeclarationSyntax
method
1778
private static
MethodDeclarationSyntax
WithoutConstraints(
MethodDeclarationSyntax
method)
1810
MethodDeclarationSyntax
method => method.WithConstraintClauses(WithTypeConstraints(method.ConstraintClauses, typeParameterName, kinds, isUnmanagedType, types)),
1818
var
method = (
MethodDeclarationSyntax
)declaration;
1882
MethodDeclarationSyntax
methodDeclaration => methodDeclaration.Identifier.ValueText,
1909
MethodDeclarationSyntax
methodDeclaration => ReplaceWithTrivia(declaration, methodDeclaration.Identifier, id),
1946
return NotVoid(((
MethodDeclarationSyntax
)declaration).ReturnType);
1985
SyntaxKind.MethodDeclaration => ((
MethodDeclarationSyntax
)declaration).WithReturnType((TypeSyntax)type),
2210
return ((
MethodDeclarationSyntax
)declaration).WithParameterList(list);
2277
var
method = (
MethodDeclarationSyntax
)declaration;
2333
var
method = (
MethodDeclarationSyntax
)declaration;
2459
SyntaxKind.MethodDeclaration => ((
MethodDeclarationSyntax
)declaration).Body?.Statements,
FindSymbols\CSharpDeclaredSymbolInfoFactoryService.cs (6)
34
MethodDeclarationSyntax
,
351
var
method = (
MethodDeclarationSyntax
)node;
496
private static string GetMethodSuffix(
MethodDeclarationSyntax
method)
662
private static bool IsExtensionMethod(
MethodDeclarationSyntax
method)
686
protected override string GetReceiverTypeName(
MethodDeclarationSyntax
methodDeclaration)
Rename\LocalConflictVisitor.cs (1)
30
public override void VisitMethodDeclaration(
MethodDeclarationSyntax
node)
Simplification\Reducers\CSharpEscapingReducer.cs (2)
75
var enclosingMethodBlock = parent.GetAncestorsOrThis(n => n is
MethodDeclarationSyntax
).FirstOrDefault();
77
if (enclosingMethodBlock != null && ((
MethodDeclarationSyntax
)enclosingMethodBlock).Modifiers.Any(SyntaxKind.AsyncKeyword))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ILocalSymbolExtensions.cs (1)
35
case
MethodDeclarationSyntax
methodDeclaration:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberDeclarationSyntaxExtensions.cs (5)
52
return ((
MethodDeclarationSyntax
)member).Identifier;
83
return ((
MethodDeclarationSyntax
)member).Arity;
105
return ((
MethodDeclarationSyntax
)member).TypeParameterList;
123
return ((
MethodDeclarationSyntax
)member).WithParameterList((ParameterListSyntax)parameterList);
147
return ((
MethodDeclarationSyntax
)member).ReturnType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (1)
280
=> node is
MethodDeclarationSyntax
or AnonymousFunctionExpressionSyntax or LocalFunctionStatementSyntax;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (2)
70
var
method = (
MethodDeclarationSyntax
)declaration;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (1)
66
var node = TryGetAncestorForLocation<
MethodDeclarationSyntax
>(root, position);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (1)
1545
=> node is
MethodDeclarationSyntax
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
124
MethodDeclarationSyntax
or
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (2)
155
=> members.FirstOrDefault(m => m is
MethodDeclarationSyntax
);
164
=> members.LastOrDefault(m => m is
MethodDeclarationSyntax
);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (2)
796
var
methodDeclarationSyntax = (
MethodDeclarationSyntax
)syntaxNode;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpDeclarationComparer.cs (4)
118
return Compare((
MethodDeclarationSyntax
)x, (
MethodDeclarationSyntax
)y);
199
private int Compare(
MethodDeclarationSyntax
x,
MethodDeclarationSyntax
y)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (11)
37
var
declaration = GenerateMethodDeclaration(method, CodeGenerationDestination.Namespace, info, cancellationToken);
50
var
declaration = GenerateMethodDeclaration(
65
var
methodDeclaration = GenerateMethodDeclaration(
74
public static
MethodDeclarationSyntax
GenerateMethodDeclaration(
79
var
reusableSyntax = GetReuseableSyntaxNodeForSymbol<
MethodDeclarationSyntax
>(method, info);
85
var
declaration = GenerateMethodDeclarationWorker(
111
private static
MethodDeclarationSyntax
GenerateMethodDeclarationWorker(
126
var
methodDeclaration = MethodDeclaration(
183
private static
MethodDeclarationSyntax
UseExpressionBodyIfDesired(
184
CSharpCodeGenerationContextInfo info,
MethodDeclarationSyntax
methodDeclaration, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (2)
1130
MethodDeclarationSyntax
or LocalFunctionStatementSyntax or ConstructorDeclarationSyntax or DelegateDeclarationSyntax or TypeDeclarationSyntax => true,
1213
var method = tokenOnLeftOfPosition.Parent.GetAncestorOrThis<
MethodDeclarationSyntax
>();
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (72)
CodeGeneration\SyntaxGeneratorTests.cs (70)
804
VerifySyntax<
MethodDeclarationSyntax
>(
808
VerifySyntax<
MethodDeclarationSyntax
>(
812
VerifySyntax<
MethodDeclarationSyntax
>(
816
VerifySyntax<
MethodDeclarationSyntax
>(
820
VerifySyntax<
MethodDeclarationSyntax
>(
824
VerifySyntax<
MethodDeclarationSyntax
>(
828
VerifySyntax<
MethodDeclarationSyntax
>(
832
VerifySyntax<
MethodDeclarationSyntax
>(
836
VerifySyntax<
MethodDeclarationSyntax
>(
840
VerifySyntax<
MethodDeclarationSyntax
>(
844
VerifySyntax<
MethodDeclarationSyntax
>(
1169
VerifySyntax<
MethodDeclarationSyntax
>(
1192
VerifySyntax<
MethodDeclarationSyntax
>(
1196
VerifySyntax<
MethodDeclarationSyntax
>(
1201
VerifySyntax<
MethodDeclarationSyntax
>(
1472
VerifySyntax<
MethodDeclarationSyntax
>(
1501
VerifySyntax<
MethodDeclarationSyntax
>(
1505
VerifySyntax<
MethodDeclarationSyntax
>(
1525
VerifySyntax<
MethodDeclarationSyntax
>(
1856
VerifySyntax<
MethodDeclarationSyntax
>(
1862
VerifySyntax<
MethodDeclarationSyntax
>(
1999
VerifySyntax<
MethodDeclarationSyntax
>(
2005
VerifySyntax<
MethodDeclarationSyntax
>(
2010
VerifySyntax<
MethodDeclarationSyntax
>(
2016
VerifySyntax<
MethodDeclarationSyntax
>(
2050
VerifySyntax<
MethodDeclarationSyntax
>(
2056
VerifySyntax<
MethodDeclarationSyntax
>(
2062
VerifySyntax<
MethodDeclarationSyntax
>(
2068
VerifySyntax<
MethodDeclarationSyntax
>(
2074
VerifySyntax<
MethodDeclarationSyntax
>(
2082
VerifySyntax<
MethodDeclarationSyntax
>(
2088
VerifySyntax<
MethodDeclarationSyntax
>(
2094
VerifySyntax<
MethodDeclarationSyntax
>(
2100
VerifySyntax<
MethodDeclarationSyntax
>(
2106
VerifySyntax<
MethodDeclarationSyntax
>(
2112
VerifySyntax<
MethodDeclarationSyntax
>(
2166
VerifySyntax<
MethodDeclarationSyntax
>(
2229
VerifySyntax<
MethodDeclarationSyntax
>(
2250
VerifySyntax<
MethodDeclarationSyntax
>(
2271
VerifySyntax<
MethodDeclarationSyntax
>(
2292
VerifySyntax<
MethodDeclarationSyntax
>(
2376
VerifySyntax<
MethodDeclarationSyntax
>(
2404
VerifySyntax<
MethodDeclarationSyntax
>(
2432
VerifySyntax<
MethodDeclarationSyntax
>(
2463
VerifySyntax<
MethodDeclarationSyntax
>(
2500
VerifySyntax<
MethodDeclarationSyntax
>(
2799
var
method = (
MethodDeclarationSyntax
)Generator.MethodDeclaration("m");
3298
var
method = (
MethodDeclarationSyntax
)Generator.MethodDeclaration("p");
3334
var
method = (
MethodDeclarationSyntax
)Generator.MethodDeclaration("p");
4282
VerifySyntax<
MethodDeclarationSyntax
>(
4333
VerifySyntax<
MethodDeclarationSyntax
>(
4341
VerifySyntax<
MethodDeclarationSyntax
>(
4350
VerifySyntax<
MethodDeclarationSyntax
>(
4359
VerifySyntax<
MethodDeclarationSyntax
>(
4368
VerifySyntax<
MethodDeclarationSyntax
>(
4375
VerifySyntax<
MethodDeclarationSyntax
>(
4441
VerifySyntax<
MethodDeclarationSyntax
>(
4453
VerifySyntax<
MethodDeclarationSyntax
>(
4465
VerifySyntax<
MethodDeclarationSyntax
>(
4478
VerifySyntax<
MethodDeclarationSyntax
>(
4490
VerifySyntax<
MethodDeclarationSyntax
>(
4502
VerifySyntax<
MethodDeclarationSyntax
>(
4514
VerifySyntax<
MethodDeclarationSyntax
>(
4526
VerifySyntax<
MethodDeclarationSyntax
>(
4539
VerifySyntax<
MethodDeclarationSyntax
>(
4552
VerifySyntax<
MethodDeclarationSyntax
>(
4693
VerifySyntax<
MethodDeclarationSyntax
>(
Formatting\FormattingTreeEditTests.cs (2)
56
var
method = root.DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (2)
CodeGeneration\CodeGenerationTests.CSharp.cs (1)
1442
await TestUpdateDeclarationAsync<
MethodDeclarationSyntax
>(input, expected, getType: GetTypeSymbol(typeof(int)));
SymbolKey\SymbolKeyCrossLanguageTests.cs (1)
46
var method = root.DescendantNodes().OfType<
MethodDeclarationSyntax
>().Single();
Microsoft.CodeAnalysis.Workspaces.UnitTests (17)
CodeCleanup\CodeCleanupTests.cs (1)
365
public static CSharp.Syntax.
MethodDeclarationSyntax
CreateCSharpMethod(string returnType = "void", string methodName = "Method")
Editing\SyntaxEditorTests.cs (4)
223
var
methodX = (
MethodDeclarationSyntax
)editor.Generator.GetMembers(cls)[0];
267
var
methodX = (
MethodDeclarationSyntax
)editor.Generator.GetMembers(cls)[0];
FindReferencesTests.cs (1)
286
var methodlist = tree.GetRoot().DescendantNodes().OfType<Microsoft.CodeAnalysis.CSharp.Syntax.
MethodDeclarationSyntax
>().ToList();
SymbolKeyTests.cs (2)
1023
n => n is CSharp.Syntax.
MethodDeclarationSyntax
).Single();
1060
n => n is CSharp.Syntax.
MethodDeclarationSyntax
).Single();
SyntaxNodeTests.cs (4)
96
var
methodDecl = classDecl.DescendantNodes().OfType<
MethodDeclarationSyntax
>().First();
109
var
latestMethod = classDeclWithField.GetCurrentNodes(methodDecl).First();
127
var
finalMethodDecl = root2.GetCurrentNodes(methodDecl).First();
SyntaxPathTests.cs (5)
164
Assert.Equal("M1", ((
MethodDeclarationSyntax
)n1).Identifier.ValueText);
167
Assert.Equal("M2", ((
MethodDeclarationSyntax
)n2).Identifier.ValueText);
170
Assert.Equal("M3", ((
MethodDeclarationSyntax
)n3).Identifier.ValueText);
232
Assert.Equal("M1", ((
MethodDeclarationSyntax
)n1).Identifier.ValueText);
235
Assert.Equal("M2", ((
MethodDeclarationSyntax
)n2).Identifier.ValueText);
Microsoft.DotNet.GenFacades (2)
NotSupportedAssemblyGenerator.cs (2)
113
public override SyntaxNode VisitMethodDeclaration(
MethodDeclarationSyntax
node)
215
private string GetMethodDefinition(
MethodDeclarationSyntax
node) => GetFullyQualifiedName((TypeDeclarationSyntax)node.Parent) + "." + node.Identifier.ValueText;
Microsoft.Extensions.Logging.Generators (5)
LoggerMessageGenerator.Parser.cs (2)
96
var
method = member as
MethodDeclarationSyntax
;
LoggerMessageGenerator.Roslyn3.11.cs (3)
65
node is
MethodDeclarationSyntax
m && m.AttributeLists.Count > 0;
69
var
methodDeclarationSyntax = (
MethodDeclarationSyntax
)context.Node;
Microsoft.Gen.ContextualOptions.Unit.Tests (2)
EmitterTests.cs (2)
64
.OfType<
MethodDeclarationSyntax
>()
93
.OfType<
MethodDeclarationSyntax
>()
Microsoft.Gen.Logging (5)
Parsing\Parser.cs (5)
71
var
method = member as
MethodDeclarationSyntax
;
366
(LoggingMethod lm, bool keepMethod) ProcessMethod(
MethodDeclarationSyntax
method, IMethodSymbol methodSymbol, Location attrLoc)
455
private static bool HasXmlDocumentation(
MethodDeclarationSyntax
method)
603
private Location? GetLoggerMessageAttribute(
MethodDeclarationSyntax
methodSyntax, SemanticModel sm, SymbolHolder symbols)
Microsoft.Gen.Metrics (3)
Parser.cs (3)
83
var
methodSyntax = (
MethodDeclarationSyntax
)memberSyntax;
393
MethodDeclarationSyntax
methodSyntax,
Microsoft.Gen.MetricsReports (3)
src\Generators\Microsoft.Gen.Metrics\Parser.cs (3)
83
var
methodSyntax = (
MethodDeclarationSyntax
)memberSyntax;
393
MethodDeclarationSyntax
methodSyntax,
Microsoft.Interop.ComInterfaceGenerator (24)
Analyzers\ConvertComImportToGeneratedComInterfaceAnalyzer.cs (1)
75
GeneratorDiagnosticsBag diagnostics = new(new DiagnosticDescriptorProvider(), new MethodSignatureDiagnosticLocations((
MethodDeclarationSyntax
)method.DeclaringSyntaxReferences[0].GetSyntax()), SR.ResourceManager, typeof(FxResources.Microsoft.Interop.ComInterfaceGenerator.SR));
ComInterfaceGenerator.cs (2)
236
private static IncrementalMethodStubGenerationContext CalculateStubInformation(
MethodDeclarationSyntax
syntax, IMethodSymbol symbol, int index, StubEnvironment environment, ManagedTypeInfo owningInterface, CancellationToken ct)
517
private static readonly
MethodDeclarationSyntax
CreateManagedVirtualFunctionTableMethodTemplate = MethodDeclaration(TypeSyntaxes.VoidStarStar, CreateManagedVirtualFunctionTableMethodName)
ComMethodContext.cs (6)
102
private
MethodDeclarationSyntax
? _unreachableExceptionStub;
104
public
MethodDeclarationSyntax
UnreachableExceptionStub => _unreachableExceptionStub ??= CreateUnreachableExceptionStub();
106
private
MethodDeclarationSyntax
CreateUnreachableExceptionStub()
123
private
MethodDeclarationSyntax
? _shadow;
125
public
MethodDeclarationSyntax
Shadow => _shadow ??= GenerateShadow();
127
private
MethodDeclarationSyntax
GenerateShadow()
ComMethodInfo.cs (5)
20
public
MethodDeclarationSyntax
Syntax { get; init; }
26
MethodDeclarationSyntax
syntax,
66
private static DiagnosticInfo? GetDiagnosticIfInvalidMethodForGeneration(
MethodDeclarationSyntax
comMethodDeclaringSyntax, IMethodSymbol method)
123
MethodDeclarationSyntax
? comMethodDeclaringSyntax = null;
129
comMethodDeclaringSyntax = (
MethodDeclarationSyntax
)declaringSyntax;
GeneratedStubCodeContext.cs (1)
12
SyntaxEquivalentNode<
MethodDeclarationSyntax
> Stub,
VirtualMethodPointerStubGenerator.cs (4)
23
public static (
MethodDeclarationSyntax
, ImmutableArray<DiagnosticInfo>) GenerateManagedToNativeStub(
115
private static
MethodDeclarationSyntax
PrintGeneratedSource(
130
public static (
MethodDeclarationSyntax
, ImmutableArray<DiagnosticInfo>) GenerateNativeToManagedStub(
165
MethodDeclarationSyntax
unmanagedToManagedStub =
VtableIndexStubGenerator.cs (5)
41
static (node, ct) => node is
MethodDeclarationSyntax
,
43
? new { Syntax = (
MethodDeclarationSyntax
)context.TargetNode, Symbol = methodSymbol }
198
private static IncrementalMethodStubGenerationContext CalculateStubInformation(
MethodDeclarationSyntax
syntax, IMethodSymbol symbol, StubEnvironment environment, CancellationToken ct)
391
private static Diagnostic? GetDiagnosticIfInvalidMethodForGeneration(
MethodDeclarationSyntax
methodSyntax, IMethodSymbol method)
441
MethodDeclarationSyntax
populateVtableMethod = MethodDeclaration(PredefinedType(Token(SyntaxKind.VoidKeyword)),
Microsoft.Interop.JavaScript.JSImportGenerator (9)
JSExportGenerator.cs (4)
42
static (node, ct) => node is
MethodDeclarationSyntax
,
43
static (context, ct) => new { Syntax = (
MethodDeclarationSyntax
)context.TargetNode, Symbol = (IMethodSymbol)context.TargetSymbol });
170
MethodDeclarationSyntax
originalSyntax,
335
private static Diagnostic? GetDiagnosticIfInvalidMethodForGeneration(
MethodDeclarationSyntax
methodSyntax, IMethodSymbol method)
JSImportGenerator.cs (5)
40
static (node, ct) => node is
MethodDeclarationSyntax
,
41
static (context, ct) => new { Syntax = (
MethodDeclarationSyntax
)context.TargetNode, Symbol = (IMethodSymbol)context.TargetSymbol });
113
MethodDeclarationSyntax
stubMethod = MethodDeclaration(stub.SignatureContext.StubReturnType, userDeclaredMethod.Identifier)
150
MethodDeclarationSyntax
originalSyntax,
214
private static Diagnostic? GetDiagnosticIfInvalidMethodForGeneration(
MethodDeclarationSyntax
methodSyntax, IMethodSymbol method)
Microsoft.Interop.LibraryImportGenerator (9)
Analyzers\ConvertToLibraryImportAnalyzer.cs (1)
141
GeneratorDiagnosticsBag diagnostics = new(new DiagnosticDescriptorProvider(), new MethodSignatureDiagnosticLocations((
MethodDeclarationSyntax
)method.DeclaringSyntaxReferences[0].GetSyntax()), SR.ResourceManager, typeof(FxResources.Microsoft.Interop.LibraryImportGenerator.SR));
LibraryImportGenerator.cs (8)
46
static (node, ct) => node is
MethodDeclarationSyntax
,
48
? new { Syntax = (
MethodDeclarationSyntax
)context.TargetNode, Symbol = methodSymbol }
58
? DiagnosticOr<(
MethodDeclarationSyntax
Syntax, IMethodSymbol Symbol)>.From(diagnostic)
59
: DiagnosticOr<(
MethodDeclarationSyntax
Syntax, IMethodSymbol Symbol)>.From((data.Syntax, data.Symbol));
173
private static
MethodDeclarationSyntax
PrintGeneratedSource(
219
MethodDeclarationSyntax
originalSyntax,
417
MethodDeclarationSyntax
stubMethod = MethodDeclaration(stub.SignatureContext.StubReturnType, userDeclaredMethod.Identifier)
541
private static DiagnosticInfo? GetDiagnosticIfInvalidMethodForGeneration(
MethodDeclarationSyntax
methodSyntax, IMethodSymbol method)
Microsoft.Interop.LibraryImportGenerator.Downlevel (8)
DownlevelLibraryImportGenerator.cs (8)
45
static (node, ct) => node is
MethodDeclarationSyntax
,
47
? new { Syntax = (
MethodDeclarationSyntax
)context.TargetNode, Symbol = methodSymbol }
57
? DiagnosticOr<(
MethodDeclarationSyntax
Syntax, IMethodSymbol Symbol)>.From(diagnostic)
58
: DiagnosticOr<(
MethodDeclarationSyntax
Syntax, IMethodSymbol Symbol)>.From((data.Syntax, data.Symbol));
115
private static
MethodDeclarationSyntax
PrintGeneratedSource(
161
MethodDeclarationSyntax
originalSyntax,
296
MethodDeclarationSyntax
stubMethod = MethodDeclaration(stub.SignatureContext.StubReturnType, userDeclaredMethod.Identifier)
411
private static DiagnosticInfo? GetDiagnosticIfInvalidMethodForGeneration(
MethodDeclarationSyntax
methodSyntax, IMethodSymbol method)
Microsoft.Interop.SourceGeneration (1)
MethodSignatureDiagnosticLocations.cs (1)
47
public MethodSignatureDiagnosticLocations(
MethodDeclarationSyntax
syntax)
Microsoft.ML.InternalCodeAnalyzer (4)
ContractsCheckAnalyzer.cs (1)
168
var enclosingParams = ((node as
MethodDeclarationSyntax
)?.ParameterList
ContractsCheckNameofFixProvider.cs (1)
114
var paramList = (temp as
MethodDeclarationSyntax
)?.ParameterList
NameAnalyzer.cs (2)
105
var
node = (
MethodDeclarationSyntax
)context.Node;
Microsoft.VisualStudio.LanguageServices.CSharp (23)
CodeModel\CSharpCodeModelService.CodeModelEventCollector.cs (1)
830
if (method is
MethodDeclarationSyntax
methodDecl)
CodeModel\CSharpCodeModelService.cs (16)
811
return ((
MethodDeclarationSyntax
)node).ExplicitInterfaceSpecifier?.ToString() +
812
((
MethodDeclarationSyntax
)node).Identifier.ToString();
892
return ((
MethodDeclarationSyntax
)node).WithIdentifier(newIdentifier);
2266
Debug.Assert(memberNode is
MethodDeclarationSyntax
or
2303
if (member is
MethodDeclarationSyntax
method)
2342
if (member is
MethodDeclarationSyntax
method)
2895
if (node is not
MethodDeclarationSyntax
methodDeclaration)
3384
else if (container is
MethodDeclarationSyntax
method)
3578
private static bool IsExtensionMethod(
MethodDeclarationSyntax
methodDeclaration)
3595
private static bool IsPartialMethod(
MethodDeclarationSyntax
methodDeclaration)
3611
var
methodDeclaration = (
MethodDeclarationSyntax
)node;
3629
var
methodDeclaration = (
MethodDeclarationSyntax
)node;
3683
return node is
MethodDeclarationSyntax
methodDeclaration
3685
&& newNode is
MethodDeclarationSyntax
newMethodDeclaration
CodeModel\CSharpCodeModelService.NodeLocator.cs (2)
395
startPosition = ((
MethodDeclarationSyntax
)node).Identifier.SpanStart;
958
endPosition = ((
MethodDeclarationSyntax
)node).Identifier.Span.End;
CodeModel\CSharpCodeModelService.NodeNameGenerator.cs (2)
203
var
methodDeclaration = (
MethodDeclarationSyntax
)node;
CodeModel\MethodXml\MethodXmlBuilder.cs (1)
609
public static string Generate(
MethodDeclarationSyntax
methodDeclaration, SemanticModel semanticModel)
LanguageService\CSharpHelpContextService.cs (1)
385
if (token.Parent.GetAncestorOrThis<
MethodDeclarationSyntax
>() != null)
Mvc.Api.Analyzers.Test (2)
ActualApiResponseMetadataFactoryTest.cs (2)
374
var
methodSyntax = (
MethodDeclarationSyntax
)syntaxTree.GetRoot().FindNode(method.Locations[0].SourceSpan);
System.Text.RegularExpressions.Generator (4)
RegexGenerator.cs (1)
60
(node, _) => node is
MethodDeclarationSyntax
or PropertyDeclarationSyntax or IndexerDeclarationSyntax or AccessorDeclarationSyntax,
UpgradeToGeneratedRegexCodeFixer.cs (3)
183
MethodDeclarationSyntax
newMethod = (
MethodDeclarationSyntax
)generator.MethodDeclaration(
232
newMethod = (
MethodDeclarationSyntax
)generator.AddAttributes(newMethod, attributes);