1034 references to IsKind
Microsoft.Analyzers.Extra (4)
CallAnalysis\Fixers\LegacyLoggingFixer.cs (3)
169
foreach (var method in targetClass.Members.Where(m => m.
IsKind
(SyntaxKind.MethodDeclaration)).OfType<MethodDeclarationSyntax>())
270
var allClasses = allNodes.Where(d => d.
IsKind
(SyntaxKind.ClassDeclaration)).OfType<ClassDeclarationSyntax>();
522
if (invocationExpression.Parent!.
IsKind
(SyntaxKind.ConditionalAccessExpression))
Utilities\SyntaxNodeExtensions.cs (1)
27
while (n != null && !n.
IsKind
(kind))
Microsoft.Analyzers.Local (2)
CallAnalysis\Throws.cs (2)
35
if (op.Syntax.
IsKind
(SyntaxKind.ThrowStatement))
44
else if (op.Syntax.
IsKind
(SyntaxKind.ThrowExpression))
Microsoft.AspNetCore.App.Analyzers (14)
RenderTreeBuilder\RenderTreeBuilderAnalyzer.cs (1)
43
if (!argument.Value.Syntax.
IsKind
(SyntaxKind.NumericLiteralExpression))
RouteEmbeddedLanguage\FrameworkParametersCompletionProvider.cs (6)
149
if (container.Parent.
IsKind
(SyntaxKind.Argument))
187
else if (container.
IsKind
(SyntaxKind.Parameter))
326
if (current.
IsKind
(SyntaxKind.Parameter))
342
if (current.Parent?.
IsKind
(SyntaxKind.Argument) ?? false)
344
if (current.Parent?.Parent?.
IsKind
(SyntaxKind.ArgumentList) ?? false)
388
if (token.Parent.
IsKind
(SyntaxKind.PredefinedType))
RouteEmbeddedLanguage\Infrastructure\RouteStringSyntaxDetector.cs (4)
83
if (container.Parent.
IsKind
(SyntaxKind.Argument))
90
else if (container.Parent.
IsKind
(SyntaxKind.AttributeArgument))
111
if (container.Parent?.
IsKind
(SyntaxKind.EqualsValueClause) ?? false)
113
if (container.Parent.Parent?.
IsKind
(SyntaxKind.VariableDeclarator) ?? false)
RouteEmbeddedLanguage\Infrastructure\RouteUsageDetector.cs (2)
82
if (container.Parent.
IsKind
(SyntaxKind.Argument))
109
else if (container.Parent.
IsKind
(SyntaxKind.AttributeArgument))
RouteEmbeddedLanguage\Infrastructure\SyntaxNodeExtensions.cs (1)
71
exprStatement.Expression.
IsKind
(SyntaxKind.SimpleAssignmentExpression);
Microsoft.AspNetCore.App.CodeFixes (1)
Dependencies\ExtensionMethodsCompletionProvider.cs (1)
90
if (current?.
IsKind
(SyntaxKind.SimpleMemberAccessExpression) ?? false)
Microsoft.AspNetCore.Components.Analyzers (3)
ComponentParameterAnalyzer.cs (3)
157
if (getterAccessor.
IsKind
(SyntaxKind.SetAccessorDeclaration))
163
if (!getterAccessor.
IsKind
(SyntaxKind.GetAccessorDeclaration) || !setterAccessor.
IsKind
(SyntaxKind.SetAccessorDeclaration))
Microsoft.CodeAnalysis.CSharp (116)
Binder\Binder_Crefs.cs (1)
1028
return parentSyntax == null || parentSyntax.
IsKind
(SyntaxKind.XmlCrefAttribute)
Binder\Binder_Expressions.cs (8)
4576
if (!equalsValueClause.
IsKind
(SyntaxKind.EqualsValueClause))
4583
if (!variableDeclarator.
IsKind
(SyntaxKind.VariableDeclarator))
4589
if (!variableDeclaration.
IsKind
(SyntaxKind.VariableDeclaration))
4595
variableDeclaration.Parent.
IsKind
(SyntaxKind.LocalDeclarationStatement) ||
4596
variableDeclaration.Parent.
IsKind
(SyntaxKind.ForStatement);
4611
Debug.Assert(node.
IsKind
(SyntaxKind.ImplicitStackAllocArrayCreationExpression) || node.
IsKind
(SyntaxKind.StackAllocArrayCreationExpression));
4648
bool isInferred = node.
IsKind
(SyntaxKind.ImplicitStackAllocArrayCreationExpression);
Binder\BinderFactory.BinderFactoryVisitor.cs (1)
1091
if (node.
IsKind
(SyntaxKind.UsingDirective) && node.Parent == containingNode)
Binder\DecisionDagBuilder.cs (1)
2218
if (e.Syntax.
IsKind
(SyntaxKind.ListPattern))
Binder\WithUsingNamespacesAndTypesBinder.cs (2)
306
Debug.Assert(declarationSyntax.
IsKind
(SyntaxKind.CompilationUnit) || declarationSyntax.
IsKind
(SyntaxKind.NamespaceDeclaration));
CodeGen\EmitStatement.cs (2)
847
return _ilEmitStyle == ILEmitStyle.Debug && _method.GenerateDebugInfo && _methodBodySyntaxOpt?.
IsKind
(SyntaxKind.Block) == true ||
858
(boundReturnStatement.Syntax.
IsKind
(SyntaxKind.Block) || _method?.IsImplicitConstructor == true) &&
Compilation\CSharpCompilation.cs (1)
782
if (root.DescendantNodes(n => n is GlobalStatementSyntax || n is StatementSyntax || n is CompilationUnitSyntax).Any(n => n.
IsKind
(SyntaxKind.ReturnStatement)))
Compilation\CSharpSemanticModel.cs (1)
1847
if (curr.
IsKind
(SyntaxKind.TypeOfExpression))
Compilation\InitializerSemanticModel.cs (3)
42
Debug.Assert(syntax.
IsKind
(SyntaxKind.VariableDeclarator) || syntax.
IsKind
(SyntaxKind.EnumMemberDeclaration));
52
Debug.Assert(syntax.
IsKind
(SyntaxKind.PropertyDeclaration));
FlowAnalysis\FlowAnalysisPass.cs (4)
195
syntax.
IsKind
(SyntaxKind.Block) ||
196
syntax.
IsKind
(SyntaxKind.ArrowExpressionClause) ||
197
syntax.
IsKind
(SyntaxKind.ConstructorDeclaration) ||
198
syntax.
IsKind
(SyntaxKind.CompilationUnit));
Lowering\AsyncRewriter\AsyncExceptionHandlerRewriter.cs (2)
548
Debug.Assert(node.Syntax.
IsKind
(SyntaxKind.CatchClause));
1067
Debug.Assert(pendingCatch.SyntaxOpt.
IsKind
(SyntaxKind.TryStatement));
Lowering\AsyncRewriter\AsyncMethodToStateMachineRewriter.cs (1)
362
Debug.Assert(node.Syntax.
IsKind
(SyntaxKind.AwaitExpression) || node.WasCompilerGenerated);
Lowering\Instrumentation\DebugInfoInjector.cs (1)
134
if (syntax.
IsKind
(SyntaxKind.Parameter))
Lowering\LocalRewriter\LocalRewriter.cs (1)
865
if (syntax.
IsKind
(SyntaxKind.Parameter))
Lowering\StateMachineRewriter\MethodToStateMachineRewriter.cs (2)
519
SynthesizedLocalKind.Spill => awaitSyntaxOpt.
IsKind
(SyntaxKind.AwaitExpression) || awaitSyntaxOpt.
IsKind
(SyntaxKind.SwitchExpression),
Operations\CSharpOperationFactory.cs (1)
2156
SyntaxNode declarationSyntax = declarationGroupSyntax.
IsKind
(SyntaxKind.LocalDeclarationStatement) ?
Symbols\FieldOrPropertyInitializer.cs (2)
31
Debug.Assert(((syntax.
IsKind
(SyntaxKind.EqualsValueClause) || syntax.
IsKind
(SyntaxKind.Parameter)) && fieldOpt != null) || syntax is StatementSyntax);
Symbols\Source\SourceComplexParameterSymbol.cs (1)
53
Debug.Assert((syntaxRef == null) || (syntaxRef.GetSyntax().
IsKind
(SyntaxKind.Parameter)));
Symbols\Source\TypeParameterBuilder.cs (1)
29
Debug.Assert(syntaxRef.GetSyntax().
IsKind
(SyntaxKind.TypeParameter));
Syntax\CSharpSyntaxRewriter.cs (1)
152
if (!alternate.IsNull && visited != null && !visited.
IsKind
(SyntaxKind.None))
Syntax\LambdaUtilities.cs (7)
40
return !node.Parent.
IsKind
(SyntaxKind.QueryExpression);
55
if (lambda.
IsKind
(SyntaxKind.ArrowExpressionClause))
61
Debug.Assert(lambda.
IsKind
(SyntaxKind.LocalFunctionStatement));
298
if (node.Parent.
IsKind
(SyntaxKind.QueryExpression))
376
return syntax.
IsKind
(SyntaxKind.GroupClause) ||
377
syntax.
IsKind
(SyntaxKind.JoinClause) ||
378
syntax.
IsKind
(SyntaxKind.FromClause);
Syntax\SyntaxBindingUtilities.cs (2)
14
=> node.
IsKind
(SyntaxKind.YieldReturnStatement) ||
15
node.
IsKind
(SyntaxKind.AwaitExpression) ||
Syntax\SyntaxFactory.cs (3)
2229
if (parent.Parent.
IsKind
(SyntaxKind.Subpattern))
2360
if (lastNode.
IsKind
(SyntaxKind.IncompleteMember))
2367
if (!lastNode.
IsKind
(SyntaxKind.GlobalStatement))
Syntax\SyntaxFacts.cs (13)
278
if (!node.
IsKind
(IdentifierName))
284
if (parent1 == null || !parent1.
IsKind
(NameColon))
290
if (parent2.
IsKind
(SyntaxKind.Subpattern))
295
if (parent2 == null || !(parent2.
IsKind
(Argument) || parent2.
IsKind
(AttributeArgument)))
306
if (parent3.
IsKind
(SyntaxKind.TupleExpression))
311
if (!(parent3 is BaseArgumentListSyntax || parent3.
IsKind
(AttributeArgumentList)))
348
while (current != null && (current.
IsKind
(ParenthesizedExpression) || current.
IsKind
(CastExpression))) current = current.Parent;
349
if (current == null || !current.
IsKind
(EqualsValueClause)) return false;
351
if (current == null || !current.
IsKind
(VariableDeclarator)) return false;
353
if (current == null || !current.
IsKind
(VariableDeclaration)) return false;
355
return current != null && current.
IsKind
(FixedStatement);
Syntax\SyntaxNodeExtensions.cs (5)
150
if (node.Parent.
IsKind
(SyntaxKind.CastExpression))
155
while (node.Parent.
IsKind
(SyntaxKind.ConditionalExpression))
174
return variableDeclarator.
IsKind
(SyntaxKind.VariableDeclarator) &&
175
variableDeclarator.Parent.
IsKind
(SyntaxKind.VariableDeclaration);
180
return parentNode.Parent.
IsKind
(SyntaxKind.ExpressionStatement);
Syntax\SyntaxNormalizer.cs (49)
279
if ((nextToken.IsKind(SyntaxKind.FromKeyword) && nextToken.Parent.
IsKind
(SyntaxKind.FromClause)) ||
280
(nextToken.IsKind(SyntaxKind.LetKeyword) && nextToken.Parent.
IsKind
(SyntaxKind.LetClause)) ||
281
(nextToken.IsKind(SyntaxKind.WhereKeyword) && nextToken.Parent.
IsKind
(SyntaxKind.WhereClause)) ||
282
(nextToken.IsKind(SyntaxKind.JoinKeyword) && nextToken.Parent.
IsKind
(SyntaxKind.JoinClause)) ||
283
(nextToken.IsKind(SyntaxKind.JoinKeyword) && nextToken.Parent.
IsKind
(SyntaxKind.JoinIntoClause)) ||
284
(nextToken.IsKind(SyntaxKind.OrderByKeyword) && nextToken.Parent.
IsKind
(SyntaxKind.OrderByClause)) ||
285
(nextToken.IsKind(SyntaxKind.SelectKeyword) && nextToken.Parent.
IsKind
(SyntaxKind.SelectClause)) ||
286
(nextToken.IsKind(SyntaxKind.GroupKeyword) && nextToken.Parent.
IsKind
(SyntaxKind.GroupClause)))
320
if (parent.
IsKind
(SyntaxKind.Interpolation) ||
337
if (parent.
IsKind
(SyntaxKind.Interpolation) ||
353
parent.
IsKind
(SyntaxKind.Interpolation) ||
369
currentTokenParent.
IsKind
(SyntaxKind.Interpolation) ||
400
nextToken.Parent.
IsKind
(SyntaxKind.DoStatement))
417
if (currentToken.Parent.
IsKind
(SyntaxKind.ForStatement))
425
else if (currentToken.Parent.
IsKind
(SyntaxKind.UsingDirective))
427
return nextToken.Parent.
IsKind
(SyntaxKind.UsingDirective) ? 1 : 2;
429
else if (currentToken.Parent.
IsKind
(SyntaxKind.ExternAliasDirective))
431
return nextToken.Parent.
IsKind
(SyntaxKind.ExternAliasDirective) ? 1 : 2;
470
if (token.Parent.
IsKind
(SyntaxKind.PropertyPatternClause))
474
else if (next.Parent.
IsKind
(SyntaxKind.PropertyPatternClause))
530
if (token.Parent.
IsKind
(SyntaxKind.PositionalPatternClause))
534
else if (next.Parent.
IsKind
(SyntaxKind.PositionalPatternClause))
649
if (token.IsKind(SyntaxKind.GreaterThanToken) && token.Parent.
IsKind
(SyntaxKind.TypeArgumentList))
658
token.Parent.
IsKind
(SyntaxKind.FunctionPointerParameterList) &&
666
!token.Parent.
IsKind
(SyntaxKind.EnumDeclaration))
684
if (token.Parent.
IsKind
(SyntaxKind.ConditionalExpression) || token.Parent is TypeSyntax)
695
return !token.Parent.
IsKind
(SyntaxKind.InterpolationFormatClause) &&
696
!token.Parent.
IsKind
(SyntaxKind.XmlPrefix);
701
if (next.Parent.
IsKind
(SyntaxKind.BaseList) ||
702
next.Parent.
IsKind
(SyntaxKind.TypeParameterConstraintClause) ||
715
if (token.IsKind(SyntaxKind.CloseParenToken) && IsWord(next.Kind()) && token.Parent.
IsKind
(SyntaxKind.TupleType) == true)
721
&& (next.Parent.
IsKind
(SyntaxKind.ConditionalExpression)))
728
return !token.Parent.
IsKind
(SyntaxKind.XmlTextAttribute);
733
return !next.Parent.
IsKind
(SyntaxKind.XmlTextAttribute);
738
if (token.Parent.
IsKind
(SyntaxKind.FunctionPointerType))
747
if (token.IsKind(SyntaxKind.AsteriskToken) && next.Parent.
IsKind
(SyntaxKind.FunctionPointerCallingConvention))
759
if (next.Parent.
IsKind
(SyntaxKind.FunctionPointerParameterList) && next.IsKind(SyntaxKind.LessThanToken))
771
case SyntaxKind.CloseBracketToken when token.Parent.
IsKind
(SyntaxKind.FunctionPointerUnmanagedCallingConventionList):
778
if (token.Parent.
IsKind
(SyntaxKind.FunctionPointerCallingConvention) && next.Parent.
IsKind
(SyntaxKind.FunctionPointerUnmanagedCallingConventionList) &&
785
if (next.Parent.
IsKind
(SyntaxKind.FunctionPointerUnmanagedCallingConventionList) && token.Parent.
IsKind
(SyntaxKind.FunctionPointerUnmanagedCallingConventionList))
818
if (token.IsKind(SyntaxKind.LessThanToken) && token.Parent.
IsKind
(SyntaxKind.FunctionPointerParameterList))
825
if (next.IsKind(SyntaxKind.GreaterThanToken) && next.Parent.
IsKind
(SyntaxKind.FunctionPointerParameterList))
849
(next.IsKind(SyntaxKind.IdentifierToken) || next.Parent.
IsKind
(SyntaxKind.IndexerDeclaration)))
896
(!next.IsKind(SyntaxKind.OpenParenToken) || KeywordNeedsSeparatorBeforeOpenParen(token.Kind()) || next.Parent.
IsKind
(SyntaxKind.TupleType)) &&
1321
if (node.Parent.
IsKind
(SyntaxKind.CompilationUnit))
1333
if (node.
IsKind
(SyntaxKind.IfStatement) && node.Parent.
IsKind
(SyntaxKind.ElseClause))
Microsoft.CodeAnalysis.CSharp.CodeStyle (181)
src\Analyzers\CSharp\Analyzers\AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs (4)
268
if (ifStatementOrElseClause.
IsKind
(SyntaxKind.ElseClause))
274
Debug.Assert(ifStatementOrElseClause.
IsKind
(SyntaxKind.IfStatement));
293
if (statement.Statement.
IsKind
(SyntaxKind.Block))
297
if (elseStatement.
IsKind
(SyntaxKind.Block))
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs (3)
84
if (!_assignmentTargetOpt.
IsKind
(SyntaxKind.IdentifierName))
224
case 2 when section.Statements[1].
IsKind
(SyntaxKind.BreakStatement) || section.Statements[0].
IsKind
(SyntaxKind.SwitchStatement):
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionHelpers.cs (2)
15
if (node.
IsKind
(SyntaxKind.DefaultSwitchLabel))
23
if (@case.Pattern.
IsKind
(SyntaxKind.DiscardPattern))
src\Analyzers\CSharp\Analyzers\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessAnalyzer.cs (7)
58
if (!ifStatement.Condition.
IsKind
(SyntaxKind.NotEqualsExpression))
121
if (condition.Left.
IsKind
(SyntaxKind.NullLiteralExpression) ||
122
condition.Right.
IsKind
(SyntaxKind.NullLiteralExpression))
124
var expr = condition.Left.
IsKind
(SyntaxKind.NullLiteralExpression)
227
if (!ifStatement.Parent.
IsKind
(SyntaxKind.Block))
333
=> left.
IsKind
(SyntaxKind.IdentifierName) && right.
IsKind
(SyntaxKind.NullLiteralExpression);
src\Analyzers\CSharp\Analyzers\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementDiagnosticAnalyzer.cs (3)
91
var parentIsElseClause = parent.
IsKind
(SyntaxKind.ElseClause);
97
if (statement.
IsKind
(SyntaxKind.IfStatement) && parentIsElseClause)
109
if (parent.
IsKind
(SyntaxKind.Block))
src\Analyzers\CSharp\Analyzers\QualifyMemberAccess\CSharpQualifyMemberAccessDiagnosticAnalyzer.cs (4)
24
=> node.
IsKind
(SyntaxKind.ThisExpression);
38
if (node.
IsKind
(SyntaxKind.BaseExpression))
62
=> declarationSyntax.
IsKind
(SyntaxKind.PropertyDeclaration) && declarationSyntax.Contains(node);
65
=> declarationSyntax.GetAncestorsOrThis(n => n.
IsKind
(SyntaxKind.FieldDeclaration) && n.Contains(node)).Any();
src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\RemoveUnreachableCodeHelpers.cs (2)
66
if (currentStatement.
IsKind
(SyntaxKind.LabeledStatement))
76
if (currentStatement.
IsKind
(SyntaxKind.LocalFunctionStatement))
src\Analyzers\CSharp\Analyzers\RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (1)
79
!blockOperation.Syntax.
IsKind
(SyntaxKind.Block);
src\Analyzers\CSharp\Analyzers\UseAutoProperty\CSharpUseAutoPropertyAnalyzer.cs (2)
58
if (node.
IsKind
(SyntaxKind.FieldExpression))
181
else if (expression.
IsKind
(SyntaxKind.IdentifierName))
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (1)
1037
if (objectCreation.Initializer.
IsKind
(SyntaxKind.ObjectCreationExpression) && objectCreation.Initializer.Expressions.Count > 0)
src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUseCollectionInitializerAnalyzer.cs (1)
35
=> expression.
IsKind
(SyntaxKind.ComplexElementInitializerExpression);
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyForAccessorsHelper.cs (1)
57
=> declaration.
IsKind
(SyntaxKind.GetAccessorDeclaration);
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyHelper`1.cs (1)
194
if (expressionBody!.Expression.
IsKind
(SyntaxKind.ThrowExpression))
src\Analyzers\CSharp\Analyzers\UseExpressionBodyForLambda\UseExpressionBodyForLambdaHelpers.cs (1)
56
if (expressionBodyOpt.
IsKind
(SyntaxKind.ThrowExpression) &&
src\Analyzers\CSharp\Analyzers\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (1)
101
else if (objectCreation.Parent.
IsKind
(SyntaxKind.ArrowExpressionClause))
src\Analyzers\CSharp\Analyzers\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorDiagnosticAnalyzer.cs (1)
73
right.
IsKind
(SyntaxKind.NullLiteralExpression))
src\Analyzers\CSharp\Analyzers\UseLocalFunction\CSharpUseLocalFunctionDiagnosticAnalyzer.cs (1)
357
if (assignment.Left.
IsKind
(SyntaxKind.IdentifierName))
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs (1)
39
Debug.Assert(localStatement.
IsKind
(SyntaxKind.LocalDeclarationStatement));
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs (3)
338
if (left.
IsKind
(SyntaxKind.NullLiteralExpression))
345
if (right.
IsKind
(SyntaxKind.NullLiteralExpression))
361
&& constantPattern.Expression.
IsKind
(SyntaxKind.NullLiteralExpression)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpIsAndCastCheckDiagnosticAnalyzer.cs (1)
96
var ifStatementScope = ifStatement.Parent.
IsKind
(SyntaxKind.Block)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CodeStyle\TypeStyle\TypeStyleHelper.cs (2)
66
if (initializerExpression.
IsKind
(SyntaxKind.DefaultExpression))
80
!initializerExpression.
IsKind
(SyntaxKind.AnonymousObjectCreationExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (6)
160
if (!simpleName.
IsKind
(SyntaxKind.IdentifierName))
355
if (expression.Parent.
IsKind
(SyntaxKind.AddressOfExpression))
467
if (expression.
IsKind
(SyntaxKind.StackAllocArrayCreationExpression))
515
if (expression.
IsKind
(SyntaxKind.ConditionalAccessExpression))
529
if (expression.
IsKind
(SyntaxKind.IdentifierName) || expression is MemberAccessExpressionSyntax)
555
!parentConditionalAccessExpression.Parent.
IsKind
(SyntaxKind.ConditionalAccessExpression);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (29)
40
var parentExpression = nodeParent.
IsKind
(SyntaxKind.ConstantPattern)
59
if (expression.
IsKind
(SyntaxKind.ParenthesizedExpression) ||
60
parentExpression.
IsKind
(SyntaxKind.ParenthesizedExpression))
89
var opposite = expression.
IsKind
(SyntaxKind.GreaterThanExpression) ? SyntaxKind.LessThanExpression : SyntaxKind.GreaterThanExpression;
95
if (expression.
IsKind
(SyntaxKind.ThrowExpression))
99
if (nodeParent.
IsKind
(SyntaxKind.ExpressionStatement))
103
if (nodeParent.
IsKind
(SyntaxKind.ArrowExpressionClause))
111
if (expression.
IsKind
(SyntaxKind.TupleExpression))
163
if (nodeParent.
IsKind
(SyntaxKind.CastExpression) && expression.
IsKind
(SyntaxKind.ThisExpression))
173
if (nodeParent.
IsKind
(SyntaxKind.Interpolation))
178
if (expression.
IsKind
(SyntaxKind.InterpolatedStringExpression))
234
if (expression.
IsKind
(SyntaxKind.ThisExpression))
238
if (expression.
IsKind
(SyntaxKind.ThrowExpression) &&
246
if (nodeParent.
IsKind
(SyntaxKind.CaseSwitchLabel))
250
if (nodeParent.
IsKind
(SyntaxKind.ConstantPattern) &&
257
if (nodeParent.
IsKind
(SyntaxKind.WhenClause))
271
if (parentExpression.
IsKind
(SyntaxKind.CastExpression) &&
279
if (expression.
IsKind
(SyntaxKind.ConditionalExpression) &&
290
if (expression.
IsKind
(SyntaxKind.ConditionalAccessExpression))
425
if (parentExpression.
IsKind
(SyntaxKind.CoalesceExpression))
518
if (name.
IsKind
(SyntaxKind.AliasQualifiedName))
547
if (binaryExpression.
IsKind
(SyntaxKind.LessThanExpression))
560
else if (binaryExpression.
IsKind
(SyntaxKind.GreaterThanExpression))
575
else if (node.Expression.
IsKind
(SyntaxKind.LessThanExpression))
582
else if (node.Expression.
IsKind
(SyntaxKind.GreaterThanExpression))
624
|| lessThanExpression.Left.
IsKind
(SyntaxKind.CastExpression))
755
if (binaryPattern.
IsKind
(SyntaxKind.AndPattern))
758
if (binaryPattern.
IsKind
(SyntaxKind.OrPattern))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\StatementSyntaxExtensions.cs (2)
40
if (first.Parent.
IsKind
(SyntaxKind.GlobalStatement))
41
return second.Parent.
IsKind
(SyntaxKind.GlobalStatement);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (3)
32
if (node.
IsKind
(kind))
43
=> CodeAnalysis.CSharpExtensions.
IsKind
(node?.Parent, kind);
358
return !current.Parent.
IsKind
(SyntaxKind.CompilationUnit);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (2)
47
token.Parent.
IsKind
(SyntaxKind.ObjectInitializerExpression);
50
=> token.IsKind(SyntaxKind.OpenBraceToken) && token.Parent.
IsKind
(SyntaxKind.AccessorList);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (20)
83
=> token.Kind() == SyntaxKind.OpenParenToken && token.Parent.
IsKind
(SyntaxKind.ParameterList);
86
=> token.Kind() == SyntaxKind.CloseParenToken && token.Parent.
IsKind
(SyntaxKind.ParameterList);
109
if (token.Parent.
IsKind
(SyntaxKind.PositionalPatternClause) && token.Parent.Parent.
IsKind
(SyntaxKind.RecursivePattern))
119
=> token.Kind() == SyntaxKind.ColonToken && token.Parent.
IsKind
(SyntaxKind.BaseList);
125
=> token.Kind() == SyntaxKind.OpenParenToken && token.Parent.
IsKind
(SyntaxKind.ParameterList) && token.Parent.Parent.
IsKind
(SyntaxKind.ParenthesizedLambdaExpression);
178
return token.Parent is ExpressionSyntax || token.Parent.
IsKind
(SyntaxKind.PropertyPatternClause);
210
token.Parent.
IsKind
(SyntaxKind.EnumDeclaration);
278
token.Parent.
IsKind
(SyntaxKind.EqualsValueClause) &&
279
token.Parent.Parent.
IsKind
(SyntaxKind.PropertyDeclaration);
305
=> token.IsDotInMemberAccess() || (token.Kind() == SyntaxKind.DotToken && token.Parent.
IsKind
(SyntaxKind.QualifiedName));
337
=> token.Kind() == SyntaxKind.ColonToken && token.Parent.
IsKind
(SyntaxKind.SwitchExpressionArm);
340
=> token.Kind() == SyntaxKind.CommaToken && token.Parent.
IsKind
(SyntaxKind.SwitchExpression);
343
=> token.Kind() == SyntaxKind.CommaToken && token.Parent.
IsKind
(SyntaxKind.PropertyPatternClause);
433
parent.
IsKind
(SyntaxKind.SimpleAssignmentExpression))
452
parent.
IsKind
(SyntaxKind.SimpleAssignmentExpression))
521
=> currentToken.Parent.
IsKind
(SyntaxKind.Interpolation);
539
currentToken.Parent.
IsKind
(SyntaxKind.TupleExpression);
543
=> token.Kind() == SyntaxKind.CommaToken && token.Parent.
IsKind
(SyntaxKind.CollectionExpression);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\AnchorIndentationFormattingRule.cs (1)
25
if (node.
IsKind
(SyntaxKind.AnonymousMethodExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\BaseFormattingRule.cs (1)
184
else if (node.
IsKind
(SyntaxKind.PropertyPatternClause))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (11)
116
currentToken.Parent.
IsKind
(SyntaxKind.TypeParameterConstraintClause))
131
firstTokenAfterTypeConstraint.Parent.
IsKind
(SyntaxKind.TypeParameterConstraintClause))
373
if ((currentToken.Kind() == SyntaxKind.FromKeyword && currentToken.Parent.
IsKind
(SyntaxKind.FromClause)) ||
374
(currentToken.Kind() == SyntaxKind.LetKeyword && currentToken.Parent.
IsKind
(SyntaxKind.LetClause)) ||
375
(currentToken.Kind() == SyntaxKind.WhereKeyword && currentToken.Parent.
IsKind
(SyntaxKind.WhereClause)) ||
376
(currentToken.Kind() == SyntaxKind.JoinKeyword && currentToken.Parent.
IsKind
(SyntaxKind.JoinClause)) ||
377
(currentToken.Kind() == SyntaxKind.JoinKeyword && currentToken.Parent.
IsKind
(SyntaxKind.JoinIntoClause)) ||
378
(currentToken.Kind() == SyntaxKind.OrderByKeyword && currentToken.Parent.
IsKind
(SyntaxKind.OrderByClause)) ||
379
(currentToken.Kind() == SyntaxKind.SelectKeyword && currentToken.Parent.
IsKind
(SyntaxKind.SelectClause)) ||
380
(currentToken.Kind() == SyntaxKind.GroupKeyword && currentToken.Parent.
IsKind
(SyntaxKind.GroupClause)))
438
nextToken.Parent.
IsKind
(SyntaxKind.DoStatement))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (2)
233
if (node.
IsKind
(SyntaxKind.ArrayInitializerExpression) && node.Parent != null && node.Parent.
IsKind
(SyntaxKind.ArrayCreationExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\NewLineUserSettingFormattingRule.cs (13)
44
if (node.
IsKind
(SyntaxKind.SwitchStatement))
121
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.Parent.
IsKind
(SyntaxKind.AnonymousObjectCreationExpression))
143
else if (currentToken.Parent.
IsKind
(SyntaxKind.PropertyPatternClause))
189
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentTokenParentParent.
IsKind
(SyntaxKind.AnonymousMethodExpression))
198
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentTokenParentParent.
IsKind
(SyntaxKind.LocalFunctionStatement))
217
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.Parent.
IsKind
(SyntaxKind.SwitchExpression))
246
if (previousToken.IsKind(SyntaxKind.CommaToken) && previousToken.Parent.
IsKind
(SyntaxKind.ObjectInitializerExpression))
260
if (previousToken.IsKind(SyntaxKind.CommaToken) && previousToken.Parent.
IsKind
(SyntaxKind.AnonymousObjectCreationExpression))
327
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.Parent.
IsKind
(SyntaxKind.AnonymousObjectCreationExpression))
399
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentTokenParentParent.
IsKind
(SyntaxKind.AnonymousMethodExpression))
412
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentTokenParentParent.
IsKind
(SyntaxKind.LocalFunctionStatement))
439
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.Parent.
IsKind
(SyntaxKind.SwitchExpression))
468
&& (previousToken.Parent is StatementSyntax && !previousToken.Parent.
IsKind
(SyntaxKind.ForStatement))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SpacingFormattingRule.cs (4)
92
if (previousToken.Parent.
IsKind
(SyntaxKind.OperatorDeclaration) && currentToken.IsOpenParenInParameterListOfAOperationDeclaration())
249
if (previousKind == SyntaxKind.CloseBracketToken && previousToken.Parent.
IsKind
(SyntaxKind.AttributeList))
253
currentToken.Parent.
IsKind
(SyntaxKind.AttributeList))
458
if (previousToken.Parent.
IsKind
(SyntaxKind.NotPattern))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (2)
80
if (node.
IsKind
(SyntaxKind.SwitchExpressionArm))
88
if (node.
IsKind
(SyntaxKind.SwitchExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\TokenBasedFormattingRule.cs (5)
175
if (previousToken.Kind() == SyntaxKind.DoKeyword && previousToken.Parent.
IsKind
(SyntaxKind.DoStatement))
288
previousToken.Parent.
IsKind
(SyntaxKind.AttributeList) &&
453
if (currentToken.IsKind(SyntaxKind.QuestionToken) && currentToken.Parent.
IsKind
(SyntaxKind.ConditionalAccessExpression))
474
currentToken.Parent.
IsKind
(SyntaxKind.SuppressNullableWarningExpression))
521
&& !previousToken.Parent.
IsKind
(SyntaxKind.SuppressNullableWarningExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\WrappingFormattingRule.cs (1)
74
if (embeddedStatement.
IsKind
(SyntaxKind.Block))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (1)
74
endToken.Parent.
IsKind
(SyntaxKind.Block) &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (3)
323
=> node?.Parent.
IsKind
(SyntaxKind.FieldDeclaration) ?? false;
326
=> node?.Parent.
IsKind
(SyntaxKind.EventFieldDeclaration) ?? false;
329
=> node?.Parent.
IsKind
(SyntaxKind.LocalDeclarationStatement) ?? false;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpBlockFacts.cs (1)
23
=> node.
IsKind
(SyntaxKind.Block);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (10)
521
if (token.Kind() == SyntaxKind.CommaToken && token.Parent.
IsKind
(SyntaxKind.OrderByClause))
527
&& token.Parent.
IsKind
(SyntaxKind.CollectionExpression))
555
=> simpleName.
IsKind
(SyntaxKind.GenericName) ||
587
=> node.
IsKind
(SyntaxKind.BaseList);
599
=> node.
IsKind
(SyntaxKind.Argument);
602
=> node.
IsKind
(SyntaxKind.AttributeArgument);
635
=> node.
IsKind
(SyntaxKind.IdentifierName) &&
690
=> node.
IsKind
(SyntaxKind.ElementAccessExpression);
1241
=> node.
IsKind
(SyntaxKind.Attribute) &&
1299
exprStatement.Expression.
IsKind
(SyntaxKind.SimpleAssignmentExpression);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\CSharpInferredMemberNameSimplifier.cs (1)
16
if (node.NameColon == null || !node.Parent.
IsKind
(SyntaxKind.TupleExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (4)
179
var isDefaultLiteralCast = castedExpressionNode.WalkDownParentheses().
IsKind
(SyntaxKind.DefaultLiteralExpression);
326
var isNullLiteralCast = castedExpressionNode.WalkDownParentheses().
IsKind
(SyntaxKind.NullLiteralExpression);
814
if (originalConditionalExpression.WhenTrue.WalkDownParentheses().
IsKind
(SyntaxKind.DefaultLiteralExpression) ||
815
originalConditionalExpression.WhenFalse.WalkDownParentheses().
IsKind
(SyntaxKind.DefaultLiteralExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
349
(previousToken.Parent.
IsKind
(SyntaxKind.Block) ||
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (10)
303
if (expression.WalkDownParentheses().
IsKind
(SyntaxKind.DefaultLiteralExpression))
621
if (result.
IsKind
(SyntaxKind.SimpleMemberAccessExpression))
632
if (result.
IsKind
(SyntaxKind.SimpleMemberAccessExpression))
663
=> node.
IsKind
(SyntaxKind.ParenthesizedExpression);
773
if (newExpression.
IsKind
(SyntaxKind.ConditionalExpression) &&
783
if (newExpression.
IsKind
(SyntaxKind.SwitchExpression) &&
793
if (newExpression.
IsKind
(SyntaxKind.CollectionExpression) &&
802
if (newExpression.
IsKind
(SyntaxKind.TupleExpression) &&
818
if (originalExpression.
IsKind
(SyntaxKind.ConditionalExpression) &&
819
newExpression.
IsKind
(SyntaxKind.ConditionalExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseExplicitTypeHelper.cs (1)
73
declExpression.Designation.
IsKind
(SyntaxKind.ParenthesizedVariableDesignation))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (4)
133
if (!variableDeclaration.Type.
IsKind
(SyntaxKind.PointerType))
137
.Any(node => node.
IsKind
(SyntaxKind.StackAllocArrayCreationExpression));
281
if (expression.
IsKind
(SyntaxKind.NullLiteralExpression))
287
if (expression.
IsKind
(SyntaxKind.ImplicitObjectCreationExpression))
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (87)
src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (4)
55
if (node.
IsKind
(SyntaxKind.VariableDeclarator) && node.Parent?.Parent?.
IsKind
(SyntaxKind.EventFieldDeclaration) == false)
86
if (node.
IsKind
(SyntaxKind.VariableDeclarator) && !(node = node.Parent?.Parent).
IsKind
(SyntaxKind.EventFieldDeclaration))
src\Analyzers\CSharp\CodeFixes\AddParameter\CSharpAddParameterCodeFixProvider.cs (1)
60
if (constructorInitializer.
IsKind
(SyntaxKind.BaseConstructorInitializer))
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (1)
208
Debug.Assert(!statements[0].
IsKind
(SyntaxKind.BreakStatement));
src\Analyzers\CSharp\CodeFixes\ConvertToAsync\CSharpConvertToAsyncMethodCodeFixProvider.cs (1)
65
var invocationExpression = node.ChildNodes().FirstOrDefault(n => n.
IsKind
(SyntaxKind.InvocationExpression));
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (1)
700
if (docComment.
IsKind
(SyntaxKind.SingleLineDocumentationCommentTrivia))
src\Analyzers\CSharp\CodeFixes\GenerateConstructor\CSharpGenerateConstructorService.cs (2)
60
typeToGenerateIn = constructorInitializer.
IsKind
(SyntaxKind.ThisConstructorInitializer)
191
constructorDeclarationSyntax.Initializer.
IsKind
(SyntaxKind.ThisConstructorInitializer))
src\Analyzers\CSharp\CodeFixes\GenerateParameterizedMember\CSharpGenerateMethodService.cs (1)
126
else if (simpleName.
IsKind
(SyntaxKind.IdentifierName))
src\Analyzers\CSharp\CodeFixes\GenerateVariable\CSharpGenerateVariableCodeFixProvider.cs (2)
45
if (node.
IsKind
(SyntaxKind.MemberBindingExpression))
47
var nameNode = node.ChildNodes().FirstOrDefault(n => n.
IsKind
(SyntaxKind.IdentifierName));
src\Analyzers\CSharp\CodeFixes\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessCodeFixProvider.cs (1)
102
if (ifStatement.Parent.
IsKind
(SyntaxKind.ElseClause) &&
src\Analyzers\CSharp\CodeFixes\MakeMemberStatic\CSharpMakeMemberStaticCodeFixProvider.cs (1)
31
if (node.
IsKind
(SyntaxKind.VariableDeclarator) && node.Parent is VariableDeclarationSyntax { Parent: FieldDeclarationSyntax or EventFieldDeclarationSyntax })
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (1)
67
if (node.
IsKind
(SyntaxKind.ConditionalAccessExpression))
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (3)
94
if (newNameNode.
IsKind
(SyntaxKind.DiscardDesignation))
213
if (originalCompoundAssignment.Parent.
IsKind
(SyntaxKind.ExpressionStatement))
215
if (!originalCompoundAssignment.
IsKind
(SyntaxKind.CoalesceAssignmentExpression))
src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs (2)
75
if (binary.
IsKind
(SyntaxKind.EqualsExpression))
95
=> binary.Right.
IsKind
(SyntaxKind.NullLiteralExpression)
src\Analyzers\CSharp\CodeFixes\UsePatternCombinators\CSharpUsePatternCombinatorsCodeFixProvider.cs (2)
117
if (expr.
IsKind
(SyntaxKind.DefaultLiteralExpression))
121
if (expr.
IsKind
(SyntaxKind.NullLiteralExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (1)
509
var insertionIndex = compilationUnit.Members.LastIndexOf(memberDeclaration => memberDeclaration.
IsKind
(SyntaxKind.GlobalStatement)) + 1;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\PropertyGenerator.cs (1)
166
if (accessor.
IsKind
(SyntaxKind.GetAccessorDeclaration))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (20)
115
case SyntaxKind.OpenBraceToken when token.Parent.
IsKind
(SyntaxKind.Block):
124
if (token.Parent.
IsKind
(SyntaxKind.Block))
148
if (token.Parent.
IsKind
(SyntaxKind.SwitchStatement))
158
case SyntaxKind.DoKeyword when token.Parent.
IsKind
(SyntaxKind.DoStatement):
174
return token.Parent.
IsKind
(SyntaxKind.ElseClause);
177
if (token.Parent.
IsKind
(SyntaxKind.AttributeList))
259
if (token.Parent.
IsKind
(SyntaxKind.AttributeList))
274
if (token.Parent.
IsKind
(SyntaxKind.CastExpression))
334
targetToken.Parent.
IsKind
(SyntaxKind.ParenthesizedExpression))
396
targetToken.Parent.
IsKind
(SyntaxKind.SwitchStatement))
450
targetToken.Parent.
IsKind
(SyntaxKind.NameColon) &&
451
targetToken.Parent.Parent.
IsKind
(SyntaxKind.Argument) &&
452
targetToken.Parent.Parent.Parent.
IsKind
(SyntaxKind.ArgumentList))
468
if (targetToken.Parent.
IsKind
(SyntaxKind.ArgumentList))
582
targetToken.Parent.
IsKind
(SyntaxKind.AccessorList))
590
targetToken.Parent.
IsKind
(SyntaxKind.Block) &&
605
targetToken.Parent.
IsKind
(SyntaxKind.AttributeList) &&
616
if (node.
IsKind
(SyntaxKind.TypeParameterList))
650
targetToken.Parent.
IsKind
(SyntaxKind.AttributeList) &&
651
targetToken.Parent.Parent.
IsKind
(SyntaxKind.TypeParameter) &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (32)
207
token.Parent.
IsKind
(SyntaxKind.Block) &&
220
token.Parent.
IsKind
(SyntaxKind.AttributeList))
482
else if (token.Parent.
IsKind
(SyntaxKind.NamespaceDeclaration))
491
token.Parent.
IsKind
(SyntaxKind.Block) &&
507
token.Parent.
IsKind
(SyntaxKind.AttributeList))
601
return incompleteMember.Type.
IsKind
(SyntaxKind.RefType);
941
return token.Parent.
IsKind
(SyntaxKind.FunctionPointerParameterList);
955
=> targetToken.Parent.
IsKind
(SyntaxKind.TypeParameterConstraintClause) &&
1158
return token.Parent.
IsKind
(SyntaxKind.BracketedParameterList);
1171
token.Parent.
IsKind
(SyntaxKind.DelegateDeclaration))
1230
if (token.Parent.
IsKind
(SyntaxKind.ParameterList) &&
1265
else if (token.IsKind(SyntaxKind.ScopedKeyword) && token.Parent.
IsKind
(SyntaxKind.Parameter))
1269
else if (token.IsKind(SyntaxKind.IdentifierToken) && token.Text == "scoped" && token.Parent is IdentifierNameSyntax scopedIdentifierName && scopedIdentifierName.Parent.
IsKind
(SyntaxKind.Parameter))
1278
return parent.
IsKind
(SyntaxKind.ParameterList) && parent.IsParentKind(SyntaxKind.AnonymousMethodExpression);
1349
leftToken.Parent.
IsKind
(SyntaxKind.IdentifierName) &&
1376
if (leftToken.Parent.
IsKind
(SyntaxKind.ParenthesizedPattern))
1391
if (leftToken.Kind() is SyntaxKind.OpenBraceToken or SyntaxKind.CommaToken && leftToken.Parent.
IsKind
(SyntaxKind.SwitchExpression))
1398
if (leftToken.Kind() is SyntaxKind.OpenParenToken or SyntaxKind.CommaToken && leftToken.Parent.
IsKind
(SyntaxKind.PositionalPatternClause))
1405
if (leftToken.Kind() is SyntaxKind.OpenBracketToken or SyntaxKind.CommaToken && leftToken.Parent.
IsKind
(SyntaxKind.ListPattern))
1412
if (leftToken.IsKind(SyntaxKind.DotDotToken) && leftToken.Parent.
IsKind
(SyntaxKind.SlicePattern))
1438
if (leftToken.IsKind(SyntaxKind.NotKeyword) && leftToken.Parent.
IsKind
(SyntaxKind.NotPattern))
1448
leftToken.Parent.
IsKind
(SyntaxKind.RelationalPattern))
1583
if (possibleCommaOrParen.Parent.
IsKind
(SyntaxKind.ParameterList) &&
1673
if (node.Parent.
IsKind
(SyntaxKind.ParenthesizedExpression))
1679
if (node.Parent.
IsKind
(SyntaxKind.Argument) && node.Parent.Parent.
IsKind
(SyntaxKind.TupleExpression))
1692
leftToken.Parent.
IsKind
(SyntaxKind.ArgumentList) &&
2049
token.Parent.
IsKind
(SyntaxKind.CastExpression))
2865
token.Parent.
IsKind
(SyntaxKind.IdentifierName) &&
2873
token.Parent.
IsKind
(SyntaxKind.IdentifierName))
2980
token.Parent.
IsKind
(SyntaxKind.CatchDeclaration))
2996
targetToken.Parent.
IsKind
(SyntaxKind.BaseList) &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ExpressionSyntaxExtensions.cs (2)
30
if (expression.
IsKind
(SyntaxKind.RefExpression))
44
if (expression.
IsKind
(SyntaxKind.ThrowExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (2)
126
node.
IsKind
(SyntaxKind.Interpolation))
133
!argument.Parent.
IsKind
(SyntaxKind.ThisConstructorInitializer) &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (4)
179
(token.IsKind(SyntaxKind.CloseBraceToken) && token.Parent.
IsKind
(SyntaxKind.Interpolation)))
251
if (token.Parent.
IsKind
(SyntaxKind.AccessorList) &&
252
token.Parent.Parent.
IsKind
(SyntaxKind.PropertyDeclaration))
307
if (token.Parent.
IsKind
(SyntaxKind.ArgumentList))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (2)
1287
if (initializerExpression.
IsKind
(SyntaxKind.ComplexElementInitializerExpression))
1307
else if (initializerExpression.
IsKind
(SyntaxKind.CollectionInitializerExpression))
Microsoft.CodeAnalysis.CSharp.EditorFeatures (4)
CompleteStatement\CompleteStatementCommandHandler.cs (3)
233
else if (currentNode.
IsKind
(SyntaxKind.DoStatement))
263
if (currentNode.
IsKind
(SyntaxKind.EqualsValueClause) && currentNode.IsParentKind(SyntaxKind.PropertyDeclaration))
491
else if (currentNode.
IsKind
(SyntaxKind.Utf8StringLiteralExpression))
Interactive\CSharpSendToInteractiveSubmissionProvider.cs (1)
115
|| node.
IsKind
(SyntaxKind.UsingDirective);
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (2)
CodeGen\CodeGenFunctionPointersTests.cs (2)
3339
var declarators = syntaxTree.GetRoot().DescendantNodes().OfType<VariableDeclaratorSyntax>().Where(d => d.Initializer!.Value.
IsKind
(SyntaxKind.AddressOfExpression)).ToArray();
4921
.Where(l => l.
IsKind
(SyntaxKind.DefaultLiteralExpression))
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (1)
Emit\EditAndContinue\EditAndContinueTestBase.cs (1)
74
if (newNode.
IsKind
(kind))
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (3)
Diagnostics\GetDiagnosticsTests.cs (2)
1636
AssertEx.All(analyzer.AnalyzedSyntaxNodes, node => node.
IsKind
(SyntaxKind.LocalDeclarationStatement));
1640
AssertEx.All(analyzer.AnalyzedSyntaxNodesInsideCodeBlock, node => node.
IsKind
(SyntaxKind.LocalDeclarationStatement));
Semantics\PatternMatchingTests_ListPatterns.cs (1)
3677
.Where(p => p.
IsKind
(SyntaxKind.PropertyPatternClause));
Microsoft.CodeAnalysis.CSharp.Features (174)
AddImport\CSharpAddImportFeatureService.cs (3)
68
else if (node.Parent.
IsKind
(SyntaxKind.CollectionInitializerExpression))
608
if (expression.
IsKind
(SyntaxKind.CollectionInitializerExpression))
626
if (node.Parent.
IsKind
(SyntaxKind.CollectionInitializerExpression))
BraceCompletion\BracketBraceCompletionService.cs (1)
49
if (currentToken.IsKind(SyntaxKind.OpenBracketToken) && currentToken.Parent.
IsKind
(SyntaxKind.ListPattern))
BraceCompletion\CurlyBraceCompletionService.cs (4)
48
=> token.IsKind(SyntaxKind.OpenBraceToken) && !token.Parent.
IsKind
(SyntaxKind.Interpolation);
159
if (currentTokenParentParent.
IsKind
(SyntaxKind.AnonymousMethodExpression))
165
if (currentToken.Parent.
IsKind
(SyntaxKind.AnonymousObjectCreationExpression))
201
if (node.
IsKind
(SyntaxKind.SwitchStatement))
BraceCompletion\InterpolationBraceCompletionService.cs (1)
42
=> token.IsKind(SyntaxKind.OpenBraceToken) && token.Parent.
IsKind
(SyntaxKind.Interpolation);
CodeLens\CSharpCodeLensDisplayInfoService.cs (2)
96
if (node.Parent.
IsKind
(SyntaxKind.AccessorList) &&
97
node.Parent.Parent.
IsKind
(SyntaxKind.IndexerDeclaration))
CodeRefactorings\EnableNullable\EnableNullableCodeRefactoringProvider.cs (3)
27
directive => directive.
IsKind
(SyntaxKind.NullableDirectiveTrivia);
225
if (firstToken.IsKind(SyntaxKind.HashToken) && firstToken.Parent.
IsKind
(SyntaxKind.RegionDirectiveTrivia))
230
if (nextToken.IsKind(SyntaxKind.HashToken) && nextToken.Parent.
IsKind
(SyntaxKind.EndRegionDirectiveTrivia))
CodeRefactorings\InlineMethod\CSharpInlineMethodRefactoringProvider.cs (4)
66
=> node.
IsKind
(SyntaxKind.FieldDeclaration);
88
return expressionNode.
IsKind
(SyntaxKind.InvocationExpression)
117
var parent => parent.
IsKind
(SyntaxKind.ArrowExpressionClause),
134
(whenNotNull.
IsKind
(SyntaxKind.InvocationExpression) || IsNullConditionalInvocationExpression(whenNotNull));
CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.cs (4)
276
while (scope.
IsKind
(SyntaxKind.LabeledStatement))
282
if (scope.
IsKind
(SyntaxKind.GlobalStatement))
440
while (parent.
IsKind
(SyntaxKind.Argument))
443
if (!parent.
IsKind
(SyntaxKind.TupleExpression))
CodeRefactorings\UseRecursivePatterns\UseRecursivePatternsCodeRefactoringProvider.cs (1)
558
when canConvertToSubpattern(name, arg) && !memberAccess.Expression.
IsKind
(SyntaxKind.BaseExpression):
Completion\CompletionProviders\CrefCompletionProvider.cs (4)
122
token.Parent.
IsKind
(SyntaxKind.XmlCrefAttribute);
141
token.Parent.
IsKind
(SyntaxKind.CrefParameterList))
147
token.Parent.
IsKind
(SyntaxKind.CrefBracketedParameterList))
161
&& token.Parent.
IsKind
(SyntaxKind.QualifiedCref);
Completion\CompletionProviders\CSharpSuggestionModeCompletionProvider.cs (2)
113
if (token.IsKind(SyntaxKind.NewKeyword) && token.Parent.
IsKind
(SyntaxKind.ObjectCreationExpression))
174
if (token.Kind() is SyntaxKind.OpenParenToken or SyntaxKind.CommaToken && token.Parent.
IsKind
(SyntaxKind.ArgumentList)
Completion\CompletionProviders\DeclarationName\DeclarationNameInfo.cs (3)
139
token.Parent.
IsKind
(SyntaxKind.IdentifierName))
419
token.Parent.
IsKind
(SyntaxKind.TypeParameterList))
505
token.Parent.
IsKind
(SyntaxKind.PredefinedType);
Completion\CompletionProviders\ObjectAndWithInitializerCompletionProvider.cs (1)
157
if (parent.
IsKind
(SyntaxKind.SimpleAssignmentExpression))
Completion\CompletionProviders\PropertySubPatternCompletionProvider.cs (1)
200
while (memberAccess.Parent.
IsKind
(SyntaxKind.SimpleMemberAccessExpression))
Completion\CompletionProviders\XmlDocCommentCompletionProvider.cs (2)
231
if (token.IsKind(SyntaxKind.IdentifierToken) && token.Parent.
IsKind
(SyntaxKind.XmlName))
293
if (token.Parent.
IsKind
(SyntaxKind.IdentifierName) &&
Completion\KeywordRecommenders\ExternKeywordRecommender.cs (3)
91
token.Parent.
IsKind
(SyntaxKind.NamespaceDeclaration))
99
token.Parent.
IsKind
(SyntaxKind.FileScopedNamespaceDeclaration))
107
token.Parent.
IsKind
(SyntaxKind.ExternAliasDirective))
Completion\KeywordRecommenders\NamespaceKeywordRecommender.cs (5)
105
token.Parent.
IsKind
(SyntaxKind.NamespaceDeclaration))
118
!token.Parent.Parent.
IsKind
(SyntaxKind.FileScopedNamespaceDeclaration))
133
else if (token.Parent.
IsKind
(SyntaxKind.NamespaceDeclaration))
144
if (token.Parent.
IsKind
(SyntaxKind.DelegateDeclaration) &&
155
token.Parent.
IsKind
(SyntaxKind.AttributeList) &&
Completion\KeywordRecommenders\ParamKeywordRecommender.cs (1)
29
token.Parent.
IsKind
(SyntaxKind.AttributeList))
Completion\KeywordRecommenders\TypeVarKeywordRecommender.cs (1)
24
token.Parent.
IsKind
(SyntaxKind.AttributeList))
Completion\KeywordRecommenders\UsingKeywordRecommender.cs (2)
103
if ((token.Kind() == SyntaxKind.OpenBraceToken && token.Parent.
IsKind
(SyntaxKind.NamespaceDeclaration))
104
|| (token.Kind() == SyntaxKind.SemicolonToken && token.Parent.
IsKind
(SyntaxKind.FileScopedNamespaceDeclaration)))
Completion\KeywordRecommenders\VoidKeywordRecommender.cs (1)
76
token.Parent.
IsKind
(SyntaxKind.ParenthesizedExpression))
Completion\KeywordRecommenders\WhereKeywordRecommender.cs (2)
58
token.Parent.
IsKind
(SyntaxKind.ParameterList) &&
71
token.Parent.
IsKind
(SyntaxKind.ParameterList))
Completion\KeywordRecommenders\WhileKeywordRecommender.cs (1)
41
token.Parent.
IsKind
(SyntaxKind.Block) &&
ConvertAutoPropertyToFullProperty\CSharpConvertAutoPropertyToFullPropertyCodeRefactoringProvider.cs (1)
75
=> (accessorListSyntax.Accessors.FirstOrDefault(a => a.
IsKind
(SyntaxKind.GetAccessorDeclaration)),
ConvertCast\CSharpConvertTryCastToDirectCastCodeRefactoringProvider.cs (1)
59
if (expression.
IsKind
(SyntaxKind.NullLiteralExpression) && nullableContext.HasFlag(NullableContext.AnnotationsEnabled) && isReferenceType)
ConvertIfToSwitch\CSharpConvertIfToSwitchCodeRefactoringProvider.Analyzer.cs (1)
32
=> !operation.SemanticModel.AnalyzeControlFlow(operation.Syntax).ExitPoints.Any(static n => n.
IsKind
(SyntaxKind.BreakStatement));
Debugging\CSharpProximityExpressionsService.Worker.cs (1)
220
var statementAncestor = _parentStatement.Ancestors().OfType<StatementSyntax>().FirstOrDefault(node => !node.
IsKind
(SyntaxKind.Block));
Diagnostics\Analyzers\CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs (1)
90
if (node is MemberAccessExpressionSyntax memberAccess && memberAccess.Expression.
IsKind
(SyntaxKind.ThisExpression))
Diagnostics\Analyzers\TypeSyntaxSimplifierWalker.cs (4)
149
if (node.
IsKind
(SyntaxKind.QualifiedName) && TrySimplify(node))
166
if (node.
IsKind
(SyntaxKind.AliasQualifiedName) && TrySimplify(node))
238
if (node.
IsKind
(SyntaxKind.SimpleMemberAccessExpression) && TrySimplify(node))
260
if (node.
IsKind
(SyntaxKind.QualifiedCref) && TrySimplify(node))
EditAndContinue\BreakpointSpans.cs (1)
201
var baseInitializer = (PrimaryConstructorBaseTypeSyntax?)typeDeclaration.BaseList?.Types.FirstOrDefault(t => t.
IsKind
(SyntaxKind.PrimaryConstructorBaseType));
EditAndContinue\SyntaxComparer.cs (4)
245
if (node != null && node.Parent.
IsKind
(SyntaxKind.ForStatement) && node is ExpressionSyntax)
467
if (node == null || node.Parent.
IsKind
(SyntaxKind.QueryExpression))
1040
leftBlock.Parent.
IsKind
(SyntaxKind.ConstructorDeclaration) ||
1041
rightBlock.Parent.
IsKind
(SyntaxKind.ConstructorDeclaration))
EditAndContinue\SyntaxUtilities.cs (2)
161
var firstGetter = accessorList?.Accessors.Where(a => a.
IsKind
(SyntaxKind.GetAccessorDeclaration)).FirstOrDefault();
215
if (declaration.
IsKind
(SyntaxKind.ArrowExpressionClause))
ExtractMethod\CSharpSelectionResult.ExpressionResult.cs (1)
106
if ((!node.
IsKind
(SyntaxKind.ObjectCreationExpression) && semanticModel.GetMemberGroup(expression).Length > 0) ||
GenerateMember\GenerateVariable\CSharpGenerateVariableService.cs (2)
136
if (identifierName.
IsKind
(SyntaxKind.GenericName))
158
return parsedType.
IsKind
(SyntaxKind.GenericName) && !parsedType.ContainsDiagnostics;
GenerateType\CSharpGenerateTypeService.cs (3)
220
if (nameOrMemberAccessExpression == null || !nameOrMemberAccessExpression.
IsKind
(SyntaxKind.SimpleMemberAccessExpression) || !simpleName.IsRightSideOfDot())
338
if ((nameOrMemberAccessExpression.
IsKind
(SyntaxKind.SimpleMemberAccessExpression) || (nameOrMemberAccessExpression.Parent != null && nameOrMemberAccessExpression.IsParentKind(SyntaxKind.SimpleMemberAccessExpression)))
343
if (nameOrMemberAccessExpression.
IsKind
(SyntaxKind.SimpleMemberAccessExpression))
IntroduceVariable\CSharpIntroduceLocalForExpressionCodeRefactoringProvider.cs (1)
48
expressionStatement.Expression.
IsKind
(SyntaxKind.IdentifierName))
IntroduceVariable\CSharpIntroduceVariableService.cs (4)
69
if (node.
IsKind
(SyntaxKind.Block))
73
else if (node.
IsKind
(SyntaxKind.ArrowExpressionClause))
120
if (expression.
IsKind
(SyntaxKind.NullLiteralExpression))
126
if (expression.
IsKind
(SyntaxKind.ThrowExpression))
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (2)
386
var localFunctions = innermostCommonBlock.DescendantNodes().Where(node => node.
IsKind
(SyntaxKind.LocalFunctionStatement) && matches.Any(match => match.Span.OverlapsWith(node.Span)));
398
!invocationExpression.Expression.
IsKind
(SyntaxKind.SimpleMemberAccessExpression) &&
LanguageServices\CSharpSymbolDisplayService.SymbolDescriptionBuilder.cs (1)
199
if (syntax.
IsKind
(SyntaxKind.LocalFunctionStatement) || syntax is AnonymousFunctionExpressionSyntax)
QuickInfo\CSharpSemanticQuickInfoProvider.cs (3)
45
else if (token.IsKind(SyntaxKind.DelegateKeyword) && token.Parent.
IsKind
(SyntaxKind.AnonymousMethodExpression))
59
token.Parent?.Parent.
IsKind
(SyntaxKind.ElementAccessExpression) == true)
83
=> !token.Parent.
IsKind
(SyntaxKind.XmlCrefAttribute);
QuickInfo\CSharpSyntacticQuickInfoProvider.cs (1)
97
=> node.
IsKind
(SyntaxKind.Block)
Rename\CSharpRenameIssuesService.cs (1)
59
if (parent.
IsKind
(SyntaxKind.IdentifierName))
SignatureHelp\ElementAccessExpressionSignatureHelpProvider.cs (1)
67
expression.
IsKind
(SyntaxKind.NullableType) &&
SignatureHelp\InvocationExpressionSignatureHelpProviderBase_MethodGroup.cs (1)
65
(throughExpression.
IsKind
(SyntaxKind.IdentifierName) &&
SplitOrMergeIfStatements\CSharpIfLikeStatementGenerator.cs (1)
171
if (statement.
IsKind
(SyntaxKind.IfStatement))
SplitStringLiteral\StringSplitter.cs (1)
73
token.Parent.
IsKind
(SyntaxKind.Interpolation) &&
src\Analyzers\CSharp\Analyzers\AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs (4)
268
if (ifStatementOrElseClause.
IsKind
(SyntaxKind.ElseClause))
274
Debug.Assert(ifStatementOrElseClause.
IsKind
(SyntaxKind.IfStatement));
293
if (statement.Statement.
IsKind
(SyntaxKind.Block))
297
if (elseStatement.
IsKind
(SyntaxKind.Block))
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs (3)
84
if (!_assignmentTargetOpt.
IsKind
(SyntaxKind.IdentifierName))
224
case 2 when section.Statements[1].
IsKind
(SyntaxKind.BreakStatement) || section.Statements[0].
IsKind
(SyntaxKind.SwitchStatement):
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionHelpers.cs (2)
15
if (node.
IsKind
(SyntaxKind.DefaultSwitchLabel))
23
if (@case.Pattern.
IsKind
(SyntaxKind.DiscardPattern))
src\Analyzers\CSharp\Analyzers\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessAnalyzer.cs (7)
58
if (!ifStatement.Condition.
IsKind
(SyntaxKind.NotEqualsExpression))
121
if (condition.Left.
IsKind
(SyntaxKind.NullLiteralExpression) ||
122
condition.Right.
IsKind
(SyntaxKind.NullLiteralExpression))
124
var expr = condition.Left.
IsKind
(SyntaxKind.NullLiteralExpression)
227
if (!ifStatement.Parent.
IsKind
(SyntaxKind.Block))
333
=> left.
IsKind
(SyntaxKind.IdentifierName) && right.
IsKind
(SyntaxKind.NullLiteralExpression);
src\Analyzers\CSharp\Analyzers\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementDiagnosticAnalyzer.cs (3)
91
var parentIsElseClause = parent.
IsKind
(SyntaxKind.ElseClause);
97
if (statement.
IsKind
(SyntaxKind.IfStatement) && parentIsElseClause)
109
if (parent.
IsKind
(SyntaxKind.Block))
src\Analyzers\CSharp\Analyzers\QualifyMemberAccess\CSharpQualifyMemberAccessDiagnosticAnalyzer.cs (3)
24
=> node.
IsKind
(SyntaxKind.ThisExpression);
38
if (node.
IsKind
(SyntaxKind.BaseExpression))
62
=> declarationSyntax.
IsKind
(SyntaxKind.PropertyDeclaration) && declarationSyntax.Contains(node);
src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\RemoveUnreachableCodeHelpers.cs (2)
66
if (currentStatement.
IsKind
(SyntaxKind.LabeledStatement))
76
if (currentStatement.
IsKind
(SyntaxKind.LocalFunctionStatement))
src\Analyzers\CSharp\Analyzers\RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs (1)
79
!blockOperation.Syntax.
IsKind
(SyntaxKind.Block);
src\Analyzers\CSharp\Analyzers\UseAutoProperty\CSharpUseAutoPropertyAnalyzer.cs (2)
58
if (node.
IsKind
(SyntaxKind.FieldExpression))
181
else if (expression.
IsKind
(SyntaxKind.IdentifierName))
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\UseCollectionExpressionHelpers.cs (1)
1037
if (objectCreation.Initializer.
IsKind
(SyntaxKind.ObjectCreationExpression) && objectCreation.Initializer.Expressions.Count > 0)
src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUseCollectionInitializerAnalyzer.cs (1)
35
=> expression.
IsKind
(SyntaxKind.ComplexElementInitializerExpression);
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyForAccessorsHelper.cs (1)
57
=> declaration.
IsKind
(SyntaxKind.GetAccessorDeclaration);
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyHelper`1.cs (1)
194
if (expressionBody!.Expression.
IsKind
(SyntaxKind.ThrowExpression))
src\Analyzers\CSharp\Analyzers\UseExpressionBodyForLambda\UseExpressionBodyForLambdaHelpers.cs (1)
56
if (expressionBodyOpt.
IsKind
(SyntaxKind.ThrowExpression) &&
src\Analyzers\CSharp\Analyzers\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (1)
101
else if (objectCreation.Parent.
IsKind
(SyntaxKind.ArrowExpressionClause))
src\Analyzers\CSharp\Analyzers\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorDiagnosticAnalyzer.cs (1)
73
right.
IsKind
(SyntaxKind.NullLiteralExpression))
src\Analyzers\CSharp\Analyzers\UseLocalFunction\CSharpUseLocalFunctionDiagnosticAnalyzer.cs (1)
357
if (assignment.Left.
IsKind
(SyntaxKind.IdentifierName))
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs (1)
39
Debug.Assert(localStatement.
IsKind
(SyntaxKind.LocalDeclarationStatement));
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs (3)
338
if (left.
IsKind
(SyntaxKind.NullLiteralExpression))
345
if (right.
IsKind
(SyntaxKind.NullLiteralExpression))
361
&& constantPattern.Expression.
IsKind
(SyntaxKind.NullLiteralExpression)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpIsAndCastCheckDiagnosticAnalyzer.cs (1)
96
var ifStatementScope = ifStatement.Parent.
IsKind
(SyntaxKind.Block)
src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (4)
55
if (node.
IsKind
(SyntaxKind.VariableDeclarator) && node.Parent?.Parent?.
IsKind
(SyntaxKind.EventFieldDeclaration) == false)
86
if (node.
IsKind
(SyntaxKind.VariableDeclarator) && !(node = node.Parent?.Parent).
IsKind
(SyntaxKind.EventFieldDeclaration))
src\Analyzers\CSharp\CodeFixes\AddParameter\CSharpAddParameterCodeFixProvider.cs (1)
60
if (constructorInitializer.
IsKind
(SyntaxKind.BaseConstructorInitializer))
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (1)
208
Debug.Assert(!statements[0].
IsKind
(SyntaxKind.BreakStatement));
src\Analyzers\CSharp\CodeFixes\ConvertToAsync\CSharpConvertToAsyncMethodCodeFixProvider.cs (1)
65
var invocationExpression = node.ChildNodes().FirstOrDefault(n => n.
IsKind
(SyntaxKind.InvocationExpression));
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (1)
700
if (docComment.
IsKind
(SyntaxKind.SingleLineDocumentationCommentTrivia))
src\Analyzers\CSharp\CodeFixes\GenerateConstructor\CSharpGenerateConstructorService.cs (2)
60
typeToGenerateIn = constructorInitializer.
IsKind
(SyntaxKind.ThisConstructorInitializer)
191
constructorDeclarationSyntax.Initializer.
IsKind
(SyntaxKind.ThisConstructorInitializer))
src\Analyzers\CSharp\CodeFixes\GenerateParameterizedMember\CSharpGenerateMethodService.cs (1)
126
else if (simpleName.
IsKind
(SyntaxKind.IdentifierName))
src\Analyzers\CSharp\CodeFixes\GenerateVariable\CSharpGenerateVariableCodeFixProvider.cs (2)
45
if (node.
IsKind
(SyntaxKind.MemberBindingExpression))
47
var nameNode = node.ChildNodes().FirstOrDefault(n => n.
IsKind
(SyntaxKind.IdentifierName));
src\Analyzers\CSharp\CodeFixes\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessCodeFixProvider.cs (1)
102
if (ifStatement.Parent.
IsKind
(SyntaxKind.ElseClause) &&
src\Analyzers\CSharp\CodeFixes\MakeMemberStatic\CSharpMakeMemberStaticCodeFixProvider.cs (1)
31
if (node.
IsKind
(SyntaxKind.VariableDeclarator) && node.Parent is VariableDeclarationSyntax { Parent: FieldDeclarationSyntax or EventFieldDeclarationSyntax })
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (1)
67
if (node.
IsKind
(SyntaxKind.ConditionalAccessExpression))
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (3)
94
if (newNameNode.
IsKind
(SyntaxKind.DiscardDesignation))
213
if (originalCompoundAssignment.Parent.
IsKind
(SyntaxKind.ExpressionStatement))
215
if (!originalCompoundAssignment.
IsKind
(SyntaxKind.CoalesceAssignmentExpression))
src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs (2)
75
if (binary.
IsKind
(SyntaxKind.EqualsExpression))
95
=> binary.Right.
IsKind
(SyntaxKind.NullLiteralExpression)
src\Analyzers\CSharp\CodeFixes\UsePatternCombinators\CSharpUsePatternCombinatorsCodeFixProvider.cs (2)
117
if (expr.
IsKind
(SyntaxKind.DefaultLiteralExpression))
121
if (expr.
IsKind
(SyntaxKind.NullLiteralExpression))
src\Compilers\CSharp\Portable\Syntax\LambdaUtilities.cs (12)
40
return !node.Parent.
IsKind
(SyntaxKind.QueryExpression);
55
if (lambda.
IsKind
(SyntaxKind.ArrowExpressionClause))
61
Debug.Assert(lambda.
IsKind
(SyntaxKind.LocalFunctionStatement));
218
if (!selectOrGroupExpression.
IsKind
(SyntaxKind.IdentifierName))
230
if (containingQueryOrContinuation.
IsKind
(SyntaxKind.QueryExpression))
248
if (selectOrGroupClause.
IsKind
(SyntaxKind.SelectClause) && containingBody.Clauses.Count == 0)
255
if (!clause.
IsKind
(SyntaxKind.WhereClause) && !clause.
IsKind
(SyntaxKind.OrderByClause))
298
if (node.Parent.
IsKind
(SyntaxKind.QueryExpression))
376
return syntax.
IsKind
(SyntaxKind.GroupClause) ||
377
syntax.
IsKind
(SyntaxKind.JoinClause) ||
378
syntax.
IsKind
(SyntaxKind.FromClause);
src\Compilers\CSharp\Portable\Syntax\SyntaxBindingUtilities.cs (2)
14
=> node.
IsKind
(SyntaxKind.YieldReturnStatement) ||
15
node.
IsKind
(SyntaxKind.AwaitExpression) ||
Structure\Providers\BlockSyntaxStructureProvider.cs (1)
176
if (node.Parent.
IsKind
(SyntaxKind.IfStatement))
Structure\Providers\StringLiteralExpressionStructureProvider.cs (1)
21
if (node.
IsKind
(SyntaxKind.StringLiteralExpression) &&
UseAutoProperty\SingleLinePropertyFormattingRule.cs (3)
16
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.Parent.
IsKind
(SyntaxKind.AccessorList))
19
if (previousToken.IsKind(SyntaxKind.OpenBraceToken) && previousToken.Parent.
IsKind
(SyntaxKind.AccessorList))
22
if (currentToken.IsKind(SyntaxKind.CloseBraceToken) && currentToken.Parent.
IsKind
(SyntaxKind.AccessorList))
UseAutoProperty\UseAutoPropertyRewriter.cs (1)
26
if (node.Expression.
IsKind
(SyntaxKind.ThisExpression))
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (59)
Semantics\BindingTests.cs (24)
2365
var node = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.ThisExpression)).Cast<ThisExpressionSyntax>().Single();
2384
var node = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.ThisExpression)).Cast<ThisExpressionSyntax>().Single();
2726
.First(x => x.Parent.
IsKind
(SyntaxKind.SimpleMemberAccessExpression) && x.Identifier.ValueText.Equals("M0"));
2738
.First(x => x.Parent.
IsKind
(SyntaxKind.SimpleMemberAccessExpression) && x.Identifier.ValueText.Equals("M1"));
2837
.First(x => x.Parent.
IsKind
(SyntaxKind.SimpleMemberAccessExpression) && x.Identifier.ValueText.Equals("M0"));
2849
.First(x => x.Parent.
IsKind
(SyntaxKind.SimpleMemberAccessExpression) && x.Identifier.ValueText.Equals("M1"));
2888
var node = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.SimpleLambdaExpression)).Single();
2889
var param = node.ChildNodes().Where(n => n.
IsKind
(SyntaxKind.Parameter)).Single();
2925
var lambda = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.SimpleLambdaExpression)).Single();
2927
var param = lambda.ChildNodes().Where(n => n.
IsKind
(SyntaxKind.Parameter)).Single();
2931
var id = lambda.DescendantNodes().First(n => n.
IsKind
(SyntaxKind.IdentifierName));
2967
var lambda = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.SimpleLambdaExpression)).Single();
2969
var param = lambda.ChildNodes().Where(n => n.
IsKind
(SyntaxKind.Parameter)).Single();
2973
var id = lambda.DescendantNodes().First(n => n.
IsKind
(SyntaxKind.IdentifierName));
3037
var node1 = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "Use").Single().Parent;
3051
var node = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "AuthenticateAsync").Single().Parent;
3117
var node1 = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "Use").Single().Parent;
3131
var node = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "AuthenticateAsync").Single().Parent;
3190
var node1 = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "Use").Single().Parent;
3205
var node = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "AuthenticateAsync").Single().Parent;
3275
var node1 = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "Use").Single().Parent;
3290
var node = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "AuthenticateAsync").Single().Parent;
3380
var node1 = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "MathMin").Single().Parent;
3732
var node1 = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "E").Single().Parent;
Semantics\ColorColorTests.cs (1)
1817
var memberAccess = syntaxRoot.DescendantNodes().Single(node => node.
IsKind
(SyntaxKind.SimpleMemberAccessExpression)) as MemberAccessExpressionSyntax;
Semantics\ImplicitObjectCreationTests.cs (1)
4532
where node.
IsKind
(SyntaxKind.CollectionInitializerExpression)
Semantics\LambdaTests.cs (7)
1979
var node1 = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.AnonymousMethodExpression)).Single();
6517
.Where(i => i.Ancestors().Any(a => a.
IsKind
(SyntaxKind.Attribute) || a.
IsKind
(SyntaxKind.DefaultExpression) || a.
IsKind
(SyntaxKind.InvocationExpression)))
6827
.Where(i => i.Ancestors().Any(a => a.
IsKind
(SyntaxKind.InvocationExpression)))
6856
.Where(i => i.Ancestors().Any(a => a.
IsKind
(SyntaxKind.InvocationExpression)))
8017
.Where(n => n.
IsKind
(SyntaxKind.ParenthesizedLambdaExpression))
Semantics\LocalFunctionTests.cs (6)
8686
.Where(i => i.Ancestors().Any(a => a.
IsKind
(SyntaxKind.Attribute) || a.
IsKind
(SyntaxKind.TypeConstraint) || a.
IsKind
(SyntaxKind.DefaultExpression) || a.
IsKind
(SyntaxKind.InvocationExpression)))
9554
.Where(i => i.Ancestors().Any(a => a.
IsKind
(SyntaxKind.Attribute)))
10174
.Where(i => i.Ancestors().Any(a => a.
IsKind
(SyntaxKind.Attribute)))
Semantics\NullableReferenceTypesTests.cs (3)
3693
var lambda = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.SimpleLambdaExpression)).Single();
3695
var param = lambda.ChildNodes().Where(n => n.
IsKind
(SyntaxKind.Parameter)).Single();
3699
var id = lambda.DescendantNodes().First(n => n.
IsKind
(SyntaxKind.IdentifierName));
Semantics\NullCoalesceAssignmentTests.cs (1)
184
var defaultLiteral = syntaxRoot.DescendantNodes().OfType<LiteralExpressionSyntax>().Where(expr => expr.
IsKind
(SyntaxKind.DefaultLiteralExpression)).Single();
Semantics\ObjectAndCollectionInitializerTests.cs (5)
3466
where node.
IsKind
(SyntaxKind.CollectionInitializerExpression)
3514
where node.
IsKind
(SyntaxKind.CollectionInitializerExpression)
3571
where node.
IsKind
(SyntaxKind.CollectionInitializerExpression)
3607
where node.
IsKind
(SyntaxKind.CollectionInitializerExpression)
3644
where node.
IsKind
(SyntaxKind.CollectionInitializerExpression)
Semantics\QueryTests.cs (6)
2384
var selectClause = tree.GetCompilationUnitRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.SelectClause)).Single() as SelectClauseSyntax;
2385
var fromClause1 = tree.GetCompilationUnitRoot().DescendantNodes().Where(n => (n.
IsKind
(SyntaxKind.FromClause)) && (n.ToString().Contains("num1"))).Single() as FromClauseSyntax;
2386
var fromClause2 = tree.GetCompilationUnitRoot().DescendantNodes().Where(n => (n.
IsKind
(SyntaxKind.FromClause)) && (n.ToString().Contains("num2"))).Single() as FromClauseSyntax;
2484
var selectClause = tree.GetCompilationUnitRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.SelectClause)).Single() as SelectClauseSyntax;
2548
var selectClause = tree.GetCompilationUnitRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.SelectClause)).Single() as SelectClauseSyntax;
2583
var orderingClause = tree.GetCompilationUnitRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.AscendingOrdering)).Single() as OrderingSyntax;
Semantics\SwitchTests.cs (1)
1154
var node = syntaxTree.GetRoot().DescendantNodes().First(x => x.
IsKind
(SyntaxKind.SimpleMemberAccessExpression));
Semantics\TopLevelStatementsTests.cs (2)
2919
var nameRef = tree1.GetRoot().DescendantNodes().OfType<IdentifierNameSyntax>().Where(id => id.Identifier.ValueText == "alias1" && !id.Parent.
IsKind
(SyntaxKind.NameEquals)).Single();
2941
nameRef = tree2.GetRoot().DescendantNodes().OfType<IdentifierNameSyntax>().Where(id => id.Identifier.ValueText == "alias2" && !id.Parent.
IsKind
(SyntaxKind.NameEquals)).Single();
Semantics\UnsafeTests.cs (1)
10224
var dereferences = tree.GetCompilationUnitRoot().DescendantNodes().Where(syntax => syntax.
IsKind
(SyntaxKind.PointerIndirectionExpression)).ToArray();
Semantics\Utf8StringsLiteralsTests.cs (1)
4081
foreach (var node in tree.GetCompilationUnitRoot().DescendantNodes().OfType<BinaryExpressionSyntax>().Where(b => b.
IsKind
(SyntaxKind.AddExpression)))
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (21)
Compilation\SemanticModelAPITests.cs (2)
404
var nsArray = tree.GetCompilationUnitRoot().DescendantNodes().Where(node => node.
IsKind
(SyntaxKind.NamespaceDeclaration)).ToArray();
425
var nsArray = tree.GetCompilationUnitRoot().DescendantNodes().Where(node => node.
IsKind
(SyntaxKind.FileScopedNamespaceDeclaration)).ToArray();
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (16)
3686
var globalStmt = tree.GetCompilationUnitRoot().FindToken(tree.GetCompilationUnitRoot().ToFullString().IndexOf('/')).Parent.AncestorsAndSelf().Single(x => x.
IsKind
(SyntaxKind.GlobalStatement));
4691
var decl = (ClassDeclarationSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.ClassDeclaration));
4706
var decl = (ClassDeclarationSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.ClassDeclaration));
4721
var decl = (ClassDeclarationSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.ClassDeclaration));
4797
var decl = (TupleExpressionSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.TupleExpression));
4820
var decl = (TupleExpressionSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.TupleExpression));
4843
var decl = (TupleExpressionSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.TupleExpression));
4866
var decl = (TupleExpressionSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.TupleExpression));
4889
var decl = (TupleExpressionSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.TupleExpression));
4912
var decl = (ArgumentSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.Argument));
4935
var decl = (ArgumentSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.Argument));
4958
var decl = (ArgumentSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.Argument));
4993
var decl = (ArgumentSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.Argument));
5039
var decl = (ArgumentSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.Argument));
5088
var decl = (ArgumentSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.Argument));
5111
var decl = (ArgumentSyntax)tree.GetCompilationUnitRoot().DescendantNodes().Last(n => n.
IsKind
(SyntaxKind.Argument));
Symbols\AnonymousTypesSemanticsTests.cs (1)
2010
while (current.Span == identifier.Span && !current.
IsKind
(SyntaxKind.IdentifierName))
Symbols\IndexerTests.cs (1)
2539
node.DescendantNodesAndSelf().Where(s => s.
IsKind
(SyntaxKind.ElementAccessExpression)).Cast<ElementAccessExpressionSyntax>();
Symbols\Source\NullablePublicAPITests.cs (1)
4730
var suppressions = tree.GetRoot().DescendantNodes().OfType<PostfixUnaryExpressionSyntax>().Where(p => p.
IsKind
(SyntaxKind.SuppressNullableWarningExpression)).ToList();
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (7)
Syntax\SyntaxRewriterTests.cs (7)
76
(node.
IsKind
(SyntaxKind.IdentifierName) && node.ToString() == "C") ? null : node);
100
(node.
IsKind
(SyntaxKind.IdentifierName) && node.ToString() != "A") ? null : node);
243
(node.
IsKind
(SyntaxKind.ExpressionStatement) && node.ToString().Contains("B")) ? null : node);
257
(node.
IsKind
(SyntaxKind.ExpressionStatement)) ? null : node);
275
if (node != null && node.
IsKind
(SyntaxKind.OmittedArraySizeExpression) && first)
306
(node.
IsKind
(SyntaxKind.IdentifierName) && node.ToString() == "D") ? null : node);
349
var typeName = tree.GetCompilationUnitRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.GenericName)).Single();
Microsoft.CodeAnalysis.CSharp.Test.Utilities (2)
SemanticModelTestBase.cs (2)
109
n.
IsKind
(SyntaxKind.BaseConstructorInitializer) || n.
IsKind
(SyntaxKind.ThisConstructorInitializer);
Microsoft.CodeAnalysis.CSharp.WinRT.UnitTests (1)
CodeGen\WinRTCollectionTests.cs (1)
7424
var add = tree.GetRoot().DescendantNodes().Where(n => n.
IsKind
(SyntaxKind.IdentifierName) && ((IdentifierNameSyntax)n).Identifier.ValueText == "Add").Single();
Microsoft.CodeAnalysis.CSharp.Workspaces (276)
Classification\ClassificationHelpers.cs (2)
311
if (parentNode.
IsKind
(SyntaxKind.EnumMemberDeclaration))
318
else if (parentNode.
IsKind
(SyntaxKind.VariableDeclarator))
Classification\SyntaxClassification\NameSyntaxClassifier.cs (1)
174
if ((name.IsUnmanaged || name.IsNotNull) && name.Parent.
IsKind
(SyntaxKind.TypeConstraint))
Classification\SyntaxClassification\OperatorOverloadSyntaxClassifier.cs (1)
35
if (syntax.
IsKind
(SyntaxKind.SimpleAssignmentExpression))
CodeGeneration\CSharpSyntaxGenerator.cs (12)
1101
if (!declaration.
IsKind
(SyntaxKind.CompilationUnit))
1424
if (modifiers.IsStatic && declaration.
IsKind
(SyntaxKind.ConstructorDeclaration) && accessibility != Accessibility.NotApplicable)
1633
(modifiers.IsStatic && declaration.
IsKind
(SyntaxKind.ConstructorDeclaration)))
2159
currentList ??= declaration.
IsKind
(SyntaxKind.IndexerDeclaration)
2616
return accessorList?.Accessors.FirstOrDefault(a => a.
IsKind
(kind));
2626
var acc = accessorList.Accessors.FirstOrDefault(a => a.
IsKind
(kind));
2754
if (fullDecl != declaration && fullDecl.
IsKind
(newFullDecl.Kind()))
2786
if (decl2.
IsKind
(kind))
2812
if (decl2.
IsKind
(kind))
2880
if (declaration.Parent.
IsKind
(SyntaxKind.GlobalStatement))
2919
if (declaration.Parent.
IsKind
(SyntaxKind.GlobalStatement))
2990
if (node.Parent.
IsKind
(SyntaxKind.GlobalStatement))
Rename\CSharpRenameRewriterLanguageService.cs (3)
224
if (newToken.Parent.
IsKind
(SyntaxKind.XmlName))
281
token.Parent.
IsKind
(SyntaxKind.DestructorDeclaration);
712
else if (newToken.IsKind(SyntaxKind.IdentifierToken) && newToken.Parent.
IsKind
(SyntaxKind.XmlName) && newToken.ValueText == _originalText)
Rename\LocalConflictVisitor.cs (1)
186
var statements = node.ChildNodes().Where(x => x.
IsKind
(SyntaxKind.SwitchSection)).SelectMany(x => x.ChildNodes());
Simplification\CSharpSimplificationService.cs (6)
114
if (parentOfToken is SimpleNameSyntax && parent.
IsKind
(SyntaxKind.XmlNameAttribute))
121
if (parent.
IsKind
(SyntaxKind.AliasQualifiedName) &&
205
Debug.Assert(tuple.
IsKind
(SyntaxKind.TupleExpression));
210
if (parent.
IsKind
(SyntaxKind.SimpleAssignmentExpression))
215
if (!parent.
IsKind
(SyntaxKind.Argument))
221
if (!grandParent.
IsKind
(SyntaxKind.TupleExpression))
Simplification\CSharpSimplificationService.Expander.cs (1)
374
if (result.Expression != null && !result.Expression.
IsKind
(SyntaxKind.ParenthesizedExpression))
Simplification\Reducers\CSharpCastReducer.Rewriter.cs (4)
37
if ((node.Left.
IsKind
(SyntaxKind.CastExpression) && !reducedNode.Left.
IsKind
(SyntaxKind.CastExpression)) ||
38
(node.Right.
IsKind
(SyntaxKind.CastExpression) && !reducedNode.Right.
IsKind
(SyntaxKind.CastExpression)))
Simplification\Reducers\CSharpInferredMemberNameReducer.Rewriter.cs (1)
56
if (node.Parent.
IsKind
(SyntaxKind.TupleExpression))
Simplification\Reducers\CSharpMiscellaneousReducer.cs (1)
142
if (!node.Parent.
IsKind
(SyntaxKind.IfStatement))
Simplification\Simplifiers\ExpressionSimplifier.cs (1)
199
if (!memberAccess.Expression.
IsKind
(SyntaxKind.BaseExpression))
Simplification\Simplifiers\NameSimplifier.cs (2)
241
if (!name.Parent.
IsKind
(SyntaxKind.QualifiedName) && (inDeclarationContext || inMemberAccessContext))
669
if (!reparsedCastExpression.
IsKind
(SyntaxKind.CastExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CodeStyle\TypeStyle\TypeStyleHelper.cs (2)
66
if (initializerExpression.
IsKind
(SyntaxKind.DefaultExpression))
80
!initializerExpression.
IsKind
(SyntaxKind.AnonymousObjectCreationExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (6)
160
if (!simpleName.
IsKind
(SyntaxKind.IdentifierName))
355
if (expression.Parent.
IsKind
(SyntaxKind.AddressOfExpression))
467
if (expression.
IsKind
(SyntaxKind.StackAllocArrayCreationExpression))
515
if (expression.
IsKind
(SyntaxKind.ConditionalAccessExpression))
529
if (expression.
IsKind
(SyntaxKind.IdentifierName) || expression is MemberAccessExpressionSyntax)
555
!parentConditionalAccessExpression.Parent.
IsKind
(SyntaxKind.ConditionalAccessExpression);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (29)
40
var parentExpression = nodeParent.
IsKind
(SyntaxKind.ConstantPattern)
59
if (expression.
IsKind
(SyntaxKind.ParenthesizedExpression) ||
60
parentExpression.
IsKind
(SyntaxKind.ParenthesizedExpression))
89
var opposite = expression.
IsKind
(SyntaxKind.GreaterThanExpression) ? SyntaxKind.LessThanExpression : SyntaxKind.GreaterThanExpression;
95
if (expression.
IsKind
(SyntaxKind.ThrowExpression))
99
if (nodeParent.
IsKind
(SyntaxKind.ExpressionStatement))
103
if (nodeParent.
IsKind
(SyntaxKind.ArrowExpressionClause))
111
if (expression.
IsKind
(SyntaxKind.TupleExpression))
163
if (nodeParent.
IsKind
(SyntaxKind.CastExpression) && expression.
IsKind
(SyntaxKind.ThisExpression))
173
if (nodeParent.
IsKind
(SyntaxKind.Interpolation))
178
if (expression.
IsKind
(SyntaxKind.InterpolatedStringExpression))
234
if (expression.
IsKind
(SyntaxKind.ThisExpression))
238
if (expression.
IsKind
(SyntaxKind.ThrowExpression) &&
246
if (nodeParent.
IsKind
(SyntaxKind.CaseSwitchLabel))
250
if (nodeParent.
IsKind
(SyntaxKind.ConstantPattern) &&
257
if (nodeParent.
IsKind
(SyntaxKind.WhenClause))
271
if (parentExpression.
IsKind
(SyntaxKind.CastExpression) &&
279
if (expression.
IsKind
(SyntaxKind.ConditionalExpression) &&
290
if (expression.
IsKind
(SyntaxKind.ConditionalAccessExpression))
425
if (parentExpression.
IsKind
(SyntaxKind.CoalesceExpression))
518
if (name.
IsKind
(SyntaxKind.AliasQualifiedName))
547
if (binaryExpression.
IsKind
(SyntaxKind.LessThanExpression))
560
else if (binaryExpression.
IsKind
(SyntaxKind.GreaterThanExpression))
575
else if (node.Expression.
IsKind
(SyntaxKind.LessThanExpression))
582
else if (node.Expression.
IsKind
(SyntaxKind.GreaterThanExpression))
624
|| lessThanExpression.Left.
IsKind
(SyntaxKind.CastExpression))
755
if (binaryPattern.
IsKind
(SyntaxKind.AndPattern))
758
if (binaryPattern.
IsKind
(SyntaxKind.OrPattern))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\StatementSyntaxExtensions.cs (2)
40
if (first.Parent.
IsKind
(SyntaxKind.GlobalStatement))
41
return second.Parent.
IsKind
(SyntaxKind.GlobalStatement);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (3)
32
if (node.
IsKind
(kind))
43
=> CodeAnalysis.CSharpExtensions.
IsKind
(node?.Parent, kind);
358
return !current.Parent.
IsKind
(SyntaxKind.CompilationUnit);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTokenExtensions.cs (2)
47
token.Parent.
IsKind
(SyntaxKind.ObjectInitializerExpression);
50
=> token.IsKind(SyntaxKind.OpenBraceToken) && token.Parent.
IsKind
(SyntaxKind.AccessorList);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (20)
83
=> token.Kind() == SyntaxKind.OpenParenToken && token.Parent.
IsKind
(SyntaxKind.ParameterList);
86
=> token.Kind() == SyntaxKind.CloseParenToken && token.Parent.
IsKind
(SyntaxKind.ParameterList);
109
if (token.Parent.
IsKind
(SyntaxKind.PositionalPatternClause) && token.Parent.Parent.
IsKind
(SyntaxKind.RecursivePattern))
119
=> token.Kind() == SyntaxKind.ColonToken && token.Parent.
IsKind
(SyntaxKind.BaseList);
125
=> token.Kind() == SyntaxKind.OpenParenToken && token.Parent.
IsKind
(SyntaxKind.ParameterList) && token.Parent.Parent.
IsKind
(SyntaxKind.ParenthesizedLambdaExpression);
178
return token.Parent is ExpressionSyntax || token.Parent.
IsKind
(SyntaxKind.PropertyPatternClause);
210
token.Parent.
IsKind
(SyntaxKind.EnumDeclaration);
278
token.Parent.
IsKind
(SyntaxKind.EqualsValueClause) &&
279
token.Parent.Parent.
IsKind
(SyntaxKind.PropertyDeclaration);
305
=> token.IsDotInMemberAccess() || (token.Kind() == SyntaxKind.DotToken && token.Parent.
IsKind
(SyntaxKind.QualifiedName));
337
=> token.Kind() == SyntaxKind.ColonToken && token.Parent.
IsKind
(SyntaxKind.SwitchExpressionArm);
340
=> token.Kind() == SyntaxKind.CommaToken && token.Parent.
IsKind
(SyntaxKind.SwitchExpression);
343
=> token.Kind() == SyntaxKind.CommaToken && token.Parent.
IsKind
(SyntaxKind.PropertyPatternClause);
433
parent.
IsKind
(SyntaxKind.SimpleAssignmentExpression))
452
parent.
IsKind
(SyntaxKind.SimpleAssignmentExpression))
521
=> currentToken.Parent.
IsKind
(SyntaxKind.Interpolation);
539
currentToken.Parent.
IsKind
(SyntaxKind.TupleExpression);
543
=> token.Kind() == SyntaxKind.CommaToken && token.Parent.
IsKind
(SyntaxKind.CollectionExpression);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\AnchorIndentationFormattingRule.cs (1)
25
if (node.
IsKind
(SyntaxKind.AnonymousMethodExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\BaseFormattingRule.cs (1)
184
else if (node.
IsKind
(SyntaxKind.PropertyPatternClause))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (11)
116
currentToken.Parent.
IsKind
(SyntaxKind.TypeParameterConstraintClause))
131
firstTokenAfterTypeConstraint.Parent.
IsKind
(SyntaxKind.TypeParameterConstraintClause))
373
if ((currentToken.Kind() == SyntaxKind.FromKeyword && currentToken.Parent.
IsKind
(SyntaxKind.FromClause)) ||
374
(currentToken.Kind() == SyntaxKind.LetKeyword && currentToken.Parent.
IsKind
(SyntaxKind.LetClause)) ||
375
(currentToken.Kind() == SyntaxKind.WhereKeyword && currentToken.Parent.
IsKind
(SyntaxKind.WhereClause)) ||
376
(currentToken.Kind() == SyntaxKind.JoinKeyword && currentToken.Parent.
IsKind
(SyntaxKind.JoinClause)) ||
377
(currentToken.Kind() == SyntaxKind.JoinKeyword && currentToken.Parent.
IsKind
(SyntaxKind.JoinIntoClause)) ||
378
(currentToken.Kind() == SyntaxKind.OrderByKeyword && currentToken.Parent.
IsKind
(SyntaxKind.OrderByClause)) ||
379
(currentToken.Kind() == SyntaxKind.SelectKeyword && currentToken.Parent.
IsKind
(SyntaxKind.SelectClause)) ||
380
(currentToken.Kind() == SyntaxKind.GroupKeyword && currentToken.Parent.
IsKind
(SyntaxKind.GroupClause)))
438
nextToken.Parent.
IsKind
(SyntaxKind.DoStatement))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (2)
233
if (node.
IsKind
(SyntaxKind.ArrayInitializerExpression) && node.Parent != null && node.Parent.
IsKind
(SyntaxKind.ArrayCreationExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\NewLineUserSettingFormattingRule.cs (13)
44
if (node.
IsKind
(SyntaxKind.SwitchStatement))
121
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.Parent.
IsKind
(SyntaxKind.AnonymousObjectCreationExpression))
143
else if (currentToken.Parent.
IsKind
(SyntaxKind.PropertyPatternClause))
189
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentTokenParentParent.
IsKind
(SyntaxKind.AnonymousMethodExpression))
198
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentTokenParentParent.
IsKind
(SyntaxKind.LocalFunctionStatement))
217
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.Parent.
IsKind
(SyntaxKind.SwitchExpression))
246
if (previousToken.IsKind(SyntaxKind.CommaToken) && previousToken.Parent.
IsKind
(SyntaxKind.ObjectInitializerExpression))
260
if (previousToken.IsKind(SyntaxKind.CommaToken) && previousToken.Parent.
IsKind
(SyntaxKind.AnonymousObjectCreationExpression))
327
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.Parent.
IsKind
(SyntaxKind.AnonymousObjectCreationExpression))
399
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentTokenParentParent.
IsKind
(SyntaxKind.AnonymousMethodExpression))
412
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentTokenParentParent.
IsKind
(SyntaxKind.LocalFunctionStatement))
439
if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentToken.Parent.
IsKind
(SyntaxKind.SwitchExpression))
468
&& (previousToken.Parent is StatementSyntax && !previousToken.Parent.
IsKind
(SyntaxKind.ForStatement))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SpacingFormattingRule.cs (4)
92
if (previousToken.Parent.
IsKind
(SyntaxKind.OperatorDeclaration) && currentToken.IsOpenParenInParameterListOfAOperationDeclaration())
249
if (previousKind == SyntaxKind.CloseBracketToken && previousToken.Parent.
IsKind
(SyntaxKind.AttributeList))
253
currentToken.Parent.
IsKind
(SyntaxKind.AttributeList))
458
if (previousToken.Parent.
IsKind
(SyntaxKind.NotPattern))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (2)
80
if (node.
IsKind
(SyntaxKind.SwitchExpressionArm))
88
if (node.
IsKind
(SyntaxKind.SwitchExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\TokenBasedFormattingRule.cs (5)
175
if (previousToken.Kind() == SyntaxKind.DoKeyword && previousToken.Parent.
IsKind
(SyntaxKind.DoStatement))
288
previousToken.Parent.
IsKind
(SyntaxKind.AttributeList) &&
453
if (currentToken.IsKind(SyntaxKind.QuestionToken) && currentToken.Parent.
IsKind
(SyntaxKind.ConditionalAccessExpression))
474
currentToken.Parent.
IsKind
(SyntaxKind.SuppressNullableWarningExpression))
521
&& !previousToken.Parent.
IsKind
(SyntaxKind.SuppressNullableWarningExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\WrappingFormattingRule.cs (1)
74
if (embeddedStatement.
IsKind
(SyntaxKind.Block))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (1)
74
endToken.Parent.
IsKind
(SyntaxKind.Block) &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (3)
323
=> node?.Parent.
IsKind
(SyntaxKind.FieldDeclaration) ?? false;
326
=> node?.Parent.
IsKind
(SyntaxKind.EventFieldDeclaration) ?? false;
329
=> node?.Parent.
IsKind
(SyntaxKind.LocalDeclarationStatement) ?? false;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpBlockFacts.cs (1)
23
=> node.
IsKind
(SyntaxKind.Block);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (10)
521
if (token.Kind() == SyntaxKind.CommaToken && token.Parent.
IsKind
(SyntaxKind.OrderByClause))
527
&& token.Parent.
IsKind
(SyntaxKind.CollectionExpression))
555
=> simpleName.
IsKind
(SyntaxKind.GenericName) ||
587
=> node.
IsKind
(SyntaxKind.BaseList);
599
=> node.
IsKind
(SyntaxKind.Argument);
602
=> node.
IsKind
(SyntaxKind.AttributeArgument);
635
=> node.
IsKind
(SyntaxKind.IdentifierName) &&
690
=> node.
IsKind
(SyntaxKind.ElementAccessExpression);
1241
=> node.
IsKind
(SyntaxKind.Attribute) &&
1299
exprStatement.Expression.
IsKind
(SyntaxKind.SimpleAssignmentExpression);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\CSharpInferredMemberNameSimplifier.cs (1)
16
if (node.NameColon == null || !node.Parent.
IsKind
(SyntaxKind.TupleExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (4)
179
var isDefaultLiteralCast = castedExpressionNode.WalkDownParentheses().
IsKind
(SyntaxKind.DefaultLiteralExpression);
326
var isNullLiteralCast = castedExpressionNode.WalkDownParentheses().
IsKind
(SyntaxKind.NullLiteralExpression);
814
if (originalConditionalExpression.WhenTrue.WalkDownParentheses().
IsKind
(SyntaxKind.DefaultLiteralExpression) ||
815
originalConditionalExpression.WhenFalse.WalkDownParentheses().
IsKind
(SyntaxKind.DefaultLiteralExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
349
(previousToken.Parent.
IsKind
(SyntaxKind.Block) ||
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (10)
303
if (expression.WalkDownParentheses().
IsKind
(SyntaxKind.DefaultLiteralExpression))
621
if (result.
IsKind
(SyntaxKind.SimpleMemberAccessExpression))
632
if (result.
IsKind
(SyntaxKind.SimpleMemberAccessExpression))
663
=> node.
IsKind
(SyntaxKind.ParenthesizedExpression);
773
if (newExpression.
IsKind
(SyntaxKind.ConditionalExpression) &&
783
if (newExpression.
IsKind
(SyntaxKind.SwitchExpression) &&
793
if (newExpression.
IsKind
(SyntaxKind.CollectionExpression) &&
802
if (newExpression.
IsKind
(SyntaxKind.TupleExpression) &&
818
if (originalExpression.
IsKind
(SyntaxKind.ConditionalExpression) &&
819
newExpression.
IsKind
(SyntaxKind.ConditionalExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseExplicitTypeHelper.cs (1)
73
declExpression.Designation.
IsKind
(SyntaxKind.ParenthesizedVariableDesignation))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpUseImplicitTypeHelper.cs (4)
133
if (!variableDeclaration.Type.
IsKind
(SyntaxKind.PointerType))
137
.Any(node => node.
IsKind
(SyntaxKind.StackAllocArrayCreationExpression));
281
if (expression.
IsKind
(SyntaxKind.NullLiteralExpression))
287
if (expression.
IsKind
(SyntaxKind.ImplicitObjectCreationExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (1)
509
var insertionIndex = compilationUnit.Members.LastIndexOf(memberDeclaration => memberDeclaration.
IsKind
(SyntaxKind.GlobalStatement)) + 1;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\PropertyGenerator.cs (1)
166
if (accessor.
IsKind
(SyntaxKind.GetAccessorDeclaration))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\CSharpSyntaxContext.cs (1)
230
targetToken.Parent.
IsKind
(SyntaxKind.DestructorDeclaration) &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (20)
115
case SyntaxKind.OpenBraceToken when token.Parent.
IsKind
(SyntaxKind.Block):
124
if (token.Parent.
IsKind
(SyntaxKind.Block))
148
if (token.Parent.
IsKind
(SyntaxKind.SwitchStatement))
158
case SyntaxKind.DoKeyword when token.Parent.
IsKind
(SyntaxKind.DoStatement):
174
return token.Parent.
IsKind
(SyntaxKind.ElseClause);
177
if (token.Parent.
IsKind
(SyntaxKind.AttributeList))
259
if (token.Parent.
IsKind
(SyntaxKind.AttributeList))
274
if (token.Parent.
IsKind
(SyntaxKind.CastExpression))
334
targetToken.Parent.
IsKind
(SyntaxKind.ParenthesizedExpression))
396
targetToken.Parent.
IsKind
(SyntaxKind.SwitchStatement))
450
targetToken.Parent.
IsKind
(SyntaxKind.NameColon) &&
451
targetToken.Parent.Parent.
IsKind
(SyntaxKind.Argument) &&
452
targetToken.Parent.Parent.Parent.
IsKind
(SyntaxKind.ArgumentList))
468
if (targetToken.Parent.
IsKind
(SyntaxKind.ArgumentList))
582
targetToken.Parent.
IsKind
(SyntaxKind.AccessorList))
590
targetToken.Parent.
IsKind
(SyntaxKind.Block) &&
605
targetToken.Parent.
IsKind
(SyntaxKind.AttributeList) &&
616
if (node.
IsKind
(SyntaxKind.TypeParameterList))
650
targetToken.Parent.
IsKind
(SyntaxKind.AttributeList) &&
651
targetToken.Parent.Parent.
IsKind
(SyntaxKind.TypeParameter) &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (67)
114
if (parent.
IsKind
(SyntaxKind.CompilationUnit) ||
207
token.Parent.
IsKind
(SyntaxKind.Block) &&
220
token.Parent.
IsKind
(SyntaxKind.AttributeList))
482
else if (token.Parent.
IsKind
(SyntaxKind.NamespaceDeclaration))
491
token.Parent.
IsKind
(SyntaxKind.Block) &&
507
token.Parent.
IsKind
(SyntaxKind.AttributeList))
601
return incompleteMember.Type.
IsKind
(SyntaxKind.RefType);
895
if (token.IsKind(SyntaxKind.OpenParenToken) && token.Parent.
IsKind
(SyntaxKind.TypeOfExpression))
907
if (token.IsKind(SyntaxKind.OpenParenToken) && token.Parent.
IsKind
(SyntaxKind.DefaultExpression))
920
if (token.IsKind(SyntaxKind.OpenParenToken) && token.Parent.
IsKind
(SyntaxKind.SizeOfExpression))
941
return token.Parent.
IsKind
(SyntaxKind.FunctionPointerParameterList);
955
=> targetToken.Parent.
IsKind
(SyntaxKind.TypeParameterConstraintClause) &&
1071
if (token.IsKind(SyntaxKind.LessThanToken) && token.Parent.
IsKind
(SyntaxKind.FunctionPointerParameterList))
1097
token.Parent.
IsKind
(SyntaxKind.AttributeList) &&
1158
return token.Parent.
IsKind
(SyntaxKind.BracketedParameterList);
1171
token.Parent.
IsKind
(SyntaxKind.DelegateDeclaration))
1230
if (token.Parent.
IsKind
(SyntaxKind.ParameterList) &&
1265
else if (token.IsKind(SyntaxKind.ScopedKeyword) && token.Parent.
IsKind
(SyntaxKind.Parameter))
1269
else if (token.IsKind(SyntaxKind.IdentifierToken) && token.Text == "scoped" && token.Parent is IdentifierNameSyntax scopedIdentifierName && scopedIdentifierName.Parent.
IsKind
(SyntaxKind.Parameter))
1278
return parent.
IsKind
(SyntaxKind.ParameterList) && parent.IsParentKind(SyntaxKind.AnonymousMethodExpression);
1349
leftToken.Parent.
IsKind
(SyntaxKind.IdentifierName) &&
1376
if (leftToken.Parent.
IsKind
(SyntaxKind.ParenthesizedPattern))
1391
if (leftToken.Kind() is SyntaxKind.OpenBraceToken or SyntaxKind.CommaToken && leftToken.Parent.
IsKind
(SyntaxKind.SwitchExpression))
1398
if (leftToken.Kind() is SyntaxKind.OpenParenToken or SyntaxKind.CommaToken && leftToken.Parent.
IsKind
(SyntaxKind.PositionalPatternClause))
1405
if (leftToken.Kind() is SyntaxKind.OpenBracketToken or SyntaxKind.CommaToken && leftToken.Parent.
IsKind
(SyntaxKind.ListPattern))
1412
if (leftToken.IsKind(SyntaxKind.DotDotToken) && leftToken.Parent.
IsKind
(SyntaxKind.SlicePattern))
1438
if (leftToken.IsKind(SyntaxKind.NotKeyword) && leftToken.Parent.
IsKind
(SyntaxKind.NotPattern))
1448
leftToken.Parent.
IsKind
(SyntaxKind.RelationalPattern))
1583
if (possibleCommaOrParen.Parent.
IsKind
(SyntaxKind.ParameterList) &&
1673
if (node.Parent.
IsKind
(SyntaxKind.ParenthesizedExpression))
1679
if (node.Parent.
IsKind
(SyntaxKind.Argument) && node.Parent.Parent.
IsKind
(SyntaxKind.TupleExpression))
1692
leftToken.Parent.
IsKind
(SyntaxKind.ArgumentList) &&
1786
token.Parent.
IsKind
(SyntaxKind.LocalDeclarationStatement))
1865
if (token.IsKind(SyntaxKind.IdentifierToken) && token.Text == "scoped" && token.Parent.
IsKind
(SyntaxKind.IdentifierName) && token.Parent.Parent is VariableDeclarationSyntax or ExpressionStatementSyntax or IncompleteMemberSyntax)
2049
token.Parent.
IsKind
(SyntaxKind.CastExpression))
2069
token.Parent.
IsKind
(SyntaxKind.GotoCaseStatement))
2110
if (token.Parent.
IsKind
(SyntaxKind.AttributeArgumentList) &&
2118
token.Parent.
IsKind
(SyntaxKind.NameColon) &&
2126
token.Parent.
IsKind
(SyntaxKind.NameEquals) &&
2208
if (token.Parent.
IsKind
(SyntaxKind.NameEquals) &&
2250
if (token.Parent.
IsKind
(SyntaxKind.ParenthesizedExpression))
2367
token.Parent.
IsKind
(SyntaxKind.ArrayRankSpecifier))
2375
token.Parent.
IsKind
(SyntaxKind.RangeExpression) &&
2392
token.Parent.
IsKind
(SyntaxKind.ConditionalExpression))
2434
if (token.Parent.
IsKind
(SyntaxKind.AttributeArgumentList))
2447
if (token.Parent.
IsKind
(SyntaxKind.Argument))
2451
else if (token.Parent.
IsKind
(SyntaxKind.RefExpression))
2466
token.Parent.
IsKind
(SyntaxKind.NameColon) &&
2486
if (token.Parent.
IsKind
(SyntaxKind.ObjectInitializerExpression) && token.IsKind(SyntaxKind.OpenBraceToken))
2537
token.Parent.
IsKind
(SyntaxKind.ForStatement))
2561
token.Parent.
IsKind
(SyntaxKind.JoinClause))
2568
token.Parent.
IsKind
(SyntaxKind.WhereClause))
2576
token.Parent.
IsKind
(SyntaxKind.OrderByClause))
2583
token.Parent.
IsKind
(SyntaxKind.SelectClause))
2591
token.Parent.
IsKind
(SyntaxKind.GroupClause))
2624
if (token.IsKind(SyntaxKind.OpenParenToken) && token.Parent.
IsKind
(SyntaxKind.UsingStatement))
2672
if (token.IsKind(SyntaxKind.WhenKeyword) && token.Parent.
IsKind
(SyntaxKind.WhenClause))
2690
token.Parent.
IsKind
(SyntaxKind.AnonymousObjectCreationExpression))
2699
token.Parent.
IsKind
(SyntaxKind.ListPattern))
2708
token.Parent.
IsKind
(SyntaxKind.CollectionExpression))
2717
token.Parent.
IsKind
(SyntaxKind.SpreadElement))
2865
token.Parent.
IsKind
(SyntaxKind.IdentifierName) &&
2873
token.Parent.
IsKind
(SyntaxKind.IdentifierName))
2980
token.Parent.
IsKind
(SyntaxKind.CatchDeclaration))
2996
targetToken.Parent.
IsKind
(SyntaxKind.BaseList) &&
3012
if (token.Parent.
IsKind
(SyntaxKind.SimpleMemberAccessExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ExpressionSyntaxExtensions.cs (2)
30
if (expression.
IsKind
(SyntaxKind.RefExpression))
44
if (expression.
IsKind
(SyntaxKind.ThrowExpression))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.cs (2)
126
node.
IsKind
(SyntaxKind.Interpolation))
133
!argument.Parent.
IsKind
(SyntaxKind.ThisConstructorInitializer) &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Indentation\CSharpIndentationService.Indenter.cs (4)
179
(token.IsKind(SyntaxKind.CloseBraceToken) && token.Parent.
IsKind
(SyntaxKind.Interpolation)))
251
if (token.Parent.
IsKind
(SyntaxKind.AccessorList) &&
252
token.Parent.Parent.
IsKind
(SyntaxKind.PropertyDeclaration))
307
if (token.Parent.
IsKind
(SyntaxKind.ArgumentList))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (2)
1287
if (initializerExpression.
IsKind
(SyntaxKind.ComplexElementInitializerExpression))
1307
else if (initializerExpression.
IsKind
(SyntaxKind.CollectionInitializerExpression))
Microsoft.CodeAnalysis.Test.Utilities (6)
Compilation\ControlFlowGraphVerifier.cs (1)
869
conditionalAccess.
IsKind
(CSharp.SyntaxKind.CoalesceAssignmentExpression) &&
Compilation\TestOperationVisitor.cs (5)
1415
if (operation.Syntax.
IsKind
(CSharp.SyntaxKind.VarPattern) ||
1417
operation.Syntax.
IsKind
(CSharp.SyntaxKind.SingleVariableDesignation))
1432
if (designation.
IsKind
(CSharp.SyntaxKind.SingleVariableDesignation))
1464
if (designation.
IsKind
(CSharp.SyntaxKind.SingleVariableDesignation))
1501
if (designation.
IsKind
(CSharp.SyntaxKind.SingleVariableDesignation))
Microsoft.DotNet.CodeAnalysis (3)
Analyzers\AppContextDefaultsAnalyzer.cs (3)
80
var containingIfStatement = call.Ancestors().FirstOrDefault(n => n.
IsKind
(SyntaxKind.IfStatement)) as IfStatementSyntax;
88
if (!(containingIfStatement.Parent.
IsKind
(SyntaxKind.SwitchSection) ||
89
containingIfStatement.Parent.Parent.
IsKind
(SyntaxKind.SwitchSection)))
Microsoft.Extensions.Logging.Generators (1)
src\libraries\Common\src\Roslyn\SyntaxValueProvider_ForAttributeWithSimpleName.cs (1)
438
if (node.
IsKind
(SyntaxKind.AttributeList))
Microsoft.Gen.ComplianceReports (2)
Parser.cs (1)
39
foreach (TypeDeclarationSyntax typeSyntax in typeForSyntaxTree.Where(n => !n.
IsKind
(SyntaxKind.InterfaceDeclaration)))
src\Generators\Shared\GeneratorUtilities.cs (1)
88
if (node.
IsKind
(SyntaxKind.Attribute))
Microsoft.Gen.ContextualOptions (1)
src\Generators\Shared\GeneratorUtilities.cs (1)
88
if (node.
IsKind
(SyntaxKind.Attribute))
Microsoft.Gen.Logging (1)
src\Generators\Shared\GeneratorUtilities.cs (1)
88
if (node.
IsKind
(SyntaxKind.Attribute))
Microsoft.Gen.Metrics (3)
Parser.cs (2)
81
foreach (var memberSyntax in typeDeclaration.Members.Where(x => x.
IsKind
(SyntaxKind.MethodDeclaration)))
192
if (typeDeclaration.
IsKind
(SyntaxKind.RecordStructDeclaration) &&
src\Generators\Shared\GeneratorUtilities.cs (1)
88
if (node.
IsKind
(SyntaxKind.Attribute))
Microsoft.Gen.MetricsReports (3)
src\Generators\Microsoft.Gen.Metrics\Parser.cs (2)
81
foreach (var memberSyntax in typeDeclaration.Members.Where(x => x.
IsKind
(SyntaxKind.MethodDeclaration)))
192
if (typeDeclaration.
IsKind
(SyntaxKind.RecordStructDeclaration) &&
src\Generators\Shared\GeneratorUtilities.cs (1)
88
if (node.
IsKind
(SyntaxKind.Attribute))
Microsoft.Interop.ComInterfaceGenerator (3)
Analyzers\AddMarshalAsToElementFixer.cs (1)
58
if (node.
IsKind
(SyntaxKind.MethodDeclaration))
Analyzers\RuntimeComApiUsageWithSourceGeneratedComAnalyzer.cs (2)
215
if (expression.
IsKind
(SyntaxKind.SimpleMemberAccessExpression))
220
if (expression.
IsKind
(SyntaxKind.GenericName))
Microsoft.Interop.LibraryImportGenerator (7)
Analyzers\ConvertToLibraryImportFixer.cs (7)
322
else if (invocation.Parent.
IsKind
(SyntaxKind.ExpressionStatement))
342
else if (invocation.Parent.
IsKind
(SyntaxKind.EqualsValueClause))
345
if (declaration.
IsKind
(SyntaxKind.FieldDeclaration) || declaration.
IsKind
(SyntaxKind.EventFieldDeclaration))
375
else if (invocation.Parent.
IsKind
(SyntaxKind.SimpleAssignmentExpression) && invocation.Parent.Parent.
IsKind
(SyntaxKind.ExpressionStatement))
509
if (attrArg.Expression.
IsKind
(SyntaxKind.StringLiteralExpression))
Microsoft.Interop.SourceGeneration (10)
Marshalling\ElementsMarshalling.cs (2)
79
if (numElementsExpression.
IsKind
(SyntaxKind.CheckedExpression))
384
if (contentsCleanupStatements.
IsKind
(SyntaxKind.EmptyStatement))
Marshalling\StatefulMarshallingStrategy.cs (2)
333
if (!elementCleanup.
IsKind
(SyntaxKind.EmptyStatement))
347
if (!elementCleanup.
IsKind
(SyntaxKind.EmptyStatement))
Marshalling\StatelessMarshallingStrategy.cs (2)
574
if (!elementCleanup.
IsKind
(SyntaxKind.EmptyStatement))
624
if (!elementCleanup.
IsKind
(SyntaxKind.EmptyStatement))
SyntaxExtensions.cs (4)
18
if (fixedStatement.Statement.
IsKind
(SyntaxKind.EmptyStatement))
24
if (fixedStatement.Statement.
IsKind
(SyntaxKind.Block))
37
if (childStatement.
IsKind
(SyntaxKind.Block))
66
if (statement.
IsKind
(SyntaxKind.Block))
Microsoft.ML.InternalCodeAnalyzer (15)
BestFriendAnalyzer.cs (1)
66
foreach (var node in model.SyntaxTree.GetRoot().DescendantNodes(n => !n.
IsKind
(SyntaxKind.UsingDirective)))
ContractsCheckAnalyzer.cs (8)
141
if (exp.
IsKind
(SyntaxKind.AddExpression))
149
if (exp.
IsKind
(SyntaxKind.SimpleMemberAccessExpression))
156
if (exp.
IsKind
(SyntaxKind.InvocationExpression))
159
return exp.
IsKind
(SyntaxKind.StringLiteralExpression) || exp.
IsKind
(SyntaxKind.IdentifierName);
164
while (node != null && !node.
IsKind
(SyntaxKind.MethodDeclaration) && !node.
IsKind
(SyntaxKind.ConstructorDeclaration))
209
if (isExcept && invocation.Parent.
IsKind
(SyntaxKind.ExpressionStatement))
ContractsCheckNameofFixProvider.cs (4)
50
Debug.Assert(nameArg.Parent.Parent.
IsKind
(SyntaxKind.InvocationExpression));
74
.Select(p => p.Parent).Where(n => n.
IsKind
(SyntaxKind.IdentifierName));
108
while (temp != null && !temp.
IsKind
(SyntaxKind.MethodDeclaration) && !temp.
IsKind
(SyntaxKind.ConstructorDeclaration))
InstanceInitializerAnalyzer.cs (1)
72
if (!syntax.ChildNodes().Any(s => s.
IsKind
(SyntaxKind.EqualsValueClause)))
SingleVariableDeclarationAnalyzer.cs (1)
44
if (vars.Count <= 1 || node.Parent.
IsKind
(SyntaxKind.ForStatement))
Microsoft.VisualStudio.LanguageServices.CSharp (21)
CodeModel\CSharpCodeModelService.CodeModelEventCollector.cs (1)
36
.Where(n => !n.
IsKind
(SyntaxKind.IncompleteMember))
CodeModel\CSharpCodeModelService.cs (6)
2321
(accessor.Body.Statements.Count == 1 && !accessor.Body.Statements[0].
IsKind
(SyntaxKind.ReturnStatement)))
2611
return property.
IsKind
(SyntaxKind.IndexerDeclaration);
3709
if (node.
IsKind
(SyntaxKind.ClassDeclaration))
3713
else if (node.
IsKind
(SyntaxKind.InterfaceDeclaration))
3734
if (typeDeclaration.
IsKind
(SyntaxKind.ClassDeclaration))
3773
if (!isFirst && node.
IsKind
(SyntaxKind.ClassDeclaration))
LanguageService\CSharpHelpContextService.cs (14)
218
token.Parent.
IsKind
(SyntaxKind.SuppressNullableWarningExpression))
245
if (token.Parent.
IsKind
(SyntaxKind.EqualsValueClause))
247
if (token.Parent.Parent.
IsKind
(SyntaxKind.Parameter))
252
else if (token.Parent.Parent.
IsKind
(SyntaxKind.PropertyDeclaration))
257
else if (token.Parent.Parent.
IsKind
(SyntaxKind.EnumMemberDeclaration))
262
else if (token.Parent.Parent.
IsKind
(SyntaxKind.VariableDeclarator))
268
else if (token.Parent.
IsKind
(SyntaxKind.NameEquals))
270
if (token.Parent.Parent.
IsKind
(SyntaxKind.AnonymousObjectMemberDeclarator))
275
else if (token.Parent.Parent.
IsKind
(SyntaxKind.UsingDirective))
280
else if (token.Parent.Parent.
IsKind
(SyntaxKind.AttributeArgument))
286
else if (token.Parent.
IsKind
(SyntaxKind.LetClause))
309
if (token.Parent.
IsKind
(SyntaxKind.FunctionPointerParameterList))
443
case SyntaxKind.ReturnKeyword when token.Parent.
IsKind
(SyntaxKind.YieldReturnStatement):
444
case SyntaxKind.BreakKeyword when token.Parent.
IsKind
(SyntaxKind.YieldBreakStatement):