1026 references to Kind
Microsoft.CodeAnalysis.CSharp (171)
Binder\Binder.cs (1)
937sub.Add(new TreeDumperNode($"scope", $"{snippet} ({scope.ScopeDesignator?.Kind()})", null));
Binder\Binder.ValueChecks.cs (1)
526Debug.Assert(expr.Syntax.Kind() != SyntaxKind.Argument || valueKind == BindValueKind.RefOrOut);
Binder\Binder_Attributes.cs (1)
288Debug.Assert(boundAttribute.Syntax.Kind() == SyntaxKind.Attribute);
Binder\Binder_Conversions.cs (2)
2715else if (node.Kind() == SyntaxKind.AwaitExpression && memberSymbol.Name == WellKnownMemberNames.GetAwaiter) 2737if (node.Parent != null && node.Parent.Kind() == SyntaxKind.InvocationExpression)
Binder\Binder_Deconstruct.cs (1)
303var elementSyntax = syntax.Kind() == SyntaxKind.TupleExpression ? ((TupleExpressionSyntax)syntax).Arguments[i] : syntax;
Binder\Binder_Expressions.cs (4)
2996switch (syntax.Kind()) 4611typeSyntax: node.Kind() == SyntaxKind.StackAllocArrayCreationExpression 6118Debug.Assert(memberInitializerSyntax.Kind() == SyntaxKind.SimpleAssignmentExpression); 8215(node.Kind() == SyntaxKind.AwaitExpression && plainName == WellKnownMemberNames.GetResult) ||
Binder\Binder_Invocation.cs (2)
1350WarnOnAccessOfOffDefault(node.Kind() == SyntaxKind.InvocationExpression ? 1863switch (expression.Kind())
Binder\Binder_Operators.cs (1)
4511if (node.Operand != operand.Syntax || operand.Syntax.Kind() != SyntaxKind.NumericLiteralExpression)
Binder\Binder_Statements.cs (8)
1691switch (syntax.Kind()) 1739switch (syntax.Kind()) 1752throw ExceptionUtilities.UnexpectedValue(syntax.Kind()); 2260if (sourceType.SpecialType == SpecialType.System_Double && syntax.Kind() == SyntaxKind.NumericLiteralExpression && 2463while (nodeForError.Kind() == SyntaxKind.ParenthesizedExpression) 2468if (nodeForError.Kind() == SyntaxKind.SimpleMemberAccessExpression || nodeForError.Kind() == SyntaxKind.PointerMemberAccessExpression) 3553return IsValidStatementExpression(expressionSyntax, expression) || expressionSyntax.Kind() == SyntaxKind.ThrowExpression;
Binder\Binder_Symbols.cs (1)
2355if (node.Kind() == SyntaxKind.AliasQualifiedName)
Binder\Binder_Unsafe.cs (1)
29Debug.Assert((node.Kind() == SyntaxKind.SizeOfExpression) == ((object)sizeOfTypeOpt != null), "Should have a type for (only) sizeof expressions.");
Binder\BinderFactory.cs (1)
116if ((!InScript || node.Kind() != SyntaxKind.CompilationUnit) && node.Parent != null)
Binder\DecisionDagBuilder.cs (1)
153if (label.Syntax.Kind() != SyntaxKind.DefaultSwitchLabel)
Binder\LocalBinderFactory.cs (1)
93else if (syntax.Kind() != SyntaxKind.Block && (statement = syntax as StatementSyntax) != null)
Binder\Semantics\Conversions\ConversionsBase.cs (1)
1609if (anonymousFunction.Syntax.Kind() == SyntaxKind.AnonymousMethodExpression)
Binder\Semantics\OverloadResolution\OverloadResolutionResult.cs (1)
668else if (nodeOpt?.Kind() == SyntaxKind.AwaitExpression && symbol.Name == WellKnownMemberNames.GetAwaiter)
Binder\SwitchBinder_Patterns.cs (2)
97if (!label.HasErrors && isSubsumed(label, reachableLabels) && label.Syntax.Kind() != SyntaxKind.DefaultSwitchLabel) 120throw ExceptionUtilities.UnexpectedValue(syntax.Kind());
Binder\UsingStatementBinder.cs (2)
92bool isUsingDeclaration = syntax.Kind() == SyntaxKind.LocalDeclarationStatement; 93bool isExpression = !isUsingDeclaration && syntax.Kind() != SyntaxKind.VariableDeclaration;
BoundTree\BoundExpression.cs (1)
23$"Unexpected syntax kind for BoundCall: {this.Syntax.Kind()}");
BoundTree\UnboundLambda.cs (3)
72public MessageID MessageID { get { return Syntax.Kind() == SyntaxKind.AnonymousMethodExpression ? MessageID.IDS_AnonMethod : MessageID.IDS_Lambda; } } 1510public override MessageID MessageID { get { return this.UnboundLambda.Syntax.Kind() == SyntaxKind.AnonymousMethodExpression ? MessageID.IDS_AnonMethod : MessageID.IDS_Lambda; } } 1524switch (syntax.Kind())
BoundTree\VariablePendingInference.cs (4)
37Debug.Assert(this.Syntax.Kind() == SyntaxKind.SingleVariableDesignation || 38(this.Syntax.Kind() == SyntaxKind.DeclarationExpression && 61SyntaxNode typeOrDesignationSyntax = this.Syntax.Kind() == SyntaxKind.DeclarationExpression ? 122switch (this.Syntax.Kind())
CodeGen\EmitStatement.cs (3)
802(local.ScopeDesignatorOpt?.Kind() == SyntaxKind.SwitchSection || local.ScopeDesignatorOpt?.Kind() == SyntaxKind.SwitchExpressionArm)); 1839(local.ScopeDesignatorOpt?.Kind() is SyntaxKind.SwitchSection or SyntaxKind.SwitchExpressionArm)))
Compilation\CSharpCompilation.cs (1)
4803Func<SyntaxNode, SyntaxKind> getKind = node => node.Kind();
Compilation\CSharpSemanticModel.cs (5)
2050boundNodeForSyntacticParent.Syntax.Kind() == SyntaxKind.ObjectCreationExpression && 3382if (expr.Syntax.Kind() is SyntaxKind.ObjectCreationExpression or SyntaxKind.ImplicitObjectCreationExpression) 3409boundNodeForSyntacticParent.Syntax.Kind() == SyntaxKind.ObjectCreationExpression && 3988parentSyntax.Kind() == SyntaxKind.Attribute && ((AttributeSyntax)parentSyntax).Name == boundNode.Syntax) 5096switch (node.Kind())
Compilation\MemberSemanticModel.cs (1)
240SyntaxKind kind = current.Kind();
Compilation\SpeculativeSemanticModelWithMemberModel.cs (1)
150var attributeOrParameter = node.FirstAncestorOrSelf<SyntaxNode>(static n => n.Kind() is SyntaxKind.Attribute or SyntaxKind.Parameter);
Compilation\SyntaxTreeSemanticModel.cs (4)
995if (SyntaxFacts.IsDocumentationCommentTrivia(curr.Kind())) 2471return (node) => node.Kind() != SyntaxKind.GlobalStatement || node.Parent != unit; 2476return (node) => node.Parent != unit || node.Kind() == SyntaxKind.GlobalStatement; 2518!(node.Kind() == SyntaxKind.ArgumentList && node == typeDeclaration.PrimaryConstructorBaseTypeIfClass?.ArgumentList);
Compiler\DocumentationCommentCompiler.DocumentationCommentWalker.cs (1)
141SyntaxKind nodeKind = node.Kind();
Compiler\MethodBodySynthesizer.cs (3)
533Debug.Assert(syntax.Kind() == SyntaxKind.Block || syntax.Kind() == SyntaxKind.ArrowExpressionClause); 554if (syntax.Kind() == SyntaxKind.Block)
Declarations\MergedTypeDeclaration.cs (2)
75switch (typeDecl.Kind()) 95throw ExceptionUtilities.UnexpectedValue(typeDecl.Kind());
FlowAnalysis\NullableWalker.cs (1)
7113if (syntax.Kind() != SyntaxKind.InvocationExpression)
FlowAnalysis\UnassignedAddressTakenVariablesWalker.cs (1)
54if (node.Parent.Kind() == SyntaxKind.AddressOfExpression)
Lowering\ClosureConversion\ClosureConversion.cs (1)
1773switch (curSyntax.Kind())
Lowering\ClosureConversion\LambdaCapturedVariable.cs (2)
101(local.ScopeDesignatorOpt?.Kind() == SyntaxKind.SwitchSection || 102local.ScopeDesignatorOpt?.Kind() == SyntaxKind.SwitchExpressionArm))
Lowering\ClosureConversion\SynthesizedClosureEnvironment.cs (1)
107throw ExceptionUtilities.UnexpectedValue(syntaxOpt.Kind());
Lowering\DiagnosticsPass_ExpressionTrees.cs (1)
635switch (node.Syntax.Kind())
Lowering\DiagnosticsPass_Warnings.cs (1)
38if (local.Syntax.Kind() == SyntaxKind.DeclarationExpression)
Lowering\Instrumentation\CodeCoverageInstrumenter.cs (4)
419SyntaxKind parentKind = returnStatement.ExpressionOpt.Syntax.Parent.Kind(); 460if (!original.IsConstructorInitializer() || original.Syntax.Kind() != SyntaxKind.ConstructorDeclaration) 575switch (parent.Kind()) 595switch (syntax.Kind())
Lowering\Instrumentation\DebugInfoInjector.cs (8)
106throw ExceptionUtilities.UnexpectedValue(original.Syntax.Kind()); 143switch (grandparent.Kind()) 154throw ExceptionUtilities.UnexpectedValue(grandparent.Kind()); 172if (original.WasCompilerGenerated && original.Syntax.Kind() == SyntaxKind.Block) 314switch (original.Syntax.Kind()) 329throw ExceptionUtilities.UnexpectedValue(original.Syntax.Kind()); 388return AddSequencePoint(original.Syntax.Kind() == SyntaxKind.VariableDeclarator ? 406if (original.WasCompilerGenerated && original.ExpressionOpt == null && original.Syntax.Kind() == SyntaxKind.Block)
Lowering\Instrumentation\Instrumenter.cs (19)
50Debug.Assert(!original.WasCompilerGenerated || original.Syntax.Kind() == SyntaxKind.Block); 115Debug.Assert(original.Syntax.Kind() == SyntaxKind.DoStatement); 123Debug.Assert(original.Syntax.Kind() == SyntaxKind.WhileStatement); 131Debug.Assert(original.Syntax.Kind() == SyntaxKind.DoStatement); 138Debug.Assert(original.Syntax.Kind() == SyntaxKind.WhileStatement); 159Debug.Assert(original.Syntax.Kind() == SyntaxKind.ForEachStatement); 166Debug.Assert(original.Syntax.Kind() == SyntaxKind.ForEachVariableStatement); 180Debug.Assert(original.Syntax.Kind() == SyntaxKind.ForStatement); 187Debug.Assert(original.Syntax.Kind() == SyntaxKind.ForStatement); 194Debug.Assert(original.Syntax.Kind() == SyntaxKind.IfStatement); 201Debug.Assert(original.Syntax.Kind() == SyntaxKind.IfStatement); 208Debug.Assert(original.Syntax.Kind() == SyntaxKind.LabeledStatement); 214Debug.Assert(original.Syntax.Kind() == SyntaxKind.VariableDeclarator || 215(original.Syntax.Kind() == SyntaxKind.LocalDeclarationStatement && 259Debug.Assert(original.Syntax.Kind() == SyntaxKind.LockStatement); 270Debug.Assert(original.Syntax.Kind() == SyntaxKind.SwitchStatement); 289Debug.Assert(original.Syntax.Kind() == SyntaxKind.UsingStatement); 302Debug.Assert(original.Syntax.Kind() == SyntaxKind.CatchClause); 309Debug.Assert(original.Syntax.Kind() == SyntaxKind.SwitchStatement);
Lowering\LocalRewriter\LocalRewriter.PatternLocalRewriter.cs (1)
558loweredInput.Syntax.Kind() == SyntaxKind.TupleExpression &&
Lowering\LocalRewriter\LocalRewriter_FixedStatement.cs (2)
87switch (node.Kind()) 144Debug.Assert(node is { } && node.Kind() == SyntaxKind.TryStatement);
Lowering\LocalRewriter\LocalRewriter_LocalDeclaration.cs (2)
76(originalOpt.Syntax.Kind() == SyntaxKind.VariableDeclarator || 77(originalOpt.Syntax.Kind() == SyntaxKind.LocalDeclarationStatement &&
Lowering\LocalRewriter\LocalRewriter_PatternSwitchStatement.cs (1)
50if (section?.Kind() == SyntaxKind.SwitchSection)
Lowering\LocalRewriter\LocalRewriter_ReturnStatement.cs (1)
29(node.Syntax.Kind() == SyntaxKind.Block && _factory.CurrentFunction?.IsAsync == false))))
Lowering\LocalRewriter\LocalRewriter_UsingStatement.cs (1)
51SyntaxToken awaitKeyword = node.Syntax.Kind() == SyntaxKind.UsingStatement ? ((UsingStatementSyntax)node.Syntax).AwaitKeyword : default;
Lowering\LocalRewriter\LocalRewriter_Yield.cs (1)
21(!node.WasCompilerGenerated || (node.Syntax.Kind() == SyntaxKind.Block && _factory.CurrentFunction?.IsAsync == false)))
Lowering\StateMachineRewriter\MethodToStateMachineRewriter.cs (4)
226RoslynDebug.Assert(SyntaxBindingUtilities.BindsToResumableStateMachineState(node) || SyntaxBindingUtilities.BindsToTryStatement(node), $"Unexpected syntax: {node.Kind()}"); 331if ((local.SynthesizedKind == SynthesizedLocalKind.UserDefined && local.ScopeDesignatorOpt?.Kind() != SyntaxKind.SwitchSection) || 764(local.ScopeDesignatorOpt?.Kind() == SyntaxKind.SwitchSection || 765local.ScopeDesignatorOpt?.Kind() == SyntaxKind.SwitchExpressionArm));
Operations\CSharpOperationFactory.cs (3)
2102var kind = node.Kind(); 2751if (boundSwitchLabel.Syntax.Kind() == SyntaxKind.DefaultSwitchLabel) 2783if (boundQueryClause.Syntax.Kind() != SyntaxKind.QueryExpression)
Operations\CSharpOperationFactory_Methods.cs (1)
64Debug.Fail($"Unexpected syntax kind: {syntax.Kind()}");
Parser\Blender.cs (1)
167if (parent.Kind() == SyntaxKind.InterpolatedStringExpression)
Parser\Blender.Cursor.cs (1)
146if (node.Kind() == SyntaxKind.InterpolatedStringExpression)
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (1)
76switch (node.Kind())
Symbols\Source\GlobalExpressionVariable.cs (4)
52Debug.Assert(nodeToBind.Kind() == SyntaxKind.VariableDeclarator || nodeToBind is ExpressionSyntax); 179Debug.Assert(nodeToBind.Kind() == SyntaxKind.VariableDeclarator || nodeToBind is ExpressionSyntax); 189if ((object)_containingFieldOpt != null && nodeToBind.Kind() != SyntaxKind.VariableDeclarator) 198switch (nodeToBind.Kind())
Symbols\Source\SourceLabelSymbol.cs (1)
51if (node.Kind() == SyntaxKind.DefaultSwitchLabel)
Symbols\Source\SourceLocalSymbol.cs (21)
166nodeToBind.Kind() == SyntaxKind.CasePatternSwitchLabel || 167nodeToBind.Kind() == SyntaxKind.ThisConstructorInitializer || 168nodeToBind.Kind() == SyntaxKind.BaseConstructorInitializer || 169nodeToBind.Kind() == SyntaxKind.PrimaryConstructorBaseType || // initializer for a record constructor 170nodeToBind.Kind() == SyntaxKind.SwitchExpressionArm || 171nodeToBind.Kind() == SyntaxKind.ArgumentList && (nodeToBind.Parent is ConstructorInitializerSyntax || nodeToBind.Parent is PrimaryConstructorBaseTypeSyntax) || 172nodeToBind.Kind() == SyntaxKind.GotoCaseStatement || // for error recovery 173nodeToBind.Kind() == SyntaxKind.VariableDeclarator && 177Debug.Assert(!(nodeToBind.Kind() == SyntaxKind.SwitchExpressionArm) || nodeBinder is SwitchExpressionArmBinder); 682switch (_deconstruction.Kind()) 708switch (_deconstruction.Kind()) 741nodeToBind.Kind() == SyntaxKind.CasePatternSwitchLabel || 742nodeToBind.Kind() == SyntaxKind.ThisConstructorInitializer || 743nodeToBind.Kind() == SyntaxKind.BaseConstructorInitializer || 744nodeToBind.Kind() == SyntaxKind.PrimaryConstructorBaseType || // initializer for a record constructor 745nodeToBind.Kind() == SyntaxKind.ArgumentList && (nodeToBind.Parent is ConstructorInitializerSyntax || nodeToBind.Parent is PrimaryConstructorBaseTypeSyntax) || 746nodeToBind.Kind() == SyntaxKind.VariableDeclarator || 747nodeToBind.Kind() == SyntaxKind.SwitchExpressionArm || 748nodeToBind.Kind() == SyntaxKind.GotoCaseStatement || 750Debug.Assert(!(nodeToBind.Kind() == SyntaxKind.SwitchExpressionArm) || nodeBinder is SwitchExpressionArmBinder); 765switch (_nodeToBind.Kind())
Symbols\Source\SourceMemberContainerSymbol.cs (2)
3912switch (syntax.Kind()) 3947throw ExceptionUtilities.UnexpectedValue(syntax.Kind());
Symbols\Source\SourcePropertySymbol.cs (1)
186_ => throw ExceptionUtilities.UnexpectedValue(syntax.Kind())
Syntax\LambdaUtilities.cs (7)
22switch (node.Kind()) 77switch (newLambda.Kind()) 121throw ExceptionUtilities.UnexpectedValue(newLambda.Kind()); 149switch (parent.Kind()) 290switch (node.Kind()) 390switch (node.Kind()) 444switch (node.Parent.Kind())
Syntax\LookupPosition.cs (1)
480switch (lambdaExpressionOrQueryNode.Kind())
Syntax\SyntaxFacts.cs (6)
31if (parent == null || !IsName(node.Kind())) 36switch (parent.Kind()) 322switch (parent4.Kind()) 398switch (syntax.Kind()) 466switch (syntax.Kind()) 563=> IsNestedFunction(child.Kind());
Syntax\SyntaxNodeExtensions.cs (4)
21switch (syntax.Kind()) 35switch (syntax.Kind()) 80SyntaxKind kind = syntax.Kind(); 167switch (parentNode.Kind())
Syntax\SyntaxNormalizer.cs (4)
702if (token.Parent.Parent?.Kind() is not SyntaxKind.TypeArgumentList and not SyntaxKind.UsingDirective) 974switch (token.Parent.Kind(), next.Parent.Kind()) 1345if (node.Parent.Kind() is SyntaxKind.GlobalStatement or SyntaxKind.FileScopedNamespaceDeclaration)
Microsoft.CodeAnalysis.CSharp.Analyzers (1)
MetaAnalyzers\CSharpDiagnosticAnalyzerAPIUsageAnalyzer.cs (1)
16return syntax.Kind() switch
Microsoft.CodeAnalysis.CSharp.CodeStyle (101)
src\Analyzers\CSharp\Analyzers\AddAccessibilityModifiers\CSharpAddAccessibilityModifiers.cs (1)
84switch (member.GetRequiredParent().Kind())
src\Analyzers\CSharp\Analyzers\AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs (3)
66case SyntaxKind.IfStatement when statement.Kind() == SyntaxKind.ElseClause: 88if (statement.Kind() == embeddedStatement.Kind()) 238if (statement.Kind() is not (SyntaxKind.IfStatement or SyntaxKind.ElseClause))
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (2)
102if (invocationOrCreation?.Kind() is not SyntaxKind.InvocationExpression and not SyntaxKind.ObjectCreationExpression) 291switch (current.Kind())
src\Analyzers\CSharp\Analyzers\MisplacedUsingDirectives\MisplacedUsingDirectivesDiagnosticAnalyzer.cs (1)
103t => t.Kind() is not (SyntaxKind.UsingDirective or SyntaxKind.NamespaceDeclaration or SyntaxKind.FileScopedNamespaceDeclaration));
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs (1)
95switch (directive.Kind())
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs (1)
63return codeBlock.Kind() is
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyHelper`1.cs (1)
145declaration.Kind(), languageVersion, conversionPreference, cancellationToken,
src\Analyzers\CSharp\Analyzers\UseExpressionBody\UseExpressionBodyDiagnosticAnalyzer.cs (3)
53var nodeKind = context.Node.Kind(); 60if (grandparent.Kind() == SyntaxKind.PropertyDeclaration && 66if (grandparent.Kind() == SyntaxKind.IndexerDeclaration &&
src\Analyzers\CSharp\Analyzers\UseInferredMemberName\CSharpUseInferredMemberNameDiagnosticAnalyzer.cs (1)
21switch (context.Node.Kind())
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs (2)
43Debug.Assert(enclosingBlock.Kind() is SyntaxKind.Block or SyntaxKind.SwitchSection); 112switch (current.Kind())
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs (1)
275switch (operand.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\BlockSyntaxExtensions.cs (1)
135if (parent.Kind() == SyntaxKind.GetAccessorDeclaration)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (4)
288switch (parent.Kind()) 291if (parent.Parent?.Kind() == SyntaxKind.TupleExpression) 407switch (parent.Kind()) 523switch (expression.Parent.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ILocalSymbolExtensions.cs (1)
17.FirstOrDefault(node => node.Kind() is SyntaxKind.LocalFunctionStatement or SyntaxKind.MethodDeclaration);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (1)
106if (nodeParent.Kind() is SyntaxKind.CheckedExpression or SyntaxKind.UncheckedExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (2)
252if (type.Parent.Kind() 276if (type.Parent.Parent.Parent?.Kind()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (5)
29=> kind = node.Kind(); 92return node?.Kind() 397switch (node.Kind()) 413switch (node.Kind()) 428switch (node.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.DocumentationCommentExteriorCommentRewriter.cs (1)
71if (currentParent.Kind() is SyntaxKind.SingleLineDocumentationCommentTrivia or
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (5)
122=> token.Kind() == SyntaxKind.CommaToken && (token.Parent.IsAnyArgumentList() || token.Parent?.Kind() is SyntaxKind.ParameterList or SyntaxKind.FunctionPointerParameterList); 129if (node.Kind() != SyntaxKind.Block) 134return node.Parent?.Kind() is SyntaxKind.SimpleLambdaExpression or SyntaxKind.ParenthesizedLambdaExpression; 139if (node.Kind() != SyntaxKind.Block) 232switch (parent.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\AnchorIndentationFormattingRule.cs (1)
19if (node.Kind() is SyntaxKind.SimpleLambdaExpression or SyntaxKind.ParenthesizedLambdaExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (2)
227if (node.IsLambdaBodyBlock() || node.IsAnonymousMethodBlock() || node.Kind() is SyntaxKind.PropertyPatternClause or SyntaxKind.SwitchExpression) 267if (node.Parent != null && node.Kind() is SyntaxKind.ListPattern or SyntaxKind.CollectionExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\NewLineUserSettingFormattingRule.cs (4)
49var parentKind = node.Parent?.Kind(); 132if (currentToken.Parent.Kind() is SyntaxKind.ObjectInitializerExpression 344currentToken.Parent.Kind() is SyntaxKind.ObjectInitializerExpression or SyntaxKind.CollectionInitializerExpression or SyntaxKind.WithInitializerExpression or SyntaxKind.PropertyPatternClause) 361currentToken.Parent.Kind() is SyntaxKind.ArrayInitializerExpression or SyntaxKind.ImplicitArrayCreationExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SpacingFormattingRule.cs (8)
49var previousParentKind = previousToken.Parent.Kind(); 50var currentParentKind = currentToken.Parent.Kind(); 163if ((previousToken.Parent.Kind() is SyntaxKind.ParenthesizedExpression or SyntaxKind.ParenthesizedPattern && previousKind == SyntaxKind.OpenParenToken) || 164(currentToken.Parent.Kind() is SyntaxKind.ParenthesizedExpression or SyntaxKind.ParenthesizedPattern && currentKind == SyntaxKind.CloseParenToken)) 208if (currentKind == SyntaxKind.OpenBracketToken && currentToken.Parent.Kind() is SyntaxKind.ListPattern or SyntaxKind.CollectionExpression) 331currentToken.Parent.Kind() is SyntaxKind.AndPattern or SyntaxKind.OrPattern or SyntaxKind.RelationalPattern || 332previousToken.Parent.Kind() is SyntaxKind.AndPattern or SyntaxKind.OrPattern or SyntaxKind.RelationalPattern) 576if (node.Kind()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\TokenBasedFormattingRule.cs (2)
266_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), 388currentToken.Parent?.Kind() is not SyntaxKind.CollectionExpression and not SyntaxKind.AttributeList &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (1)
73endToken.Parent.Parent?.Kind() is SyntaxKind.TryStatement or SyntaxKind.DoStatement;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (3)
117Debug.Assert(oldNode.Kind() == newNode.Kind()); 416=> node.Ancestors().Any(n => n.Kind() is
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (1)
22switch (declaration.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (13)
229_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), 633=> node.Kind() == SyntaxKind.PropertyPatternClause; 713var kind = node.Kind(); 803switch (node.Kind()) 864Debug.Fail("Unexpected node type " + node.Kind()); 1111=> node?.Parent?.Kind() is SyntaxKind.PostIncrementExpression or SyntaxKind.PreIncrementExpression; 1114=> node?.Parent?.Kind() is SyntaxKind.PostDecrementExpression or SyntaxKind.PreDecrementExpression; 1162=> SyntaxFacts.IsDocumentationCommentTrivia(node.Kind()); 1165=> node?.Kind() is SyntaxKind.UsingDirective or SyntaxKind.ExternAliasDirective; 1183if (SyntaxFacts.IsNamespaceMemberDeclaration(node.Kind())) 1199switch (node.Kind()) 1204return node.Parent?.Parent?.Kind() is SyntaxKind.FieldDeclaration or SyntaxKind.EventFieldDeclaration; 1228=> SyntaxFacts.IsTypeDeclaration(node.Kind());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (8)
230if (castSyntax.WalkUpParentheses().GetRequiredParent().Kind() is SyntaxKind.BitwiseOrExpression or SyntaxKind.OrAssignmentExpression) 1178Debug.Assert(currentOld.Kind() == currentNew.Kind()); 1234Debug.Assert(currentOld.Kind() == currentNew.Kind()); 1235if (!haveHitArgumentNode && currentOld.Kind() != SyntaxKind.Argument) 1264Debug.Assert(currentOld.Kind() == currentNew.Kind());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (6)
99if (parent.Kind() is SyntaxKind.StringLiteralExpression or 115if (parent == null || parent.Kind() == SyntaxKind.SkippedTokensTrivia) 172if (parent == null || parent.Kind() == SyntaxKind.SkippedTokensTrivia) 272if (parent == null || parent.Kind() == SyntaxKind.SkippedTokensTrivia) 356node.Kind() is SyntaxKind.IfStatement or 439if (token.Parent.Kind() is SyntaxKind.Block or
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (13)
82if (node.Kind() is not SyntaxKind.PrimaryConstructorBaseType || 83previousNode.Kind() is SyntaxKind.ArgumentList) 97node.Kind() is SyntaxKind.Attribute or 109node => node.Kind() is SyntaxKind.UnknownAccessorDeclaration or SyntaxKind.IncompleteMember or SyntaxKind.BracketedArgumentList), 156switch (nodeToSpeculate.Kind()) 300if (currentOriginalNode.Kind() is SyntaxKind.CaseSwitchLabel or SyntaxKind.ConstantPattern) 315else if (currentOriginalNode.Kind() == SyntaxKind.LogicalNotExpression) 319else if (currentOriginalNode.Kind() == SyntaxKind.ConditionalAccessExpression) 336else if (currentOriginalNode.Kind() == SyntaxKind.VariableDeclarator) 515else if (currentOriginalNode.Kind() == SyntaxKind.CollectionInitializerExpression) 520else if (currentOriginalNode.Kind() == SyntaxKind.ImplicitArrayCreationExpression) 529else if (currentOriginalNode.Kind() == SyntaxKind.DefaultExpression) 581=> node.Kind() is
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.cs (2)
61if (typeName?.FirstAncestorOrSelf<SyntaxNode>(a => a.Kind() is SyntaxKind.DeclarationExpression or SyntaxKind.VariableDeclaration or SyntaxKind.ForEachStatement) is not { } declaration) 83Debug.Assert(node.Kind() is SyntaxKind.VariableDeclaration or SyntaxKind.ForEachStatement or SyntaxKind.DeclarationExpression);
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (39)
src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (1)
46if (node.Kind() is not SyntaxKind.MethodDeclaration and not SyntaxKind.PropertyDeclaration and not SyntaxKind.VariableDeclarator)
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (1)
228if (token.IsKind(SyntaxKind.HashToken) && token.Parent!.Kind() is not (SyntaxKind.RegionDirectiveTrivia or SyntaxKind.EndRegionDirectiveTrivia))
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (1)
299=> throw ExceptionUtilities.UnexpectedValue(node.Kind());
src\Analyzers\CSharp\CodeFixes\GenerateEnumMember\CSharpGenerateEnumMemberService.cs (1)
41if (simpleNameOrMemberAccessExpression.GetRequiredParent().Kind()
src\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateConversionCodeFixProvider.cs (1)
36return node.Kind()
src\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateDeconstructMethodCodeFixProvider.cs (1)
46.FirstOrDefault(n => n.Kind() is SyntaxKind.SimpleAssignmentExpression or SyntaxKind.ForEachVariableStatement or SyntaxKind.PositionalPatternClause);
src\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateMethodCodeFixProvider.cs (1)
55return node.Kind()
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (2)
119a => a.Kind() is 315=> node.Kind() is
src\Analyzers\CSharp\CodeFixes\RemoveConfusingSuppression\CSharpRemoveConfusingSuppressionCodeFixProvider.cs (2)
69Debug.Assert(node.Kind() is SyntaxKind.IsExpression or SyntaxKind.IsPatternExpression); 77n => n.Kind() is SyntaxKind.IsExpression or SyntaxKind.IsPatternExpression);
src\Analyzers\CSharp\CodeFixes\RemoveUnreachableCode\CSharpRemoveUnreachableCodeCodeFixProvider.cs (1)
82if (statement.Parent?.Kind()
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (4)
46switch (node.Kind()) 86Debug.Fail($"Unexpected node kind for local/parameter declaration or reference: '{node.Kind()}'"); 205Debug.Fail($"Unexpected kind for originalCompoundAssignment: {originalCompoundAssignment.Kind()}"); 231var mappedBinaryExpressionKind = originalCompoundAssignment.Kind().MapCompoundAssignmentKindToBinaryExpressionKind();
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
79throw ExceptionUtilities.UnexpectedValue(declarationContext?.Kind());
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (1)
552=> memberDeclaration.GetLeadingTrivia().Any(t => t.GetStructure()?.Kind() == SyntaxKind.PragmaWarningDirectiveTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
230return destination.Kind() switch
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpDeclarationComparer.cs (8)
88if (x.Kind() != y.Kind()) 90if (!s_kindPrecedenceMap.TryGetValue(x.Kind(), out var xPrecedence) || 91!s_kindPrecedenceMap.TryGetValue(y.Kind(), out var yPrecedence)) 101switch (x.Kind()) 152throw ExceptionUtilities.UnexpectedValue(x.Kind()); 347if (node.Kind() == SyntaxKind.InterfaceDeclaration) 352else if (node.Kind() is SyntaxKind.StructDeclaration or SyntaxKind.ClassDeclaration or SyntaxKind.RecordDeclaration or SyntaxKind.RecordStructDeclaration)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Editing\CSharpImportAdder.cs (1)
164switch (node.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (5)
135if (token.Parent.Parent.Kind() is not SyntaxKind.TryStatement and not SyntaxKind.DoStatement) 138else if (token.Parent.Parent?.Kind() 163return parent?.Kind() 455if (owner?.Kind() 470if (targetToken.Parent?.Parent?.Kind()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (3)
2345previousToken.Parent?.Kind() is SyntaxKind.PointerType or SyntaxKind.NullableType) 2914switch (name.Parent.Kind()) 2955block.Parent?.Kind() is SyntaxKind.TryStatement or SyntaxKind.CatchClause)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\NameSyntaxExtensions.cs (1)
35if (nameSyntax.Parent?.Kind()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\CSharpSimplificationHelpers.cs (2)
34if (parentOfToken is SimpleNameSyntax && parent.Kind() == SyntaxKind.XmlNameAttribute) 41if (parent.Kind() == SyntaxKind.AliasQualifiedName &&
Microsoft.CodeAnalysis.CSharp.EditorFeatures (7)
CompleteStatement\CompleteStatementCommandHandler.cs (6)
209if (currentNode.Kind() is 276if (currentNode.Kind() is SyntaxKind.FieldDeclaration or SyntaxKind.DelegateDeclaration or SyntaxKind.ArrowExpressionClause) 340m[nameof(statementNode)] = statementNode.Kind(); 369switch (statementNode.Kind()) 483if (currentNode.Kind() is not (SyntaxKind.InterpolatedStringExpression or SyntaxKind.StringLiteralExpression or SyntaxKind.Utf8StringLiteralExpression or SyntaxKind.CharacterLiteralExpression)) 538switch (currentNode.Kind())
Interactive\CSharpSendToInteractiveSubmissionProvider.cs (1)
112var kind = node.Kind();
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
Diagnostics\DiagnosticAnalyzerDriver\DiagnosticAnalyzerDriverTests.cs (1)
327Assert.NotEqual(SyntaxKind.MethodDeclaration, context.Node.Kind());
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (2)
CodeGen\CodeGenDeconstructTests.cs (2)
5001Assert.False(nodes.Any(n => n.Kind() == SyntaxKind.SimpleAssignmentExpression)); 5124Assert.True(nodes.Any(n => n.Kind() == SyntaxKind.SimpleAssignmentExpression));
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (3)
Emit\EditAndContinue\EditAndContinueTestBase.cs (1)
115switch (node.Kind())
Emit\NumericIntPtrTests.cs (2)
6627var expr = tree.GetRoot().DescendantNodes().Single(n => n.Kind() == kind); 6859var expr = tree.GetRoot().DescendantNodes().Single(n => n.Kind() == kind);
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (19)
Attributes\AttributeTests.cs (1)
3123Assert.Equal(SyntaxKind.Attribute, attrs[0].ApplicationSyntaxReference.GetSyntax().Kind());
Diagnostics\DiagnosticAnalyzerTests.cs (4)
251switch (context.Node.Kind()) 808switch (CSharpExtensions.Kind(context.Node.Parent)) 4135var diagnostic = CodeAnalysis.Diagnostic.Create(Rule, context.Node.GetLocation(), context.Node.Kind(), context.ContainingSymbol.Name); 4153var syntaxKinds = baseListNode.DescendantNodesAndSelf().Select(node => node.Kind()).Distinct().AsImmutable();
Diagnostics\GetDiagnosticsTests.cs (2)
1099throw new Exception($"Unexpected topmost node for code block '{context.CodeBlock.Kind()}'"); 1118throw new Exception($"Unexpected topmost node for operation block '{operationBlock.Syntax.Kind()}'");
Semantics\OutVarTests.cs (1)
1181if (parent.Kind() == SyntaxKind.VariableDeclarator)
Semantics\PrimaryConstructorTests.cs (6)
4329Assert.Equal(SyntaxKind.ClassDeclaration, context.Operation.Syntax.Kind()); 4333Assert.Equal(SyntaxKind.ClassDeclaration, context.Operation.Syntax.Kind()); 4337Assert.Equal(SyntaxKind.ConstructorDeclaration, context.Operation.Syntax.Kind()); 4351Assert.Equal(SyntaxKind.PrimaryConstructorBaseType, context.Operation.Syntax.Kind()); 4366Assert.Equal(SyntaxKind.BaseConstructorInitializer, context.Operation.Syntax.Kind()); 5697Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind());
Semantics\RecordTests.cs (5)
26896Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind()); 26900Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind()); 26904Assert.Equal(SyntaxKind.ConstructorDeclaration, context.Operation.Syntax.Kind()); 26918Assert.Equal(SyntaxKind.PrimaryConstructorBaseType, context.Operation.Syntax.Kind()); 26933Assert.Equal(SyntaxKind.BaseConstructorInitializer, context.Operation.Syntax.Kind());
Microsoft.CodeAnalysis.CSharp.Features (179)
AddImport\CSharpAddImportFeatureService.cs (3)
114if (nameNode?.Parent?.Kind() is not SyntaxKind.SimpleMemberAccessExpression and not SyntaxKind.MemberBindingExpression) 119if (memberAccess?.Parent?.Kind() is SyntaxKind.SimpleMemberAccessExpression or SyntaxKind.ElementAccessExpression || 120memberBinding?.Parent?.Kind() is SyntaxKind.SimpleMemberAccessExpression or SyntaxKind.ElementAccessExpression)
BraceCompletion\CurlyBraceCompletionService.cs (1)
206var parentKind = node?.Parent?.Kind();
ChangeSignature\ChangeSignatureFormattingRule.cs (2)
32if (s_allowableKinds.Contains(node.Kind())) 54if (previousToken.Kind() == SyntaxKind.CommaToken && s_allowableKinds.Contains(previousToken.Parent.Kind()))
ChangeSignature\CSharpChangeSignatureService.cs (8)
202current.Kind() == SyntaxKind.Block || current.Kind() == SyntaxKind.ArrowExpressionClause) 207if (matchKinds.Contains(current.Kind())) 241if (_updatableNodeKinds.Contains(node.Kind())) 247var matchingNode = node.AncestorsAndSelf().FirstOrDefault(n => _updatableAncestorKinds.Contains(n.Kind())); 264switch (matchingNode.Kind()) 639_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()) 916_ => throw ExceptionUtilities.UnexpectedValue(newArgument.Kind())
ChangeSignature\UnifiedArgumentSyntax.cs (1)
19Debug.Assert(argument.Kind() is SyntaxKind.Argument or SyntaxKind.AttributeArgument);
CodeLens\CSharpCodeLensDisplayInfoService.cs (3)
37switch (node.Kind()) 102switch (node.Kind()) 184while (scopeNode != null && !SyntaxFacts.IsNamespaceMemberDeclaration(scopeNode.Kind()))
CodeRefactorings\ConvertLocalFunctionToMethod\CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs (1)
153switch (node.Kind())
CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.cs (3)
115else if (identifierNode.Parent.Kind() is 307if (descendantNodesAndSelf.Any(n => n.Kind() is SyntaxKind.ObjectCreationExpression or SyntaxKind.InvocationExpression)) 506while (parent.Kind() is SyntaxKind.ParenthesizedExpression or SyntaxKind.CastExpression)
CodeRefactorings\UseExplicitOrImplicitType\AbstractUseTypeCodeRefactoringProvider.cs (1)
41Debug.Assert(declaration.Kind() is SyntaxKind.VariableDeclaration or SyntaxKind.ForEachStatement or SyntaxKind.DeclarationExpression);
Completion\CompletionProviders\AwaitCompletionProvider.cs (2)
48_ => throw ExceptionUtilities.UnexpectedValue(declaration.Kind()) 63_ => throw ExceptionUtilities.UnexpectedValue(declaration.Kind())
Completion\CompletionProviders\CompletionUtilities.cs (1)
167symbol.DeclaringSyntaxReferences[0].GetSyntax().Kind() == SyntaxKind.DefaultSwitchLabel)
Completion\CompletionProviders\CrefCompletionProvider.cs (1)
137if (token.Parent?.Kind() is not (SyntaxKind.CrefParameterList or SyntaxKind.CrefBracketedParameterList))
Completion\CompletionProviders\CSharpSuggestionModeCompletionProvider.cs (2)
144token.GetRequiredParent().Kind() == SyntaxKind.ParenthesizedExpression) 152token.GetRequiredParent().Kind() == SyntaxKind.CastExpression)
Completion\CompletionProviders\ExplicitInterfaceMemberCompletionProvider.cs (1)
80var kind = ancestor.Kind();
Completion\CompletionProviders\ExplicitInterfaceTypeCompletionProvider.cs (1)
142=> node.Kind() is SyntaxKind.ClassDeclaration or SyntaxKind.StructDeclaration or
Completion\CompletionProviders\ObjectAndWithInitializerCompletionProvider.cs (1)
126token.Parent.Kind() is not (SyntaxKind.ObjectInitializerExpression or SyntaxKind.WithInitializerExpression))
Completion\CompletionProviders\Scripting\DirectiveCompletionProviderUtilities.cs (1)
22if (token.Kind() == SyntaxKind.StringLiteralToken && token.Parent!.Kind() == directiveKind)
Completion\CompletionProviders\SymbolCompletionProvider.cs (1)
186if (token.Parent?.Kind() is not (SyntaxKind.ArgumentList or SyntaxKind.BracketedArgumentList or SyntaxKind.AttributeArgumentList or SyntaxKind.ArrayRankSpecifier))
Completion\CompletionProviders\XmlDocCommentCompletionProvider.cs (1)
143if (token.Parent?.Kind() is SyntaxKind.XmlEmptyElement or SyntaxKind.XmlText ||
Completion\KeywordRecommenders\AssemblyKeywordRecommender.cs (1)
19token.GetRequiredParent().Kind() == SyntaxKind.AttributeList)
Completion\KeywordRecommenders\RefKeywordRecommender.cs (3)
203return parent?.Kind() == SyntaxKind.SimpleAssignmentExpression 204|| parent?.Parent?.Kind() == SyntaxKind.VariableDeclarator; 211return token.Parent?.Kind() == SyntaxKind.ConditionalExpression;
ConvertLinq\ConvertForEachToLinqQuery\AbstractConverter.cs (2)
69switch (node.Node.Kind()) 235switch (node.Node.Kind())
ConvertLinq\ConvertForEachToLinqQuery\AbstractToMethodConverter.cs (1)
145switch (node.Kind())
ConvertLinq\CSharpConvertLinqQueryToForEachProvider.cs (4)
225switch (parent.Kind()) 457switch (invocationParent.Kind()) 461if (invocationParent?.Parent.Kind() is 928switch (node.Kind())
Debugging\CSharpProximityExpressionsService_ExpressionTermCollector.cs (1)
189memberAccessExpression.Parent?.Kind() is not SyntaxKind.SimpleMemberAccessExpression and not SyntaxKind.PointerMemberAccessExpression)
Debugging\LocationInfoGetter.cs (2)
32if ((memberDeclaration == null) || (memberDeclaration.Kind() == SyntaxKind.GlobalStatement)) 40if (memberDeclaration.Kind() is SyntaxKind.FieldDeclaration or SyntaxKind.EventFieldDeclaration)
Diagnostics\Analyzers\CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs (3)
40return codeBlock.Kind() is 79=> node != null && s_kindsOfInterest.Contains(node.Kind()); 129else if (node.Kind() == SyntaxKind.SimpleMemberAccessExpression)
DocumentationComments\CSharpDocumentationCommentSnippetService.cs (1)
141var throwExpressionsAndStatements = member.DescendantNodes().Where(n => n.Kind() is SyntaxKind.ThrowExpression or SyntaxKind.ThrowStatement);
EditAndContinue\BreakpointSpans.cs (3)
172switch (node.Kind()) 774=> declaration.Parent!.Kind() switch 949switch (parent.Kind())
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (36)
74switch (current.Kind()) 138switch (current.Parent.Parent!.Kind()) 213switch (node.Kind()) 581switch (node.Kind()) 684switch (parent.Kind()) 740switch (node.Kind()) 759if (oldStatement.Kind() != newStatement.Kind()) 764switch (oldStatement.Kind()) 910=> node.Kind() is SyntaxKind.RecordDeclaration or SyntaxKind.RecordStructDeclaration; 1382if (node.Kind() is SyntaxKind.UsingDirective or SyntaxKind.NamespaceDeclaration or SyntaxKind.FileScopedNamespaceDeclaration) 1496switch (oldNode.Kind()) 1602=> TryGetDiagnosticSpanImpl(node.Kind(), node, editKind); 1940switch (lambda.Kind()) 1990=> TryGetDisplayNameImpl(node, editKind) ?? throw ExceptionUtilities.UnexpectedValue(node.Kind()); 1994switch (node.Kind()) 2104return node.Parent!.Kind() switch 2223throw ExceptionUtilities.UnexpectedValue(node.Kind()); 2258switch (node.Kind()) 2380switch (newNode.Kind()) 2396switch (node.Kind()) 2420switch (oldNode.Kind()) 2446switch (newNode.Kind()) 2490if (node.Kind() is SyntaxKind.StackAllocArrayCreationExpression or SyntaxKind.ImplicitStackAllocArrayCreationExpression) 2576var kind = current.Kind(); 2594RoslynDebug.Assert(current.Parent.Kind() == SyntaxKind.TryStatement); 2640switch (oldNode.Kind()) 2653throw ExceptionUtilities.UnexpectedValue(oldNode.Kind()); 2674switch (node.Kind()) 2702throw ExceptionUtilities.UnexpectedValue(node.Kind()); 2740switch (node.Parent.Kind()) 2773switch (containingStatementPart.Kind()) 2806switch (statement.Kind()) 2816throw ExceptionUtilities.UnexpectedValue(statement.Kind()); 2955switch (node.Kind()) 3043nodeSelector: static n => n.Kind() is SyntaxKind.ForEachStatement or SyntaxKind.ForEachVariableStatement,
EditAndContinue\SyntaxComparer.cs (7)
709switch (left.Kind()) 777switch (leftNode.Kind()) 974switch (nestedFunction.Kind()) 1029throw ExceptionUtilities.UnexpectedValue(nestedFunction.Kind()); 1053switch (leftBlock.Parent.Kind()) 1109throw ExceptionUtilities.UnexpectedValue(leftBlock.Parent.Kind()); 1413switch (node.Kind())
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (4)
343if (ancestors.Where(a => CSharp.SyntaxFacts.IsTypeDeclaration(a.Kind())) 537return contextNode.Kind(); 700.Where(n => n.Kind() is SyntaxKind.DeclarationExpression or SyntaxKind.DeclarationPattern); 704switch (node.Kind())
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.ExpressionCodeGenerator.cs (4)
46expression.Parent.Kind() == SyntaxKind.EqualsValueClause && 48expression.Parent.Parent.Kind() == SyntaxKind.VariableDeclarator) 63switch (expression.Kind()) 76throw new System.NotSupportedException("Unexpected name kind: " + expression.Kind().ToString());
ExtractMethod\CSharpMethodExtractor.FormattingProvider.cs (1)
62if (node.Kind() is SyntaxKind.SimpleLambdaExpression or SyntaxKind.ParenthesizedLambdaExpression or SyntaxKind.AnonymousMethodExpression)
ExtractMethod\CSharpSelectionValidator.cs (2)
120if (ancestor.Kind() is SyntaxKind.BaseConstructorInitializer or SyntaxKind.ThisConstructorInitializer) 339if (commonNode.Kind() == SyntaxKind.IsPatternExpression)
GenerateType\CSharpGenerateTypeService.cs (2)
95return baseList.Parent.Kind() is 644if (baseList.Parent.Kind() is SyntaxKind.InterfaceDeclaration or SyntaxKind.StructDeclaration or SyntaxKind.RecordStructDeclaration)
GoToDefinition\CSharpGoToDefinitionSymbolService.cs (3)
94var kind = node.Kind(); 113SyntaxFacts.GetTypeDeclarationKind(node.Kind()) != SyntaxKind.None) 128if (SyntaxFacts.GetTypeDeclarationKind(node.Kind()) != SyntaxKind.None)
Highlighting\KeywordHighlighters\IfStatementHighlighter.cs (1)
34if (ifStatement.Parent.Kind() != SyntaxKind.ElseClause)
InlineHints\CSharpInlineTypeHintsService.cs (1)
80return parameterNode.Parent?.Parent?.Kind() is SyntaxKind.ParenthesizedLambdaExpression
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (2)
46=> node.Kind() is SyntaxKind.Block or SyntaxKind.SwitchSection; 49=> node.Kind() is SyntaxKind.Block or SyntaxKind.EmptyStatement;
LineSeparators\CSharpLineSeparatorService.cs (2)
71if (SyntaxFacts.IsTypeDeclaration(node.Kind())) 76switch (node.Kind())
MetadataAsSource\FormattingRule.cs (3)
38if (previousToken.Kind() == SyntaxKind.SemicolonToken && previousToken.Parent.Kind() == SyntaxKind.UsingDirective) 49if (previousMember.Kind() == nextMember.Kind())
QuickInfo\CSharpSyntacticQuickInfoProvider.cs (1)
98&& node.Parent?.Kind() is SyntaxKind.Block or SyntaxKind.SwitchSection or SyntaxKind.GlobalStatement;
RemoveUnusedVariable\CSharpRemoveUnusedVariableCodeFixProvider.cs (3)
41if (node.Kind() == SyntaxKind.SimpleAssignmentExpression) 44if (parent.Kind() == SyntaxKind.ExpressionStatement) 59switch (node.Kind())
ReplaceDocCommentTextWithTag\CSharpReplaceDocCommentTextWithTagCodeRefactoringProvider.cs (1)
27=> token.GetRequiredParent().Kind() is SyntaxKind.XmlCrefAttribute or SyntaxKind.XmlNameAttribute or SyntaxKind.XmlTextAttribute;
SimplifyTypeNames\SimplifyTypeNamesCodeFixProvider.cs (1)
56if (annotatedexpressionSyntax.Kind() is SyntaxKind.IsExpression or SyntaxKind.AsExpression)
src\Analyzers\CSharp\Analyzers\AddAccessibilityModifiers\CSharpAddAccessibilityModifiers.cs (1)
84switch (member.GetRequiredParent().Kind())
src\Analyzers\CSharp\Analyzers\AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs (3)
66case SyntaxKind.IfStatement when statement.Kind() == SyntaxKind.ElseClause: 88if (statement.Kind() == embeddedStatement.Kind()) 238if (statement.Kind() is not (SyntaxKind.IfStatement or SyntaxKind.ElseClause))
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (2)
102if (invocationOrCreation?.Kind() is not SyntaxKind.InvocationExpression and not SyntaxKind.ObjectCreationExpression) 291switch (current.Kind())
src\Analyzers\CSharp\Analyzers\MisplacedUsingDirectives\MisplacedUsingDirectivesDiagnosticAnalyzer.cs (1)
103t => t.Kind() is not (SyntaxKind.UsingDirective or SyntaxKind.NamespaceDeclaration or SyntaxKind.FileScopedNamespaceDeclaration));
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs (1)
95switch (directive.Kind())
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs (1)
63return codeBlock.Kind() is
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyHelper`1.cs (1)
145declaration.Kind(), languageVersion, conversionPreference, cancellationToken,
src\Analyzers\CSharp\Analyzers\UseExpressionBody\UseExpressionBodyDiagnosticAnalyzer.cs (3)
53var nodeKind = context.Node.Kind(); 60if (grandparent.Kind() == SyntaxKind.PropertyDeclaration && 66if (grandparent.Kind() == SyntaxKind.IndexerDeclaration &&
src\Analyzers\CSharp\Analyzers\UseInferredMemberName\CSharpUseInferredMemberNameDiagnosticAnalyzer.cs (1)
21switch (context.Node.Kind())
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs (2)
43Debug.Assert(enclosingBlock.Kind() is SyntaxKind.Block or SyntaxKind.SwitchSection); 112switch (current.Kind())
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs (1)
275switch (operand.Kind())
src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (1)
46if (node.Kind() is not SyntaxKind.MethodDeclaration and not SyntaxKind.PropertyDeclaration and not SyntaxKind.VariableDeclarator)
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (1)
228if (token.IsKind(SyntaxKind.HashToken) && token.Parent!.Kind() is not (SyntaxKind.RegionDirectiveTrivia or SyntaxKind.EndRegionDirectiveTrivia))
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (1)
299=> throw ExceptionUtilities.UnexpectedValue(node.Kind());
src\Analyzers\CSharp\CodeFixes\GenerateEnumMember\CSharpGenerateEnumMemberService.cs (1)
41if (simpleNameOrMemberAccessExpression.GetRequiredParent().Kind()
src\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateConversionCodeFixProvider.cs (1)
36return node.Kind()
src\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateDeconstructMethodCodeFixProvider.cs (1)
46.FirstOrDefault(n => n.Kind() is SyntaxKind.SimpleAssignmentExpression or SyntaxKind.ForEachVariableStatement or SyntaxKind.PositionalPatternClause);
src\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateMethodCodeFixProvider.cs (1)
55return node.Kind()
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (2)
119a => a.Kind() is 315=> node.Kind() is
src\Analyzers\CSharp\CodeFixes\RemoveConfusingSuppression\CSharpRemoveConfusingSuppressionCodeFixProvider.cs (2)
69Debug.Assert(node.Kind() is SyntaxKind.IsExpression or SyntaxKind.IsPatternExpression); 77n => n.Kind() is SyntaxKind.IsExpression or SyntaxKind.IsPatternExpression);
src\Analyzers\CSharp\CodeFixes\RemoveUnreachableCode\CSharpRemoveUnreachableCodeCodeFixProvider.cs (1)
82if (statement.Parent?.Kind()
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (4)
46switch (node.Kind()) 86Debug.Fail($"Unexpected node kind for local/parameter declaration or reference: '{node.Kind()}'"); 205Debug.Fail($"Unexpected kind for originalCompoundAssignment: {originalCompoundAssignment.Kind()}"); 231var mappedBinaryExpressionKind = originalCompoundAssignment.Kind().MapCompoundAssignmentKindToBinaryExpressionKind();
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
79throw ExceptionUtilities.UnexpectedValue(declarationContext?.Kind());
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (1)
552=> memberDeclaration.GetLeadingTrivia().Any(t => t.GetStructure()?.Kind() == SyntaxKind.PragmaWarningDirectiveTrivia)
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (1)
76switch (node.Kind())
src\Compilers\CSharp\Portable\Syntax\LambdaUtilities.cs (7)
22switch (node.Kind()) 77switch (newLambda.Kind()) 121throw ExceptionUtilities.UnexpectedValue(newLambda.Kind()); 149switch (parent.Kind()) 290switch (node.Kind()) 390switch (node.Kind()) 444switch (node.Parent.Kind())
Structure\Providers\ArrowExpressionClauseStructureProvider.cs (1)
32autoCollapse: parent.Kind() != SyntaxKind.LocalFunctionStatement));
Structure\Providers\BlockSyntaxStructureProvider.cs (2)
29var parentKind = parent.Kind(); 204=> (parent?.Kind()) switch
UseExpressionBody\UseExpressionBodyCodeRefactoringProvider.cs (2)
152if (helper.SyntaxKinds.Contains(current.Kind())) 217if (!helper.IsRelevantDeclarationNode(node) || !helper.SyntaxKinds.Contains(node.Kind()))
Wrapping\SeparatedSyntaxList\CSharpParameterWrapper.cs (1)
54if (declaration.Kind() == SyntaxKind.SimpleLambdaExpression)
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (2)
Diagnostics\Suppression\SuppressionTests.cs (2)
1117switch (context.Node.Kind()) 2187switch (context.Node.Kind())
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (14)
Semantics\BindingTests.cs (1)
3734Assert.Equal(SyntaxKind.QualifiedName, node1.Kind());
Semantics\ForEachTests.cs (1)
3421var node = tree.GetRoot().DescendantNodes().Where(n => n.Kind() == SyntaxKind.ForEachStatement).OfType<ForEachStatementSyntax>().Single();
Semantics\LocalFunctionTests.cs (1)
7643.Where(i => i.Ancestors().Any(a => a.Kind() is SyntaxKind.Attribute or SyntaxKind.TypeConstraint or SyntaxKind.DefaultExpression or SyntaxKind.InvocationExpression or SyntaxKind.EqualsValueClause))
Semantics\NativeIntegerTests.cs (2)
10112var expr = tree.GetRoot().DescendantNodes().Single(n => n.Kind() == kind); 10337var expr = tree.GetRoot().DescendantNodes().Single(n => n.Kind() == kind);
Semantics\RecordStructTests.cs (1)
6494Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind());
Semantics\TopLevelStatementsTests.cs (8)
6724Assert.Equal(SyntaxKind.InvocationExpression, context.Operation.Syntax.Kind()); 6744Assert.Equal(SyntaxKind.CompilationUnit, context.Operation.Syntax.Kind()); 6802Assert.Equal(SyntaxKind.CompilationUnit, context.OperationBlocks.Single().Syntax.Kind()); 6860Assert.Equal(SyntaxKind.CompilationUnit, context.OperationBlocks.Single().Syntax.Kind()); 6918Assert.Equal(SyntaxKind.CompilationUnit, context.CodeBlock.Kind()); 6986Assert.Equal(SyntaxKind.CompilationUnit, context.CodeBlock.Kind()); 7354Assert.Equal(SyntaxKind.CompilationUnit, context.OperationBlocks.Single().Syntax.Kind()); 7422Assert.Equal(SyntaxKind.CompilationUnit, context.Operation.Syntax.Kind());
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (54)
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (9)
3389Assert.Equal(SyntaxKind.IncompleteMember, node.Kind()); 3478Assert.Equal(SyntaxKind.ForEachStatement, foreachNode.Kind()); 3502Assert.Equal(SyntaxKind.ForEachStatement, foreachNode.Kind()); 3529Assert.Equal(SyntaxKind.ForEachStatement, foreachNode1.Kind()); 3535Assert.Equal(SyntaxKind.ForEachStatement, foreachNode2.Kind()); 3566Assert.Equal(SyntaxKind.CatchDeclaration, catchDeclaration.Kind()); 3587Assert.Equal(SyntaxKind.LocalFunctionStatement, methodDecl.Kind()); 3612Assert.Equal(SyntaxKind.MethodDeclaration, methodDecl.Kind()); 5131Assert.Equal(SyntaxKind.IncompleteMember, node.Kind());
Compilation\SemanticModelGetSemanticInfoTests.cs (1)
15429var syntax = tree.GetCompilationUnitRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.ThisExpression);
SymbolDisplay\SymbolDisplayTests.cs (13)
6725.Where(n => n.Kind() == SyntaxKind.LocalFunctionStatement) 6768.Where(n => n.Kind() == SyntaxKind.LocalFunctionStatement) 6802.Where(n => n.Kind() == SyntaxKind.LocalFunctionStatement) 6897.Where(n => n.Kind() == SyntaxKind.LocalFunctionStatement) 7154var declarations = semanticModel.SyntaxTree.GetRoot().DescendantNodes().Where(n => n.Kind() == SyntaxKind.StructDeclaration).Cast<BaseTypeDeclarationSyntax>().ToArray(); 7192var declarations = semanticModel.SyntaxTree.GetRoot().DescendantNodes().Where(n => n.Kind() == SyntaxKind.StructDeclaration).Cast<BaseTypeDeclarationSyntax>().ToArray(); 7230var declarations = semanticModel.SyntaxTree.GetRoot().DescendantNodes().Where(n => n.Kind() == SyntaxKind.StructDeclaration).Cast<BaseTypeDeclarationSyntax>().ToArray(); 7290var declaration = (BaseTypeDeclarationSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.StructDeclaration); 7362var declaration = (BaseTypeDeclarationSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.StructDeclaration); 7622var declaration = (BaseTypeDeclarationSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.StructDeclaration); 7775var declaration = (BaseTypeDeclarationSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.StructDeclaration); 8514var declaration = (LocalDeclarationStatementSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.LocalDeclarationStatement); 8565var declaration = (LocalDeclarationStatementSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.LocalDeclarationStatement);
Symbols\EnumTests.cs (1)
353var expr = tree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.BitwiseNotExpression);
Symbols\ImplicitClassTests.cs (2)
37Assert.Equal(SyntaxKind.NamespaceDeclaration, implicitClass.DeclaringSyntaxReferences.Single().GetSyntax().Kind()); 66Assert.Equal(SyntaxKind.CompilationUnit, scriptClass.DeclaringSyntaxReferences.Single().GetSyntax().Kind());
Symbols\Source\DeclaringSyntaxNodeTests.cs (1)
105Assert.Equal(expectedSyntaxKind, node.Kind());
Symbols\SymbolEqualityTests.cs (27)
411var member1Syntax = (FieldDeclarationSyntax)root.DescendantNodes().First(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 412var member2Syntax = (FieldDeclarationSyntax)root.DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 449var member1Syntax = (FieldDeclarationSyntax)root.DescendantNodes().First(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 450var member2Syntax = (FieldDeclarationSyntax)root.DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 480var member1Syntax = (FieldDeclarationSyntax)root.DescendantNodes().First(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 481var member2Syntax = (FieldDeclarationSyntax)root.DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 523var member1Syntax = (FieldDeclarationSyntax)root.DescendantNodes().First(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 524var member2Syntax = (FieldDeclarationSyntax)root.DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 554var member1Syntax = (FieldDeclarationSyntax)root.DescendantNodes().First(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 555var member2Syntax = (FieldDeclarationSyntax)root.DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 590var create1Syntax = (InvocationExpressionSyntax)root.DescendantNodes().First(sn => sn.Kind() == SyntaxKind.InvocationExpression); 591var create2Syntax = (InvocationExpressionSyntax)root.DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.InvocationExpression); 625var member1Syntax = (FieldDeclarationSyntax)root.DescendantNodes().First(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 626var member2Syntax = (FieldDeclarationSyntax)root.DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 674var member1Syntax = (FieldDeclarationSyntax)root.DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.ClassDeclaration).DescendantNodes().First(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 675var member2Syntax = (FieldDeclarationSyntax)root.DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.ClassDeclaration).DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 726var member1Syntax = (FieldDeclarationSyntax)root.DescendantNodes().First(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 727var member2Syntax = (FieldDeclarationSyntax)root.DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.FieldDeclaration); 776var member1Syntax = (ClassDeclarationSyntax)root.DescendantNodes().First(sn => sn.Kind() == SyntaxKind.ClassDeclaration); 777var member2Syntax = (IdentifierNameSyntax)root.DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.IdentifierName); 827var member1Syntax = (ClassDeclarationSyntax)root.DescendantNodes().First(sn => sn.Kind() == SyntaxKind.ClassDeclaration); 828var member2Syntax = (IdentifierNameSyntax)root.DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.SimpleMemberAccessExpression).DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.IdentifierName); 888var member1Syntax = (ClassDeclarationSyntax)root.DescendantNodes().First(sn => sn.Kind() == SyntaxKind.ClassDeclaration); 889var member2Syntax = (IdentifierNameSyntax)root.DescendantNodes().Last(sn => sn.Kind() == SyntaxKind.IdentifierName);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (58)
Parsing\ExpressionParsingTests.cs (1)
3138Assert.Equal(SyntaxKind.CompilationUnit, root.Kind());
Parsing\LocalFunctionParsingTests.cs (2)
1229.Where(n => n.Kind() == SyntaxKind.MethodDeclaration) 1289Assert.True(file.DescendantNodes().Any(n => n.Kind() == SyntaxKind.LocalFunctionStatement && !n.ContainsDiagnostics));
Parsing\ScriptParsingTests.cs (2)
9612Assert.Equal(SyntaxKind.GlobalStatement, tree.GetCompilationUnitRoot().ChildNodes().ToList()[0].Kind()); 9664Assert.Equal(SyntaxKind.GlobalStatement, statement.Kind());
Syntax\SyntaxNodeTests.cs (53)
76Assert.Equal(SyntaxKind.IdentifierName, nodes[0].Kind()); 77Assert.Equal(SyntaxKind.ArgumentList, nodes[1].Kind()); 89Assert.Equal(SyntaxKind.DivideExpression, nodes[0].Kind()); 90Assert.Equal(SyntaxKind.ParenthesizedExpression, nodes[1].Kind()); 91Assert.Equal(SyntaxKind.MultiplyExpression, nodes[2].Kind()); 92Assert.Equal(SyntaxKind.ParenthesizedExpression, nodes[3].Kind()); 93Assert.Equal(SyntaxKind.SubtractExpression, nodes[4].Kind()); 94Assert.Equal(SyntaxKind.ParenthesizedExpression, nodes[5].Kind()); 95Assert.Equal(SyntaxKind.AddExpression, nodes[6].Kind()); 107Assert.Equal(SyntaxKind.IdentifierName, nodes[0].Kind()); 108Assert.Equal(SyntaxKind.DivideExpression, nodes[1].Kind()); 109Assert.Equal(SyntaxKind.ParenthesizedExpression, nodes[2].Kind()); 110Assert.Equal(SyntaxKind.MultiplyExpression, nodes[3].Kind()); 111Assert.Equal(SyntaxKind.ParenthesizedExpression, nodes[4].Kind()); 112Assert.Equal(SyntaxKind.SubtractExpression, nodes[5].Kind()); 113Assert.Equal(SyntaxKind.ParenthesizedExpression, nodes[6].Kind()); 114Assert.Equal(SyntaxKind.AddExpression, nodes[7].Kind()); 137Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[0].Kind()); 141Assert.Equal(SyntaxKind.IfDirectiveTrivia, nodes[0].Kind()); 142Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[1].Kind()); 143Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[2].Kind()); 147Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[0].Kind()); 151Assert.Equal(SyntaxKind.IfDirectiveTrivia, nodes[0].Kind()); 152Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[1].Kind()); 157Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[0].Kind()); 161Assert.Equal(SyntaxKind.IfDirectiveTrivia, nodes[0].Kind()); 162Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[1].Kind()); 163Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[2].Kind()); 167Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[0].Kind()); 171Assert.Equal(SyntaxKind.IfDirectiveTrivia, nodes[0].Kind()); 172Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[1].Kind()); 183Assert.Equal(SyntaxKind.ReturnStatement, nodes[0].Kind()); 184Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[1].Kind()); 188Assert.Equal(SyntaxKind.ReturnStatement, nodes[0].Kind()); 189Assert.Equal(SyntaxKind.IfDirectiveTrivia, nodes[1].Kind()); 190Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[2].Kind()); 191Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[3].Kind()); 195Assert.Equal(SyntaxKind.ReturnStatement, nodes[0].Kind()); 196Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[1].Kind()); 200Assert.Equal(SyntaxKind.ReturnStatement, nodes[0].Kind()); 201Assert.Equal(SyntaxKind.IfDirectiveTrivia, nodes[1].Kind()); 202Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[2].Kind()); 207Assert.Equal(SyntaxKind.ReturnStatement, nodes[0].Kind()); 208Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[1].Kind()); 212Assert.Equal(SyntaxKind.ReturnStatement, nodes[0].Kind()); 213Assert.Equal(SyntaxKind.IfDirectiveTrivia, nodes[1].Kind()); 214Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[2].Kind()); 215Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[3].Kind()); 219Assert.Equal(SyntaxKind.ReturnStatement, nodes[0].Kind()); 220Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[1].Kind()); 224Assert.Equal(SyntaxKind.ReturnStatement, nodes[0].Kind()); 225Assert.Equal(SyntaxKind.IfDirectiveTrivia, nodes[1].Kind()); 226Assert.Equal(SyntaxKind.TrueLiteralExpression, nodes[2].Kind());
Microsoft.CodeAnalysis.CSharp.Workspaces (177)
Classification\ClassificationHelpers.cs (5)
64IsControlStatementKind(token.Parent.Kind()); 290=> parentNode.Kind() switch 338=> identifier.Parent!.Kind() switch 362if (token.Parent.Kind() is SyntaxKind.TypeParameterList or 376if (token.Parent.Kind() != SyntaxKind.ConditionalExpression)
Classification\SyntaxClassification\DiscardSyntaxClassifier.cs (1)
28if (syntax.Kind() is SyntaxKind.DiscardDesignation or SyntaxKind.DiscardPattern)
Classification\Worker_DocumentationComments.cs (1)
162switch (token.Parent.Kind())
CodeGeneration\CSharpSyntaxGenerator.cs (39)
72throw ExceptionUtilities.UnexpectedValue(node.Kind()); 134switch (declaration.Kind()) 633=> declaration.Kind() switch 654switch (declaration.Kind()) 742switch (node.Kind()) 821switch (member.Kind()) 880throw ExceptionUtilities.UnexpectedValue(member.Kind()); 914switch (node.Kind()) 1062switch (declaration.Kind()) 1118switch (attributeDeclaration.Kind()) 1166switch (declaration.Kind()) 1186switch (declaration.Kind()) 1279switch (declaration.Kind()) 1332=> declaration.Kind() switch 1631modifiers &= GetAllowedModifiers(declaration.Kind()); 1889switch (declaration.Kind()) 2115switch (declaration.Kind()) 2156=> declaration.Kind() switch 2176switch (declaration.Kind()) 2222=> declaration.Kind() switch 2231=> declaration.Kind() switch 2241switch (declaration.Kind()) 2376switch (declaration.Kind()) 2422switch (declaration.Kind()) 2477switch (declaration.Kind()) 2548switch (declaration.Kind()) 2588switch (declaration.Kind()) 2628var result = declaration.Kind() switch 2681var newAccessors = AsAccessorList(accessors, declaration.Kind()); 2704=> declaration.Kind() switch 2728switch (node.Kind()) 2737switch (node.Kind()) 2891if (fullDecl != declaration && fullDecl.IsKind(newFullDecl.Kind())) 2922var kind = decl1.Kind(); 2948var kind = decl1.Kind(); 3110=> declaration.Kind() switch 3148switch (declaration.Kind()) 3192switch (parent.Kind()) 3464switch (expression.Kind())
FindSymbols\FindSymbolsUtilities.cs (1)
32switch (container.Kind())
Formatting\CSharpSyntaxFormattingService.cs (1)
311currentTokenParentParent.Kind() is SyntaxKind.SimpleLambdaExpression or SyntaxKind.ParenthesizedLambdaExpression or SyntaxKind.AnonymousMethodExpression)
Formatting\TypingFormattingRule.cs (1)
104while (node != null && node.Kind() != SyntaxKind.CompilationUnit)
LanguageServices\FixAllSpanMappingService\CSharpFixAllSpanMappingService.cs (1)
40var firstTypeOrNamespaceDecl = root.ChildNodes().FirstOrDefault(n => SyntaxFacts.IsNamespaceMemberDeclaration(n.Kind()));
Recommendations\CSharpRecommendationServiceRunner.cs (6)
171if (current.Kind() == SyntaxKind.ConstantPattern) 174if (current.Kind() == SyntaxKind.ParenthesizedExpression) 177if (current.Kind() == SyntaxKind.SimpleMemberAccessExpression) 194if (current.Kind() == SyntaxKind.QualifiedName) 197if (current.Kind() == SyntaxKind.AliasQualifiedName) 305.Kind() is SyntaxKind.LabeledStatement or SyntaxKind.DefaultSwitchLabel);
Rename\LocalConflictVisitor.cs (1)
166foreach (var child in body.ChildNodes().Where(c => c.Kind() != SyntaxKind.QueryContinuation))
Simplification\CSharpSimplificationService.Expander.cs (11)
626(parent is MemberAccessExpressionSyntax && parent.Kind() != SyntaxKind.SimpleMemberAccessExpression) || 627((parent.Kind() == SyntaxKind.SimpleMemberAccessExpression || parent.Kind() == SyntaxKind.NameMemberCref) && originalSimpleName.IsRightSideOfDot()) || 628(parent.Kind() == SyntaxKind.QualifiedName && originalSimpleName.IsRightSideOfQualifiedName()) || 629(parent.Kind() == SyntaxKind.AliasQualifiedName) || 630(parent.Kind() == SyntaxKind.NameColon)) 640if (symbol.IsConstructor() && (parent.Kind() == SyntaxKind.ObjectCreationExpression || parent.Kind() == SyntaxKind.NameMemberCref)) 865if (parent.Kind() is SyntaxKind.ObjectInitializerExpression or SyntaxKind.WithInitializerExpression) 867return currentNode.Kind() == SyntaxKind.SimpleAssignmentExpression && 946switch (parent.Kind())
Simplification\Reducers\CSharpMiscellaneousReducer.cs (1)
180switch (node.Kind())
Simplification\Simplifiers\ExpressionSimplifier.cs (1)
395if (constructor == null || constructor.GetRequiredParent().Kind() is not (SyntaxKind.StructDeclaration or SyntaxKind.RecordStructDeclaration))
Simplification\Simplifiers\NameSimplifier.cs (2)
496if (name.Parent.Kind() == SyntaxKind.Attribute || name.IsRightSideOfDotOrColonColon()) 557switch (parent.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\BlockSyntaxExtensions.cs (1)
135if (parent.Kind() == SyntaxKind.GetAccessorDeclaration)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (4)
288switch (parent.Kind()) 291if (parent.Parent?.Kind() == SyntaxKind.TupleExpression) 407switch (parent.Kind()) 523switch (expression.Parent.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ILocalSymbolExtensions.cs (1)
17.FirstOrDefault(node => node.Kind() is SyntaxKind.LocalFunctionStatement or SyntaxKind.MethodDeclaration);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (1)
106if (nodeParent.Kind() is SyntaxKind.CheckedExpression or SyntaxKind.UncheckedExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (2)
252if (type.Parent.Kind() 276if (type.Parent.Parent.Parent?.Kind()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (5)
29=> kind = node.Kind(); 92return node?.Kind() 397switch (node.Kind()) 413switch (node.Kind()) 428switch (node.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.DocumentationCommentExteriorCommentRewriter.cs (1)
71if (currentParent.Kind() is SyntaxKind.SingleLineDocumentationCommentTrivia or
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (5)
122=> token.Kind() == SyntaxKind.CommaToken && (token.Parent.IsAnyArgumentList() || token.Parent?.Kind() is SyntaxKind.ParameterList or SyntaxKind.FunctionPointerParameterList); 129if (node.Kind() != SyntaxKind.Block) 134return node.Parent?.Kind() is SyntaxKind.SimpleLambdaExpression or SyntaxKind.ParenthesizedLambdaExpression; 139if (node.Kind() != SyntaxKind.Block) 232switch (parent.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\AnchorIndentationFormattingRule.cs (1)
19if (node.Kind() is SyntaxKind.SimpleLambdaExpression or SyntaxKind.ParenthesizedLambdaExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (2)
227if (node.IsLambdaBodyBlock() || node.IsAnonymousMethodBlock() || node.Kind() is SyntaxKind.PropertyPatternClause or SyntaxKind.SwitchExpression) 267if (node.Parent != null && node.Kind() is SyntaxKind.ListPattern or SyntaxKind.CollectionExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\NewLineUserSettingFormattingRule.cs (4)
49var parentKind = node.Parent?.Kind(); 132if (currentToken.Parent.Kind() is SyntaxKind.ObjectInitializerExpression 344currentToken.Parent.Kind() is SyntaxKind.ObjectInitializerExpression or SyntaxKind.CollectionInitializerExpression or SyntaxKind.WithInitializerExpression or SyntaxKind.PropertyPatternClause) 361currentToken.Parent.Kind() is SyntaxKind.ArrayInitializerExpression or SyntaxKind.ImplicitArrayCreationExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SpacingFormattingRule.cs (8)
49var previousParentKind = previousToken.Parent.Kind(); 50var currentParentKind = currentToken.Parent.Kind(); 163if ((previousToken.Parent.Kind() is SyntaxKind.ParenthesizedExpression or SyntaxKind.ParenthesizedPattern && previousKind == SyntaxKind.OpenParenToken) || 164(currentToken.Parent.Kind() is SyntaxKind.ParenthesizedExpression or SyntaxKind.ParenthesizedPattern && currentKind == SyntaxKind.CloseParenToken)) 208if (currentKind == SyntaxKind.OpenBracketToken && currentToken.Parent.Kind() is SyntaxKind.ListPattern or SyntaxKind.CollectionExpression) 331currentToken.Parent.Kind() is SyntaxKind.AndPattern or SyntaxKind.OrPattern or SyntaxKind.RelationalPattern || 332previousToken.Parent.Kind() is SyntaxKind.AndPattern or SyntaxKind.OrPattern or SyntaxKind.RelationalPattern) 576if (node.Kind()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\TokenBasedFormattingRule.cs (2)
266_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), 388currentToken.Parent?.Kind() is not SyntaxKind.CollectionExpression and not SyntaxKind.AttributeList &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (1)
73endToken.Parent.Parent?.Kind() is SyntaxKind.TryStatement or SyntaxKind.DoStatement;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (3)
117Debug.Assert(oldNode.Kind() == newNode.Kind()); 416=> node.Ancestors().Any(n => n.Kind() is
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (1)
22switch (declaration.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (13)
229_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), 633=> node.Kind() == SyntaxKind.PropertyPatternClause; 713var kind = node.Kind(); 803switch (node.Kind()) 864Debug.Fail("Unexpected node type " + node.Kind()); 1111=> node?.Parent?.Kind() is SyntaxKind.PostIncrementExpression or SyntaxKind.PreIncrementExpression; 1114=> node?.Parent?.Kind() is SyntaxKind.PostDecrementExpression or SyntaxKind.PreDecrementExpression; 1162=> SyntaxFacts.IsDocumentationCommentTrivia(node.Kind()); 1165=> node?.Kind() is SyntaxKind.UsingDirective or SyntaxKind.ExternAliasDirective; 1183if (SyntaxFacts.IsNamespaceMemberDeclaration(node.Kind())) 1199switch (node.Kind()) 1204return node.Parent?.Parent?.Kind() is SyntaxKind.FieldDeclaration or SyntaxKind.EventFieldDeclaration; 1228=> SyntaxFacts.IsTypeDeclaration(node.Kind());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (8)
230if (castSyntax.WalkUpParentheses().GetRequiredParent().Kind() is SyntaxKind.BitwiseOrExpression or SyntaxKind.OrAssignmentExpression) 1178Debug.Assert(currentOld.Kind() == currentNew.Kind()); 1234Debug.Assert(currentOld.Kind() == currentNew.Kind()); 1235if (!haveHitArgumentNode && currentOld.Kind() != SyntaxKind.Argument) 1264Debug.Assert(currentOld.Kind() == currentNew.Kind());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (6)
99if (parent.Kind() is SyntaxKind.StringLiteralExpression or 115if (parent == null || parent.Kind() == SyntaxKind.SkippedTokensTrivia) 172if (parent == null || parent.Kind() == SyntaxKind.SkippedTokensTrivia) 272if (parent == null || parent.Kind() == SyntaxKind.SkippedTokensTrivia) 356node.Kind() is SyntaxKind.IfStatement or 439if (token.Parent.Kind() is SyntaxKind.Block or
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (13)
82if (node.Kind() is not SyntaxKind.PrimaryConstructorBaseType || 83previousNode.Kind() is SyntaxKind.ArgumentList) 97node.Kind() is SyntaxKind.Attribute or 109node => node.Kind() is SyntaxKind.UnknownAccessorDeclaration or SyntaxKind.IncompleteMember or SyntaxKind.BracketedArgumentList), 156switch (nodeToSpeculate.Kind()) 300if (currentOriginalNode.Kind() is SyntaxKind.CaseSwitchLabel or SyntaxKind.ConstantPattern) 315else if (currentOriginalNode.Kind() == SyntaxKind.LogicalNotExpression) 319else if (currentOriginalNode.Kind() == SyntaxKind.ConditionalAccessExpression) 336else if (currentOriginalNode.Kind() == SyntaxKind.VariableDeclarator) 515else if (currentOriginalNode.Kind() == SyntaxKind.CollectionInitializerExpression) 520else if (currentOriginalNode.Kind() == SyntaxKind.ImplicitArrayCreationExpression) 529else if (currentOriginalNode.Kind() == SyntaxKind.DefaultExpression) 581=> node.Kind() is
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.cs (2)
61if (typeName?.FirstAncestorOrSelf<SyntaxNode>(a => a.Kind() is SyntaxKind.DeclarationExpression or SyntaxKind.VariableDeclaration or SyntaxKind.ForEachStatement) is not { } declaration) 83Debug.Assert(node.Kind() is SyntaxKind.VariableDeclaration or SyntaxKind.ForEachStatement or SyntaxKind.DeclarationExpression);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
230return destination.Kind() switch
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpDeclarationComparer.cs (8)
88if (x.Kind() != y.Kind()) 90if (!s_kindPrecedenceMap.TryGetValue(x.Kind(), out var xPrecedence) || 91!s_kindPrecedenceMap.TryGetValue(y.Kind(), out var yPrecedence)) 101switch (x.Kind()) 152throw ExceptionUtilities.UnexpectedValue(x.Kind()); 347if (node.Kind() == SyntaxKind.InterfaceDeclaration) 352else if (node.Kind() is SyntaxKind.StructDeclaration or SyntaxKind.ClassDeclaration or SyntaxKind.RecordDeclaration or SyntaxKind.RecordStructDeclaration)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Editing\CSharpImportAdder.cs (1)
164switch (node.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (5)
135if (token.Parent.Parent.Kind() is not SyntaxKind.TryStatement and not SyntaxKind.DoStatement) 138else if (token.Parent.Parent?.Kind() 163return parent?.Kind() 455if (owner?.Kind() 470if (targetToken.Parent?.Parent?.Kind()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (3)
2345previousToken.Parent?.Kind() is SyntaxKind.PointerType or SyntaxKind.NullableType) 2914switch (name.Parent.Kind()) 2955block.Parent?.Kind() is SyntaxKind.TryStatement or SyntaxKind.CatchClause)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\NameSyntaxExtensions.cs (1)
35if (nameSyntax.Parent?.Kind()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\CSharpSimplificationHelpers.cs (2)
34if (parentOfToken is SimpleNameSyntax && parent.Kind() == SyntaxKind.XmlNameAttribute) 41if (parent.Kind() == SyntaxKind.AliasQualifiedName &&
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (18)
CodeGeneration\SyntaxGeneratorTests.cs (18)
4005Assert.Equal(SyntaxKind.FieldDeclaration, xTypedT.Kind()); 4010Assert.Equal(SyntaxKind.FieldDeclaration, xNamedQ.Kind()); 4015Assert.Equal(SyntaxKind.FieldDeclaration, xInitialized.Kind()); 4020Assert.Equal(SyntaxKind.FieldDeclaration, xPrivate.Kind()); 4025Assert.Equal(SyntaxKind.FieldDeclaration, xReadOnly.Kind()); 4030Assert.Equal(SyntaxKind.FieldDeclaration, xAttributed.Kind()); 4388Assert.Equal(SyntaxKind.AttributeList, xNamedQ.Kind()); 4393Assert.Equal(SyntaxKind.AttributeList, xWithArg.Kind()); 4602Assert.Equal(SyntaxKind.AttributeList, xNamedQ.Kind()); 4607Assert.Equal(SyntaxKind.AttributeList, xWithArg.Kind()); 4699Assert.Equal(SyntaxKind.AttributeList, attrX.Kind()); 4703Assert.Equal(SyntaxKind.Attribute, attrY.Kind()); 4707Assert.Equal(SyntaxKind.Attribute, attrZ.Kind()); 4711Assert.Equal(SyntaxKind.AttributeList, attrP.Kind()); 4718Assert.Equal(SyntaxKind.AttributeList, attrA.Kind()); 4722Assert.Equal(SyntaxKind.Attribute, attrB.Kind()); 4726Assert.Equal(SyntaxKind.Attribute, attrC.Kind()); 4730Assert.Equal(SyntaxKind.Attribute, attrD.Kind());
Microsoft.CodeAnalysis.UnitTests (3)
CommonSyntaxTests.cs (3)
198Assert.Equal(CSharp.SyntaxKind.None, CSharp.CSharpExtensions.Kind(node)); 223Assert.Equal(CSharp.SyntaxKind.ParenthesizedExpression, CSharp.CSharpExtensions.Kind(trackedB.Parent)); 246Assert.Equal(CSharp.SyntaxKind.ParenthesizedExpression, CSharp.CSharpExtensions.Kind(trackedB.Parent));
Microsoft.CodeAnalysis.Workspaces.UnitTests (19)
SyntaxPathTests.cs (19)
98Assert.Equal(SyntaxKind.CompilationUnit, node.Kind()); 112Assert.Equal(SyntaxKind.CompilationUnit, node.Kind()); 125Assert.Equal(SyntaxKind.CompilationUnit, node.Kind()); 165Assert.Equal(SyntaxKind.MethodDeclaration, n1.Kind()); 168Assert.Equal(SyntaxKind.MethodDeclaration, n2.Kind()); 171Assert.Equal(SyntaxKind.MethodDeclaration, n3.Kind()); 200Assert.Equal(SyntaxKind.ClassDeclaration, n1.Kind()); 202Assert.Equal(SyntaxKind.ClassDeclaration, n2.Kind()); 237Assert.Equal(SyntaxKind.MethodDeclaration, n1.Kind()); 240Assert.Equal(SyntaxKind.MethodDeclaration, n2.Kind()); 269Assert.Equal(SyntaxKind.ClassDeclaration, n1.Kind()); 302Assert.Equal(SyntaxKind.ClassDeclaration, n1.Kind()); 332Assert.Equal(SyntaxKind.ClassDeclaration, n1.Kind()); 334Assert.Equal(SyntaxKind.ClassDeclaration, n2.Kind()); 363Assert.Equal(SyntaxKind.ClassDeclaration, n1.Kind()); 365Assert.Equal(SyntaxKind.StructDeclaration, n2.Kind()); 402Assert.Equal(SyntaxKind.ClassDeclaration, n1.Kind()); 404Assert.Equal(SyntaxKind.StructDeclaration, n2.Kind()); 420Assert.Equal(SyntaxKind.ClassDeclaration, node.Kind());
Microsoft.ML.InternalCodeAnalyzer (2)
BestFriendAnalyzer.cs (1)
69switch (node.Kind())
ContractsCheckNameofFixProvider.cs (1)
78var pk = node.Parent.Kind();
Microsoft.VisualStudio.LanguageServices.CSharp (49)
CodeModel\CSharpCodeModelService.cs (41)
91switch (node.Kind()) 124switch (node.Kind()) 130Debug.Fail("Unsupported element kind: " + node.Kind()); 137switch (node.Kind()) 520switch (node.Kind()) 542switch (node.Kind()) 545return (EnvDTE.CodeElement)CodeClass.Create(state, fileCodeModel, nodeKey, (int)node.Kind()); 547return (EnvDTE.CodeElement)CodeInterface.Create(state, fileCodeModel, nodeKey, (int)node.Kind()); 549return (EnvDTE.CodeElement)CodeStruct.Create(state, fileCodeModel, nodeKey, (int)node.Kind()); 551return (EnvDTE.CodeElement)CodeEnum.Create(state, fileCodeModel, nodeKey, (int)node.Kind()); 553return (EnvDTE.CodeElement)CodeVariable.Create(state, fileCodeModel, nodeKey, (int)node.Kind()); 555return (EnvDTE.CodeElement)CodeDelegate.Create(state, fileCodeModel, nodeKey, (int)node.Kind()); 561return (EnvDTE.CodeElement)CodeFunction.Create(state, fileCodeModel, nodeKey, (int)node.Kind()); 564return (EnvDTE.CodeElement)CodeNamespace.Create(state, fileCodeModel, nodeKey, (int)node.Kind()); 567return (EnvDTE.CodeElement)CodeProperty.Create(state, fileCodeModel, nodeKey, (int)node.Kind()); 569return (EnvDTE.CodeElement)CodeEvent.Create(state, fileCodeModel, nodeKey, (int)node.Kind()); 576return (EnvDTE.CodeElement)CodeVariable.Create(state, fileCodeModel, nodeKey, (int)node.Kind()); 580return (EnvDTE.CodeElement)CodeEvent.Create(state, fileCodeModel, nodeKey, (int)node.Kind()); 592switch (node.Kind()) 801switch (node.Kind()) 852Debug.Fail("Invalid node kind: " + node.Kind()); 859var kind = node.Kind(); 880switch (node.Kind()) 921Debug.Fail("Invalid node kind: " + node.Kind()); 956if (node.Kind() == SyntaxKind.UsingDirective) 1479switch (node.Kind()) 1492=> node.Kind() switch 1662var attribute = (AttributeSyntax)argument.Ancestors().First(n => n.Kind() == SyntaxKind.Attribute); 2883=> node.Kind() switch 2905switch (node.Kind()) 2923switch (node.Kind()) 3176return node.Kind() == SyntaxKind.VariableDeclarator 3493switch (node.Kind()) 3525return node?.Kind() 3603if (node == null || node.Kind() != SyntaxKind.MethodDeclaration || 3643if (node == null || node.Kind() != SyntaxKind.PropertyDeclaration || 3723if (node.Kind() is not (SyntaxKind.ClassDeclaration or SyntaxKind.InterfaceDeclaration)) 3756if (node.Kind() is not (SyntaxKind.ClassDeclaration or SyntaxKind.InterfaceDeclaration)) 3806if (node.Kind() is SyntaxKind.ClassDeclaration or SyntaxKind.StructDeclaration) 3816if (node.Kind() is not (SyntaxKind.ClassDeclaration or SyntaxKind.StructDeclaration)) 3851if (node.Kind() is not (SyntaxKind.ClassDeclaration or SyntaxKind.StructDeclaration))
CodeModel\CSharpCodeModelService.NodeLocator.cs (4)
35switch (node.Kind()) 79Debug.Fail("Unsupported node kind: " + node.Kind()); 86switch (node.Kind()) 130Debug.Fail("Unsupported node kind: " + node.Kind());
CodeModel\CSharpCodeModelService.NodeNameGenerator.cs (1)
161switch (node.Kind())
CodeModel\CSharpCodeModelService_Prototype.cs (1)
69Debug.Fail(string.Format("Invalid node/symbol kind: {0}/{1}", node.Kind(), symbol.Kind));
Utilities\BlankLineInGeneratedMethodFormattingRule.cs (2)
27if (currentToken.Parent.Kind() == SyntaxKind.Block && 28currentToken.Parent.Parent.Kind() == SyntaxKind.MethodDeclaration)
Roslyn.Diagnostics.CSharp.Analyzers (107)
CSharpSpecializedEnumerableCreationAnalyzer.cs (2)
52switch (expression.Kind()) 69return expression.Kind() switch
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\BlockSyntaxExtensions.cs (1)
135if (parent.Kind() == SyntaxKind.GetAccessorDeclaration)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (4)
288switch (parent.Kind()) 291if (parent.Parent?.Kind() == SyntaxKind.TupleExpression) 407switch (parent.Kind()) 523switch (expression.Parent.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ILocalSymbolExtensions.cs (1)
17.FirstOrDefault(node => node.Kind() is SyntaxKind.LocalFunctionStatement or SyntaxKind.MethodDeclaration);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (1)
106if (nodeParent.Kind() is SyntaxKind.CheckedExpression or SyntaxKind.UncheckedExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (2)
252if (type.Parent.Kind() 276if (type.Parent.Parent.Parent?.Kind()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (5)
29=> kind = node.Kind(); 92return node?.Kind() 397switch (node.Kind()) 413switch (node.Kind()) 428switch (node.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.DocumentationCommentExteriorCommentRewriter.cs (1)
71if (currentParent.Kind() is SyntaxKind.SingleLineDocumentationCommentTrivia or
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (5)
122=> token.Kind() == SyntaxKind.CommaToken && (token.Parent.IsAnyArgumentList() || token.Parent?.Kind() is SyntaxKind.ParameterList or SyntaxKind.FunctionPointerParameterList); 129if (node.Kind() != SyntaxKind.Block) 134return node.Parent?.Kind() is SyntaxKind.SimpleLambdaExpression or SyntaxKind.ParenthesizedLambdaExpression; 139if (node.Kind() != SyntaxKind.Block) 232switch (parent.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\AnchorIndentationFormattingRule.cs (1)
19if (node.Kind() is SyntaxKind.SimpleLambdaExpression or SyntaxKind.ParenthesizedLambdaExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (2)
227if (node.IsLambdaBodyBlock() || node.IsAnonymousMethodBlock() || node.Kind() is SyntaxKind.PropertyPatternClause or SyntaxKind.SwitchExpression) 267if (node.Parent != null && node.Kind() is SyntaxKind.ListPattern or SyntaxKind.CollectionExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\NewLineUserSettingFormattingRule.cs (4)
49var parentKind = node.Parent?.Kind(); 132if (currentToken.Parent.Kind() is SyntaxKind.ObjectInitializerExpression 344currentToken.Parent.Kind() is SyntaxKind.ObjectInitializerExpression or SyntaxKind.CollectionInitializerExpression or SyntaxKind.WithInitializerExpression or SyntaxKind.PropertyPatternClause) 361currentToken.Parent.Kind() is SyntaxKind.ArrayInitializerExpression or SyntaxKind.ImplicitArrayCreationExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SpacingFormattingRule.cs (8)
49var previousParentKind = previousToken.Parent.Kind(); 50var currentParentKind = currentToken.Parent.Kind(); 163if ((previousToken.Parent.Kind() is SyntaxKind.ParenthesizedExpression or SyntaxKind.ParenthesizedPattern && previousKind == SyntaxKind.OpenParenToken) || 164(currentToken.Parent.Kind() is SyntaxKind.ParenthesizedExpression or SyntaxKind.ParenthesizedPattern && currentKind == SyntaxKind.CloseParenToken)) 208if (currentKind == SyntaxKind.OpenBracketToken && currentToken.Parent.Kind() is SyntaxKind.ListPattern or SyntaxKind.CollectionExpression) 331currentToken.Parent.Kind() is SyntaxKind.AndPattern or SyntaxKind.OrPattern or SyntaxKind.RelationalPattern || 332previousToken.Parent.Kind() is SyntaxKind.AndPattern or SyntaxKind.OrPattern or SyntaxKind.RelationalPattern) 576if (node.Kind()
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\TokenBasedFormattingRule.cs (2)
266_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), 388currentToken.Parent?.Kind() is not SyntaxKind.CollectionExpression and not SyntaxKind.AttributeList &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (1)
73endToken.Parent.Parent?.Kind() is SyntaxKind.TryStatement or SyntaxKind.DoStatement;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (3)
117Debug.Assert(oldNode.Kind() == newNode.Kind()); 416=> node.Ancestors().Any(n => n.Kind() is
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (1)
22switch (declaration.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (13)
229_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), 633=> node.Kind() == SyntaxKind.PropertyPatternClause; 713var kind = node.Kind(); 803switch (node.Kind()) 864Debug.Fail("Unexpected node type " + node.Kind()); 1111=> node?.Parent?.Kind() is SyntaxKind.PostIncrementExpression or SyntaxKind.PreIncrementExpression; 1114=> node?.Parent?.Kind() is SyntaxKind.PostDecrementExpression or SyntaxKind.PreDecrementExpression; 1162=> SyntaxFacts.IsDocumentationCommentTrivia(node.Kind()); 1165=> node?.Kind() is SyntaxKind.UsingDirective or SyntaxKind.ExternAliasDirective; 1183if (SyntaxFacts.IsNamespaceMemberDeclaration(node.Kind())) 1199switch (node.Kind()) 1204return node.Parent?.Parent?.Kind() is SyntaxKind.FieldDeclaration or SyntaxKind.EventFieldDeclaration; 1228=> SyntaxFacts.IsTypeDeclaration(node.Kind());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (8)
230if (castSyntax.WalkUpParentheses().GetRequiredParent().Kind() is SyntaxKind.BitwiseOrExpression or SyntaxKind.OrAssignmentExpression) 1178Debug.Assert(currentOld.Kind() == currentNew.Kind()); 1234Debug.Assert(currentOld.Kind() == currentNew.Kind()); 1235if (!haveHitArgumentNode && currentOld.Kind() != SyntaxKind.Argument) 1264Debug.Assert(currentOld.Kind() == currentNew.Kind());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (6)
99if (parent.Kind() is SyntaxKind.StringLiteralExpression or 115if (parent == null || parent.Kind() == SyntaxKind.SkippedTokensTrivia) 172if (parent == null || parent.Kind() == SyntaxKind.SkippedTokensTrivia) 272if (parent == null || parent.Kind() == SyntaxKind.SkippedTokensTrivia) 356node.Kind() is SyntaxKind.IfStatement or 439if (token.Parent.Kind() is SyntaxKind.Block or
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (13)
82if (node.Kind() is not SyntaxKind.PrimaryConstructorBaseType || 83previousNode.Kind() is SyntaxKind.ArgumentList) 97node.Kind() is SyntaxKind.Attribute or 109node => node.Kind() is SyntaxKind.UnknownAccessorDeclaration or SyntaxKind.IncompleteMember or SyntaxKind.BracketedArgumentList), 156switch (nodeToSpeculate.Kind()) 300if (currentOriginalNode.Kind() is SyntaxKind.CaseSwitchLabel or SyntaxKind.ConstantPattern) 315else if (currentOriginalNode.Kind() == SyntaxKind.LogicalNotExpression) 319else if (currentOriginalNode.Kind() == SyntaxKind.ConditionalAccessExpression) 336else if (currentOriginalNode.Kind() == SyntaxKind.VariableDeclarator) 515else if (currentOriginalNode.Kind() == SyntaxKind.CollectionInitializerExpression) 520else if (currentOriginalNode.Kind() == SyntaxKind.ImplicitArrayCreationExpression) 529else if (currentOriginalNode.Kind() == SyntaxKind.DefaultExpression) 581=> node.Kind() is
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\TypeStyle\CSharpTypeStyleHelper.cs (2)
61if (typeName?.FirstAncestorOrSelf<SyntaxNode>(a => a.Kind() is SyntaxKind.DeclarationExpression or SyntaxKind.VariableDeclaration or SyntaxKind.ForEachStatement) is not { } declaration) 83Debug.Assert(node.Kind() is SyntaxKind.VariableDeclaration or SyntaxKind.ForEachStatement or SyntaxKind.DeclarationExpression);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
230return destination.Kind() switch
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpDeclarationComparer.cs (8)
88if (x.Kind() != y.Kind()) 90if (!s_kindPrecedenceMap.TryGetValue(x.Kind(), out var xPrecedence) || 91!s_kindPrecedenceMap.TryGetValue(y.Kind(), out var yPrecedence)) 101switch (x.Kind()) 152throw ExceptionUtilities.UnexpectedValue(x.Kind()); 347if (node.Kind() == SyntaxKind.InterfaceDeclaration) 352else if (node.Kind() is SyntaxKind.StructDeclaration or SyntaxKind.ClassDeclaration or SyntaxKind.RecordDeclaration or SyntaxKind.RecordStructDeclaration)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Editing\CSharpImportAdder.cs (1)
164switch (node.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (5)
135if (token.Parent.Parent.Kind() is not SyntaxKind.TryStatement and not SyntaxKind.DoStatement) 138else if (token.Parent.Parent?.Kind() 163return parent?.Kind() 455if (owner?.Kind() 470if (targetToken.Parent?.Parent?.Kind()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (3)
2345previousToken.Parent?.Kind() is SyntaxKind.PointerType or SyntaxKind.NullableType) 2914switch (name.Parent.Kind()) 2955block.Parent?.Kind() is SyntaxKind.TryStatement or SyntaxKind.CatchClause)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\NameSyntaxExtensions.cs (1)
35if (nameSyntax.Parent?.Kind()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Utilities\CSharpSimplificationHelpers.cs (2)
34if (parentOfToken is SimpleNameSyntax && parent.Kind() == SyntaxKind.XmlNameAttribute) 41if (parent.Kind() == SyntaxKind.AliasQualifiedName &&