837 references to Kind
Microsoft.CodeAnalysis.CSharp (169)
Binder\Binder.cs (1)
924sub.Add(new TreeDumperNode($"scope", $"{snippet} ({scope.ScopeDesignator?.Kind()})", null));
Binder\Binder.ValueChecks.cs (1)
519Debug.Assert(expr.Syntax.Kind() != SyntaxKind.Argument || valueKind == BindValueKind.RefOrOut);
Binder\Binder_Attributes.cs (1)
288Debug.Assert(boundAttribute.Syntax.Kind() == SyntaxKind.Attribute);
Binder\Binder_Deconstruct.cs (1)
303var elementSyntax = syntax.Kind() == SyntaxKind.TupleExpression ? ((TupleExpressionSyntax)syntax).Arguments[i] : syntax;
Binder\Binder_Expressions.cs (4)
2946switch (syntax.Kind()) 4555typeSyntax: node.Kind() == SyntaxKind.StackAllocArrayCreationExpression 6062Debug.Assert(memberInitializerSyntax.Kind() == SyntaxKind.SimpleAssignmentExpression); 8060(node.Kind() == SyntaxKind.AwaitExpression && plainName == WellKnownMemberNames.GetResult) ||
Binder\Binder_Invocation.cs (2)
1306WarnOnAccessOfOffDefault(node.Kind() == SyntaxKind.InvocationExpression ? 1806switch (expression.Kind())
Binder\Binder_Operators.cs (1)
3084if (node.Operand != operand.Syntax || operand.Syntax.Kind() != SyntaxKind.NumericLiteralExpression)
Binder\Binder_Statements.cs (8)
1676switch (syntax.Kind()) 1724switch (syntax.Kind()) 1737throw ExceptionUtilities.UnexpectedValue(syntax.Kind()); 2241if (sourceType.SpecialType == SpecialType.System_Double && syntax.Kind() == SyntaxKind.NumericLiteralExpression && 2444while (nodeForError.Kind() == SyntaxKind.ParenthesizedExpression) 2449if (nodeForError.Kind() == SyntaxKind.SimpleMemberAccessExpression || nodeForError.Kind() == SyntaxKind.PointerMemberAccessExpression) 3534return IsValidStatementExpression(expressionSyntax, expression) || expressionSyntax.Kind() == SyntaxKind.ThrowExpression;
Binder\Binder_Symbols.cs (1)
2289if (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)
94else if (syntax.Kind() != SyntaxKind.Block && (statement = syntax as StatementSyntax) != null)
Binder\Semantics\Conversions\ConversionsBase.cs (1)
1611if (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; } } 1489public override MessageID MessageID { get { return this.UnboundLambda.Syntax.Kind() == SyntaxKind.AnonymousMethodExpression ? MessageID.IDS_AnonMethod : MessageID.IDS_Lambda; } } 1503switch (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)); 1832(local.ScopeDesignatorOpt?.Kind() is SyntaxKind.SwitchSection or SyntaxKind.SwitchExpressionArm)))
Compilation\CSharpCompilation.cs (1)
4730Func<SyntaxNode, SyntaxKind> getKind = node => node.Kind();
Compilation\CSharpSemanticModel.cs (5)
2039boundNodeForSyntacticParent.Syntax.Kind() == SyntaxKind.ObjectCreationExpression && 3370if (expr.Syntax.Kind() is SyntaxKind.ObjectCreationExpression or SyntaxKind.ImplicitObjectCreationExpression) 3397boundNodeForSyntacticParent.Syntax.Kind() == SyntaxKind.ObjectCreationExpression && 3976parentSyntax.Kind() == SyntaxKind.Attribute && ((AttributeSyntax)parentSyntax).Name == boundNode.Syntax) 5085switch (node.Kind())
Compilation\MemberSemanticModel.cs (1)
239SyntaxKind 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)
993if (SyntaxFacts.IsDocumentationCommentTrivia(curr.Kind())) 2415return (node) => node.Kind() != SyntaxKind.GlobalStatement || node.Parent != unit; 2420return (node) => node.Parent != unit || node.Kind() == SyntaxKind.GlobalStatement; 2462!(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)
74switch (typeDecl.Kind()) 93throw ExceptionUtilities.UnexpectedValue(typeDecl.Kind());
FlowAnalysis\NullableWalker.cs (1)
6688if (syntax.Kind() != SyntaxKind.InvocationExpression)
FlowAnalysis\UnassignedAddressTakenVariablesWalker.cs (1)
54if (node.Parent.Kind() == SyntaxKind.AddressOfExpression)
Lowering\ClosureConversion\ClosureConversion.cs (1)
1770switch (curSyntax.Kind())
Lowering\ClosureConversion\LambdaCapturedVariable.cs (2)
82(local.ScopeDesignatorOpt?.Kind() == SyntaxKind.SwitchSection || 83local.ScopeDesignatorOpt?.Kind() == SyntaxKind.SwitchExpressionArm))
Lowering\ClosureConversion\SynthesizedClosureEnvironment.cs (1)
106throw ExceptionUtilities.UnexpectedValue(syntaxOpt.Kind());
Lowering\DiagnosticsPass_ExpressionTrees.cs (1)
591switch (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)
554loweredInput.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)
221RoslynDebug.Assert(SyntaxBindingUtilities.BindsToResumableStateMachineState(node) || SyntaxBindingUtilities.BindsToTryStatement(node), $"Unexpected syntax: {node.Kind()}"); 326if ((local.SynthesizedKind == SynthesizedLocalKind.UserDefined && local.ScopeDesignatorOpt?.Kind() != SyntaxKind.SwitchSection) || 739(local.ScopeDesignatorOpt?.Kind() == SyntaxKind.SwitchSection || 740local.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)
75switch (node.Kind())
Symbols\Source\GlobalExpressionVariable.cs (4)
51Debug.Assert(nodeToBind.Kind() == SyntaxKind.VariableDeclarator || nodeToBind is ExpressionSyntax); 178Debug.Assert(nodeToBind.Kind() == SyntaxKind.VariableDeclarator || nodeToBind is ExpressionSyntax); 188if ((object)_containingFieldOpt != null && nodeToBind.Kind() != SyntaxKind.VariableDeclarator) 197switch (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)
3519switch (syntax.Kind()) 3553throw ExceptionUtilities.UnexpectedValue(syntax.Kind());
Symbols\Source\SourcePropertySymbol.cs (1)
185_ => throw ExceptionUtilities.UnexpectedValue(syntax.Kind())
Syntax\LambdaUtilities.cs (7)
20switch (node.Kind()) 75switch (newLambda.Kind()) 119throw ExceptionUtilities.UnexpectedValue(newLambda.Kind()); 147switch (parent.Kind()) 288switch (node.Kind()) 388switch (node.Kind()) 442switch (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)
686if (token.Parent.Parent?.Kind() is not SyntaxKind.TypeArgumentList and not SyntaxKind.UsingDirective) 957switch (token.Parent.Kind(), next.Parent.Kind()) 1328if (node.Parent.Kind() is SyntaxKind.GlobalStatement or SyntaxKind.FileScopedNamespaceDeclaration)
Microsoft.CodeAnalysis.CSharp.CodeStyle (95)
src\Analyzers\CSharp\Analyzers\AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs (3)
67case SyntaxKind.IfStatement when statement.Kind() == SyntaxKind.ElseClause: 89if (statement.Kind() == embeddedStatement.Kind()) 239if (statement.Kind() is not (SyntaxKind.IfStatement or SyntaxKind.ElseClause))
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (2)
107if (invocationOrCreation?.Kind() is not SyntaxKind.InvocationExpression and not SyntaxKind.ObjectCreationExpression) 324switch (current.Kind())
src\Analyzers\CSharp\Analyzers\MisplacedUsingDirectives\MisplacedUsingDirectivesDiagnosticAnalyzer.cs (1)
95t => t.Kind() is not (SyntaxKind.UsingDirective or SyntaxKind.NamespaceDeclaration or SyntaxKind.FileScopedNamespaceDeclaration));
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs (1)
96switch (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 (1)
53var nodeKind = context.Node.Kind();
src\Analyzers\CSharp\Analyzers\UseInferredMemberName\CSharpUseInferredMemberNameDiagnosticAnalyzer.cs (1)
26switch (context.Node.Kind())
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs (2)
40Debug.Assert(enclosingBlock.Kind() is SyntaxKind.Block or SyntaxKind.SwitchSection); 102switch (current.Kind())
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs (1)
284switch (operand.Kind())
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)
107if (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)
27=> kind = node.Kind(); 90return node?.Kind() 395switch (node.Kind()) 411switch (node.Kind()) 426switch (node.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.DocumentationCommentExteriorCommentRewriter.cs (1)
72if (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) 260if (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)
253_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), 375currentToken.Parent?.Kind() is not SyntaxKind.CollectionExpression and not SyntaxKind.AttributeList &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (1)
75endToken.Parent.Parent?.Kind() is SyntaxKind.TryStatement or SyntaxKind.DoStatement;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (2)
116Debug.Assert(oldNode.Kind() == newNode.Kind());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (2)
28switch (declaration.Kind()) 155switch (declaration.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (13)
218_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), 640=> node.Kind() == SyntaxKind.PropertyPatternClause; 720var kind = node.Kind(); 816switch (node.Kind()) 879Debug.Assert(name != null, "Unexpected node type " + node.Kind()); 1185=> node?.Parent?.Kind() is SyntaxKind.PostIncrementExpression or SyntaxKind.PreIncrementExpression; 1188=> node?.Parent?.Kind() is SyntaxKind.PostDecrementExpression or SyntaxKind.PreDecrementExpression; 1229=> SyntaxFacts.IsDocumentationCommentTrivia(node.Kind()); 1232=> node?.Kind() is SyntaxKind.UsingDirective or SyntaxKind.ExternAliasDirective; 1250if (SyntaxFacts.IsNamespaceMemberDeclaration(node.Kind())) 1266switch (node.Kind()) 1271return node.Parent?.Parent?.Kind() is SyntaxKind.FieldDeclaration or SyntaxKind.EventFieldDeclaration; 1295=> SyntaxFacts.IsTypeDeclaration(node.Kind());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (7)
1098Debug.Assert(currentOld.Kind() == currentNew.Kind()); 1154Debug.Assert(currentOld.Kind() == currentNew.Kind()); 1155if (!haveHitArgumentNode && currentOld.Kind() != SyntaxKind.Argument) 1184Debug.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) 357node.Kind() is SyntaxKind.IfStatement or 440if (token.Parent.Kind() is SyntaxKind.Block or
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (12)
82if (node.Kind() is not SyntaxKind.PrimaryConstructorBaseType || 83previousNode.Kind() is SyntaxKind.ArgumentList) 97node.Kind() is SyntaxKind.Attribute or 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)
62if (typeName?.FirstAncestorOrSelf<SyntaxNode>(a => a.Kind() is SyntaxKind.DeclarationExpression or SyntaxKind.VariableDeclaration or SyntaxKind.ForEachStatement) is not { } declaration) 84Debug.Assert(node.Kind() is SyntaxKind.VariableDeclaration or SyntaxKind.ForEachStatement or SyntaxKind.DeclarationExpression);
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (34)
src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (1)
50if (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)
40if (simpleNameOrMemberAccessExpression.Parent.Kind()
src\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateConversionCodeFixProvider.cs (1)
37return node.Kind()
src\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateMethodCodeFixProvider.cs (1)
56return node.Kind()
src\Analyzers\CSharp\CodeFixes\ImplementInterface\CSharpImplementInterfaceService.cs (1)
51if (interfaceNode.Parent.Parent?.Parent.Kind() is
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (1)
316=> node.Kind() is
src\Analyzers\CSharp\CodeFixes\RemoveUnreachableCode\CSharpRemoveUnreachableCodeCodeFixProvider.cs (1)
82if (statement.Parent?.Kind()
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (4)
47switch (node.Kind()) 87Debug.Fail($"Unexpected node kind for local/parameter declaration or reference: '{node.Kind()}'"); 206Debug.Fail($"Unexpected kind for originalCompoundAssignment: {originalCompoundAssignment.Kind()}"); 232var mappedBinaryExpressionKind = originalCompoundAssignment.Kind().MapCompoundAssignmentKindToBinaryExpressionKind();
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
78throw ExceptionUtilities.UnexpectedValue(declarationContext?.Kind());
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 (2)
2344previousToken.Parent?.Kind() is SyntaxKind.PointerType or SyntaxKind.NullableType) 2913switch (name.Parent.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\NameSyntaxExtensions.cs (1)
54if (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)
191if (currentNode.Kind() is 258if (currentNode.Kind() is SyntaxKind.FieldDeclaration or SyntaxKind.DelegateDeclaration or SyntaxKind.ArrowExpressionClause) 321m[nameof(statementNode)] = statementNode.Kind(); 350switch (statementNode.Kind()) 464if (currentNode.Kind() is not (SyntaxKind.InterpolatedStringExpression or SyntaxKind.StringLiteralExpression or SyntaxKind.Utf8StringLiteralExpression or SyntaxKind.CharacterLiteralExpression)) 519switch (currentNode.Kind())
Interactive\CSharpSendToInteractiveSubmissionProvider.cs (1)
112var kind = node.Kind();
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
Diagnostics\DiagnosticAnalyzerDriver\DiagnosticAnalyzerDriverTests.cs (1)
325Assert.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)
6621var expr = tree.GetRoot().DescendantNodes().Single(n => n.Kind() == kind); 6853var expr = tree.GetRoot().DescendantNodes().Single(n => n.Kind() == kind);
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (29)
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)
974throw new Exception($"Unexpected topmost node for code block '{context.CodeBlock.Kind()}'"); 993throw new Exception($"Unexpected topmost node for operation block '{operationBlock.Syntax.Kind()}'");
Semantics\OutVarTests.cs (5)
1184switch (parent1.Kind()) 1191Assert.Equal(SyntaxKind.LocalDeclarationStatement, parent1.Kind()); 1224switch (reference.Parent.Kind()) 1333switch (reference.Parent.Kind()) 32708var inFieldDeclaratorArgumentlist = declarator != null && declarator.Parent.Parent.Kind() != SyntaxKind.LocalDeclarationStatement &&
Semantics\PatternMatchingTestBase.cs (3)
37return tree.GetRoot().DescendantNodes().OfType<SingleVariableDesignationSyntax>().Where(p => p.Parent.Kind() == SyntaxKind.DeclarationPattern || p.Parent.Kind() == SyntaxKind.VarPattern); 292var inFieldDeclaratorArgumentlist = declarator != null && declarator.Parent.Parent.Kind() != SyntaxKind.LocalDeclarationStatement &&
Semantics\PrimaryConstructorTests.cs (8)
1130Assert.Equal(SyntaxKind.ClassDeclaration, baseWithargs.Parent.Parent.Kind()); 3922Assert.Equal(SyntaxKind.SimpleBaseType, identifier.Parent.Kind()); 4328Assert.Equal(SyntaxKind.ClassDeclaration, context.Operation.Syntax.Kind()); 4332Assert.Equal(SyntaxKind.ClassDeclaration, context.Operation.Syntax.Kind()); 4336Assert.Equal(SyntaxKind.ConstructorDeclaration, context.Operation.Syntax.Kind()); 4350Assert.Equal(SyntaxKind.PrimaryConstructorBaseType, context.Operation.Syntax.Kind()); 4365Assert.Equal(SyntaxKind.BaseConstructorInitializer, context.Operation.Syntax.Kind()); 5696Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind());
Semantics\RecordTests.cs (7)
21203Assert.Equal(SyntaxKind.RecordDeclaration, baseWithargs.Parent.Parent.Kind()); 26358Assert.Equal(SyntaxKind.SimpleBaseType, identifier.Parent.Kind()); 26791Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind()); 26795Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind()); 26799Assert.Equal(SyntaxKind.ConstructorDeclaration, context.Operation.Syntax.Kind()); 26813Assert.Equal(SyntaxKind.PrimaryConstructorBaseType, context.Operation.Syntax.Kind()); 26828Assert.Equal(SyntaxKind.BaseConstructorInitializer, context.Operation.Syntax.Kind());
Microsoft.CodeAnalysis.CSharp.Features (112)
AddImport\CSharpAddImportFeatureService.cs (3)
119if (nameNode?.Parent?.Kind() is not SyntaxKind.SimpleMemberAccessExpression and not SyntaxKind.MemberBindingExpression) 124if (memberAccess?.Parent?.Kind() is SyntaxKind.SimpleMemberAccessExpression or SyntaxKind.ElementAccessExpression || 125memberBinding?.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 (7)
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()) 619_ => throw ExceptionUtilities.UnexpectedValue(node.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 (2)
242if (descendantNodesAndSelf.Any(n => n.Kind() is SyntaxKind.ObjectCreationExpression or SyntaxKind.InvocationExpression)) 437while (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 (1)
50_ => 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\ExplicitInterfaceTypeCompletionProvider.cs (1)
151=> node.Kind() is SyntaxKind.ClassDeclaration or SyntaxKind.StructDeclaration or
Completion\CompletionProviders\Scripting\DirectiveCompletionProviderUtilities.cs (1)
22if (token.Kind() == SyntaxKind.StringLiteralToken && token.Parent!.Kind() == directiveKind)
Completion\KeywordRecommenders\RefKeywordRecommender.cs (3)
208return parent?.Kind() == SyntaxKind.SimpleAssignmentExpression 209|| parent?.Parent?.Kind() == SyntaxKind.VariableDeclarator; 216return token.Parent?.Kind() == SyntaxKind.ConditionalExpression;
ConvertLinq\ConvertForEachToLinqQuery\AbstractToMethodConverter.cs (1)
146switch (node.Kind())
ConvertLinq\CSharpConvertLinqQueryToForEachProvider.cs (1)
930switch (node.Kind())
Debugging\CSharpProximityExpressionsService_ExpressionTermCollector.cs (1)
189memberAccessExpression.Parent?.Kind() is not SyntaxKind.SimpleMemberAccessExpression and not SyntaxKind.PointerMemberAccessExpression)
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)
149var throwExpressionsAndStatements = member.DescendantNodes().Where(n => n.Kind() is SyntaxKind.ThrowExpression or SyntaxKind.ThrowStatement);
EditAndContinue\BreakpointSpans.cs (3)
171switch (node.Kind()) 773=> declaration.Parent!.Kind() switch 947switch (parent.Kind())
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 (2)
428.Where(n => n.Kind() is SyntaxKind.DeclarationExpression or SyntaxKind.DeclarationPattern); 432switch (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)
60if (node.Kind() is SyntaxKind.SimpleLambdaExpression or SyntaxKind.ParenthesizedLambdaExpression or SyntaxKind.AnonymousMethodExpression)
GenerateType\CSharpGenerateTypeService.cs (2)
104return baseList?.Parent.Kind() is 669if (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)
33if (ifStatement.Parent.Kind() != SyntaxKind.ElseClause)
InlineHints\CSharpInlineTypeHintsService.cs (1)
85return 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)
72if (SyntaxFacts.IsTypeDeclaration(node.Kind())) 77switch (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())
SimplifyTypeNames\SimplifyTypeNamesCodeFixProvider.cs (1)
57if (annotatedexpressionSyntax.Kind() is SyntaxKind.IsExpression or SyntaxKind.AsExpression)
src\Analyzers\CSharp\Analyzers\AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs (3)
67case SyntaxKind.IfStatement when statement.Kind() == SyntaxKind.ElseClause: 89if (statement.Kind() == embeddedStatement.Kind()) 239if (statement.Kind() is not (SyntaxKind.IfStatement or SyntaxKind.ElseClause))
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (2)
107if (invocationOrCreation?.Kind() is not SyntaxKind.InvocationExpression and not SyntaxKind.ObjectCreationExpression) 324switch (current.Kind())
src\Analyzers\CSharp\Analyzers\MisplacedUsingDirectives\MisplacedUsingDirectivesDiagnosticAnalyzer.cs (1)
95t => t.Kind() is not (SyntaxKind.UsingDirective or SyntaxKind.NamespaceDeclaration or SyntaxKind.FileScopedNamespaceDeclaration));
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryNullableDirective\CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs (1)
96switch (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 (1)
53var nodeKind = context.Node.Kind();
src\Analyzers\CSharp\Analyzers\UseInferredMemberName\CSharpUseInferredMemberNameDiagnosticAnalyzer.cs (1)
26switch (context.Node.Kind())
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs (2)
40Debug.Assert(enclosingBlock.Kind() is SyntaxKind.Block or SyntaxKind.SwitchSection); 102switch (current.Kind())
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs (1)
284switch (operand.Kind())
src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (1)
50if (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)
40if (simpleNameOrMemberAccessExpression.Parent.Kind()
src\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateConversionCodeFixProvider.cs (1)
37return node.Kind()
src\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateMethodCodeFixProvider.cs (1)
56return node.Kind()
src\Analyzers\CSharp\CodeFixes\ImplementInterface\CSharpImplementInterfaceService.cs (1)
51if (interfaceNode.Parent.Parent?.Parent.Kind() is
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (1)
316=> node.Kind() is
src\Analyzers\CSharp\CodeFixes\RemoveUnreachableCode\CSharpRemoveUnreachableCodeCodeFixProvider.cs (1)
82if (statement.Parent?.Kind()
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (4)
47switch (node.Kind()) 87Debug.Fail($"Unexpected node kind for local/parameter declaration or reference: '{node.Kind()}'"); 206Debug.Fail($"Unexpected kind for originalCompoundAssignment: {originalCompoundAssignment.Kind()}"); 232var mappedBinaryExpressionKind = originalCompoundAssignment.Kind().MapCompoundAssignmentKindToBinaryExpressionKind();
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
78throw ExceptionUtilities.UnexpectedValue(declarationContext?.Kind());
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (1)
75switch (node.Kind())
src\Compilers\CSharp\Portable\Syntax\LambdaUtilities.cs (7)
20switch (node.Kind()) 75switch (newLambda.Kind()) 119throw ExceptionUtilities.UnexpectedValue(newLambda.Kind()); 147switch (parent.Kind()) 288switch (node.Kind()) 388switch (node.Kind()) 442switch (node.Parent.Kind())
Structure\Providers\BlockSyntaxStructureProvider.cs (1)
200=> (parent?.Kind()) switch
UseExpressionBody\UseExpressionBodyCodeRefactoringProvider.cs (2)
154if (helper.SyntaxKinds.Contains(current.Kind())) 219if (!helper.IsRelevantDeclarationNode(node) || !helper.SyntaxKinds.Contains(node.Kind()))
Wrapping\SeparatedSyntaxList\CSharpParameterWrapper.cs (1)
55if (declaration.Kind() == SyntaxKind.SimpleLambdaExpression)
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (2)
Diagnostics\Suppression\SuppressionTests.cs (2)
1072switch (context.Node.Kind()) 2066switch (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)
7641.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)
10107var expr = tree.GetRoot().DescendantNodes().Single(n => n.Kind() == kind); 10332var expr = tree.GetRoot().DescendantNodes().Single(n => n.Kind() == kind);
Semantics\RecordStructTests.cs (1)
6422Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind());
Semantics\TopLevelStatementsTests.cs (8)
6723Assert.Equal(SyntaxKind.InvocationExpression, context.Operation.Syntax.Kind()); 6743Assert.Equal(SyntaxKind.CompilationUnit, context.Operation.Syntax.Kind()); 6801Assert.Equal(SyntaxKind.CompilationUnit, context.OperationBlocks.Single().Syntax.Kind()); 6859Assert.Equal(SyntaxKind.CompilationUnit, context.OperationBlocks.Single().Syntax.Kind()); 6917Assert.Equal(SyntaxKind.CompilationUnit, context.CodeBlock.Kind()); 6985Assert.Equal(SyntaxKind.CompilationUnit, context.CodeBlock.Kind()); 7353Assert.Equal(SyntaxKind.CompilationUnit, context.OperationBlocks.Single().Syntax.Kind()); 7421Assert.Equal(SyntaxKind.CompilationUnit, context.Operation.Syntax.Kind());
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (53)
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)
15434var syntax = tree.GetCompilationUnitRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.ThisExpression);
DocumentationComments\CrefTests.cs (1)
5799if (typeSyntax.Parent.Kind() == SyntaxKind.NameMemberCref)
SymbolDisplay\SymbolDisplayTests.cs (13)
6438.Where(n => n.Kind() == SyntaxKind.LocalFunctionStatement) 6481.Where(n => n.Kind() == SyntaxKind.LocalFunctionStatement) 6515.Where(n => n.Kind() == SyntaxKind.LocalFunctionStatement) 6610.Where(n => n.Kind() == SyntaxKind.LocalFunctionStatement) 6867var declarations = semanticModel.SyntaxTree.GetRoot().DescendantNodes().Where(n => n.Kind() == SyntaxKind.StructDeclaration).Cast<BaseTypeDeclarationSyntax>().ToArray(); 6905var declarations = semanticModel.SyntaxTree.GetRoot().DescendantNodes().Where(n => n.Kind() == SyntaxKind.StructDeclaration).Cast<BaseTypeDeclarationSyntax>().ToArray(); 6943var declarations = semanticModel.SyntaxTree.GetRoot().DescendantNodes().Where(n => n.Kind() == SyntaxKind.StructDeclaration).Cast<BaseTypeDeclarationSyntax>().ToArray(); 7003var declaration = (BaseTypeDeclarationSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.StructDeclaration); 7075var declaration = (BaseTypeDeclarationSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.StructDeclaration); 7335var declaration = (BaseTypeDeclarationSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.StructDeclaration); 7488var declaration = (BaseTypeDeclarationSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.StructDeclaration); 8227var declaration = (LocalDeclarationStatementSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.LocalDeclarationStatement); 8278var 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\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 (167)
Classification\ClassificationHelpers.cs (5)
68return IsControlStatementKind(token.Parent.Kind()); 287=> 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)
75throw ExceptionUtilities.UnexpectedValue(node.Kind()); 137switch (declaration.Kind()) 626=> declaration.Kind() switch 647switch (declaration.Kind()) 735switch (node.Kind()) 814switch (member.Kind()) 873throw ExceptionUtilities.UnexpectedValue(member.Kind()); 907switch (node.Kind()) 1055switch (declaration.Kind()) 1111switch (attributeDeclaration.Kind()) 1159switch (declaration.Kind()) 1179switch (declaration.Kind()) 1272switch (declaration.Kind()) 1325=> declaration.Kind() switch 1621modifiers &= GetAllowedModifiers(declaration.Kind()); 1964switch (declaration.Kind()) 2005=> declaration.Kind() switch 2025switch (declaration.Kind()) 2071=> declaration.Kind() switch 2080=> declaration.Kind() switch 2090switch (declaration.Kind()) 2228switch (declaration.Kind()) 2274switch (declaration.Kind()) 2329switch (declaration.Kind()) 2400switch (declaration.Kind()) 2440switch (declaration.Kind()) 2480var result = declaration.Kind() switch 2506switch (declaration.Kind()) 2544var newAccessors = AsAccessorList(accessors, declaration.Kind()); 2567=> declaration.Kind() switch 2591switch (node.Kind()) 2600switch (node.Kind()) 2754if (fullDecl != declaration && fullDecl.IsKind(newFullDecl.Kind())) 2785var kind = decl1.Kind(); 2811var kind = decl1.Kind(); 2973=> declaration.Kind() switch 3011switch (declaration.Kind()) 3055switch (parent.Kind()) 3394switch (expression.Kind())
FindSymbols\CSharpDeclaredSymbolInfoFactoryService.cs (1)
617switch (container.Kind())
Formatting\CSharpSyntaxFormattingService.cs (3)
345(currentTokenParentParent.Kind() == SyntaxKind.SimpleLambdaExpression || 346currentTokenParentParent.Kind() == SyntaxKind.ParenthesizedLambdaExpression || 347currentTokenParentParent.Kind() == SyntaxKind.AnonymousMethodExpression))
Formatting\TypingFormattingRule.cs (1)
104while (node != null && node.Kind() != SyntaxKind.CompilationUnit)
Rename\LocalConflictVisitor.cs (1)
166foreach (var child in body.ChildNodes().Where(c => c.Kind() != SyntaxKind.QueryContinuation))
Simplification\CSharpSimplificationService.Expander.cs (11)
629(parent is MemberAccessExpressionSyntax && parent.Kind() != SyntaxKind.SimpleMemberAccessExpression) || 630((parent.Kind() == SyntaxKind.SimpleMemberAccessExpression || parent.Kind() == SyntaxKind.NameMemberCref) && originalSimpleName.IsRightSideOfDot()) || 631(parent.Kind() == SyntaxKind.QualifiedName && originalSimpleName.IsRightSideOfQualifiedName()) || 632(parent.Kind() == SyntaxKind.AliasQualifiedName) || 633(parent.Kind() == SyntaxKind.NameColon)) 643if (symbol.IsConstructor() && (parent.Kind() == SyntaxKind.ObjectCreationExpression || parent.Kind() == SyntaxKind.NameMemberCref)) 873if (parent.Kind() is SyntaxKind.ObjectInitializerExpression or SyntaxKind.WithInitializerExpression) 875return currentNode.Kind() == SyntaxKind.SimpleAssignmentExpression && 954switch (parent.Kind())
Simplification\Reducers\CSharpMiscellaneousReducer.cs (1)
180switch (node.Kind())
Simplification\Simplifiers\NameSimplifier.cs (2)
496if (name.Parent.Kind() == SyntaxKind.Attribute || name.IsRightSideOfDotOrColonColon()) 558switch (parent.Kind())
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)
107if (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)
27=> kind = node.Kind(); 90return node?.Kind() 395switch (node.Kind()) 411switch (node.Kind()) 426switch (node.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\CSharpTriviaFormatter.DocumentationCommentExteriorCommentRewriter.cs (1)
72if (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) 260if (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)
253_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), 375currentToken.Parent?.Kind() is not SyntaxKind.CollectionExpression and not SyntaxKind.AttributeList &&
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Indentation\CSharpSmartTokenFormatter.cs (1)
75endToken.Parent.Parent?.Kind() is SyntaxKind.TryStatement or SyntaxKind.DoStatement;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (2)
116Debug.Assert(oldNode.Kind() == newNode.Kind());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (2)
28switch (declaration.Kind()) 155switch (declaration.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (13)
218_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), 640=> node.Kind() == SyntaxKind.PropertyPatternClause; 720var kind = node.Kind(); 816switch (node.Kind()) 879Debug.Assert(name != null, "Unexpected node type " + node.Kind()); 1185=> node?.Parent?.Kind() is SyntaxKind.PostIncrementExpression or SyntaxKind.PreIncrementExpression; 1188=> node?.Parent?.Kind() is SyntaxKind.PostDecrementExpression or SyntaxKind.PreDecrementExpression; 1229=> SyntaxFacts.IsDocumentationCommentTrivia(node.Kind()); 1232=> node?.Kind() is SyntaxKind.UsingDirective or SyntaxKind.ExternAliasDirective; 1250if (SyntaxFacts.IsNamespaceMemberDeclaration(node.Kind())) 1266switch (node.Kind()) 1271return node.Parent?.Parent?.Kind() is SyntaxKind.FieldDeclaration or SyntaxKind.EventFieldDeclaration; 1295=> SyntaxFacts.IsTypeDeclaration(node.Kind());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (7)
1098Debug.Assert(currentOld.Kind() == currentNew.Kind()); 1154Debug.Assert(currentOld.Kind() == currentNew.Kind()); 1155if (!haveHitArgumentNode && currentOld.Kind() != SyntaxKind.Argument) 1184Debug.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) 357node.Kind() is SyntaxKind.IfStatement or 440if (token.Parent.Kind() is SyntaxKind.Block or
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (12)
82if (node.Kind() is not SyntaxKind.PrimaryConstructorBaseType || 83previousNode.Kind() is SyntaxKind.ArgumentList) 97node.Kind() is SyntaxKind.Attribute or 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)
62if (typeName?.FirstAncestorOrSelf<SyntaxNode>(a => a.Kind() is SyntaxKind.DeclarationExpression or SyntaxKind.VariableDeclaration or SyntaxKind.ForEachStatement) is not { } declaration) 84Debug.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 (2)
2344previousToken.Parent?.Kind() is SyntaxKind.PointerType or SyntaxKind.NullableType) 2913switch (name.Parent.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\NameSyntaxExtensions.cs (1)
54if (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)
3816Assert.Equal(SyntaxKind.FieldDeclaration, xTypedT.Kind()); 3821Assert.Equal(SyntaxKind.FieldDeclaration, xNamedQ.Kind()); 3826Assert.Equal(SyntaxKind.FieldDeclaration, xInitialized.Kind()); 3831Assert.Equal(SyntaxKind.FieldDeclaration, xPrivate.Kind()); 3836Assert.Equal(SyntaxKind.FieldDeclaration, xReadOnly.Kind()); 3841Assert.Equal(SyntaxKind.FieldDeclaration, xAttributed.Kind()); 4144Assert.Equal(SyntaxKind.AttributeList, xNamedQ.Kind()); 4149Assert.Equal(SyntaxKind.AttributeList, xWithArg.Kind()); 4324Assert.Equal(SyntaxKind.AttributeList, xNamedQ.Kind()); 4329Assert.Equal(SyntaxKind.AttributeList, xWithArg.Kind()); 4407Assert.Equal(SyntaxKind.AttributeList, attrX.Kind()); 4411Assert.Equal(SyntaxKind.Attribute, attrY.Kind()); 4415Assert.Equal(SyntaxKind.Attribute, attrZ.Kind()); 4419Assert.Equal(SyntaxKind.AttributeList, attrP.Kind()); 4426Assert.Equal(SyntaxKind.AttributeList, attrA.Kind()); 4430Assert.Equal(SyntaxKind.Attribute, attrB.Kind()); 4434Assert.Equal(SyntaxKind.Attribute, attrC.Kind()); 4438Assert.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()); 163Assert.Equal(SyntaxKind.MethodDeclaration, n1.Kind()); 166Assert.Equal(SyntaxKind.MethodDeclaration, n2.Kind()); 169Assert.Equal(SyntaxKind.MethodDeclaration, n3.Kind()); 196Assert.Equal(SyntaxKind.ClassDeclaration, n1.Kind()); 198Assert.Equal(SyntaxKind.ClassDeclaration, n2.Kind()); 231Assert.Equal(SyntaxKind.MethodDeclaration, n1.Kind()); 234Assert.Equal(SyntaxKind.MethodDeclaration, n2.Kind()); 261Assert.Equal(SyntaxKind.ClassDeclaration, n1.Kind()); 292Assert.Equal(SyntaxKind.ClassDeclaration, n1.Kind()); 320Assert.Equal(SyntaxKind.ClassDeclaration, n1.Kind()); 322Assert.Equal(SyntaxKind.ClassDeclaration, n2.Kind()); 349Assert.Equal(SyntaxKind.ClassDeclaration, n1.Kind()); 351Assert.Equal(SyntaxKind.StructDeclaration, n2.Kind()); 388Assert.Equal(SyntaxKind.ClassDeclaration, n1.Kind()); 390Assert.Equal(SyntaxKind.StructDeclaration, n2.Kind()); 406Assert.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)
163switch (node.Kind())
CodeModel\CSharpCodeModelService_Prototype.cs (1)
70Debug.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)