868 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)
496Debug.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)
2979switch (syntax.Kind()) 4590typeSyntax: node.Kind() == SyntaxKind.StackAllocArrayCreationExpression 6097Debug.Assert(memberInitializerSyntax.Kind() == SyntaxKind.SimpleAssignmentExpression); 8093(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)
3089if (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) 3555return IsValidStatementExpression(expressionSyntax, expression) || expressionSyntax.Kind() == SyntaxKind.ThrowExpression;
Binder\Binder_Symbols.cs (1)
2307if (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)
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)); 1832(local.ScopeDesignatorOpt?.Kind() is SyntaxKind.SwitchSection or SyntaxKind.SwitchExpressionArm)))
Compilation\CSharpCompilation.cs (1)
4778Func<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) 5092switch (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)
6754if (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)
101(local.ScopeDesignatorOpt?.Kind() == SyntaxKind.SwitchSection || 102local.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)
226RoslynDebug.Assert(SyntaxBindingUtilities.BindsToResumableStateMachineState(node) || SyntaxBindingUtilities.BindsToTryStatement(node), $"Unexpected syntax: {node.Kind()}"); 331if ((local.SynthesizedKind == SynthesizedLocalKind.UserDefined && local.ScopeDesignatorOpt?.Kind() != SyntaxKind.SwitchSection) || 757(local.ScopeDesignatorOpt?.Kind() == SyntaxKind.SwitchSection || 758local.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)
3592switch (syntax.Kind()) 3626throw 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 (96)
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)
102if (invocationOrCreation?.Kind() is not SyntaxKind.InvocationExpression and not SyntaxKind.ObjectCreationExpression) 291switch (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)
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\ExpressionSyntaxExtensions.cs (4)
289switch (parent.Kind()) 292if (parent.Parent?.Kind() == SyntaxKind.TupleExpression) 408switch (parent.Kind()) 524switch (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) 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)
261_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), 379currentToken.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 (3)
116Debug.Assert(oldNode.Kind() == newNode.Kind()); 411=> node.Ancestors().Any(n => n.Kind() is
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)
226_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), 630=> node.Kind() == SyntaxKind.PropertyPatternClause; 710var kind = node.Kind(); 802switch (node.Kind()) 865Debug.Assert(name != null, "Unexpected node type " + node.Kind()); 1140=> node?.Parent?.Kind() is SyntaxKind.PostIncrementExpression or SyntaxKind.PreIncrementExpression; 1143=> node?.Parent?.Kind() is SyntaxKind.PostDecrementExpression or SyntaxKind.PreDecrementExpression; 1191=> SyntaxFacts.IsDocumentationCommentTrivia(node.Kind()); 1194=> node?.Kind() is SyntaxKind.UsingDirective or SyntaxKind.ExternAliasDirective; 1212if (SyntaxFacts.IsNamespaceMemberDeclaration(node.Kind())) 1228switch (node.Kind()) 1233return node.Parent?.Parent?.Kind() is SyntaxKind.FieldDeclaration or SyntaxKind.EventFieldDeclaration; 1257=> SyntaxFacts.IsTypeDeclaration(node.Kind());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (7)
1174Debug.Assert(currentOld.Kind() == currentNew.Kind()); 1230Debug.Assert(currentOld.Kind() == currentNew.Kind()); 1231if (!haveHitArgumentNode && currentOld.Kind() != SyntaxKind.Argument) 1260Debug.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 (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 (33)
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)
79throw 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)
37if (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) 339m[nameof(statementNode)] = statementNode.Kind(); 368switch (statementNode.Kind()) 482if (currentNode.Kind() is not (SyntaxKind.InterpolatedStringExpression or SyntaxKind.StringLiteralExpression or SyntaxKind.Utf8StringLiteralExpression or SyntaxKind.CharacterLiteralExpression)) 537switch (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()) 32756var 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)
1131Assert.Equal(SyntaxKind.ClassDeclaration, baseWithargs.Parent.Parent.Kind()); 3923Assert.Equal(SyntaxKind.SimpleBaseType, identifier.Parent.Kind()); 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 (7)
21318Assert.Equal(SyntaxKind.RecordDeclaration, baseWithargs.Parent.Parent.Kind()); 26473Assert.Equal(SyntaxKind.SimpleBaseType, identifier.Parent.Kind()); 26906Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind()); 26910Assert.Equal(SyntaxKind.RecordDeclaration, context.Operation.Syntax.Kind()); 26914Assert.Equal(SyntaxKind.ConstructorDeclaration, context.Operation.Syntax.Kind()); 26928Assert.Equal(SyntaxKind.PrimaryConstructorBaseType, context.Operation.Syntax.Kind()); 26943Assert.Equal(SyntaxKind.BaseConstructorInitializer, context.Operation.Syntax.Kind());
Microsoft.CodeAnalysis.CSharp.Features (146)
AddImport\CSharpAddImportFeatureService.cs (3)
115if (nameNode?.Parent?.Kind() is not SyntaxKind.SimpleMemberAccessExpression and not SyntaxKind.MemberBindingExpression) 120if (memberAccess?.Parent?.Kind() is SyntaxKind.SimpleMemberAccessExpression or SyntaxKind.ElementAccessExpression || 121memberBinding?.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()) 621_ => 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)
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)
52_ => throw ExceptionUtilities.UnexpectedValue(declaration.Kind()) 67_ => throw ExceptionUtilities.UnexpectedValue(declaration.Kind())
Completion\CompletionProviders\CompletionUtilities.cs (1)
169symbol.DeclaringSyntaxReferences[0].GetSyntax().Kind() == SyntaxKind.DefaultSwitchLabel)
Completion\CompletionProviders\CrefCompletionProvider.cs (1)
137if (token.Parent?.Kind() is not (SyntaxKind.CrefParameterList or SyntaxKind.CrefBracketedParameterList))
Completion\CompletionProviders\ExplicitInterfaceMemberCompletionProvider.cs (1)
81var kind = ancestor.Kind();
Completion\CompletionProviders\ExplicitInterfaceTypeCompletionProvider.cs (1)
141=> 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)
929switch (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\CSharpEditAndContinueAnalyzer.cs (35)
74switch (current.Kind()) 138switch (current.Parent.Parent!.Kind()) 229switch (node.Kind()) 597switch (node.Kind()) 700switch (parent.Kind()) 756switch (node.Kind()) 775if (oldStatement.Kind() != newStatement.Kind()) 780switch (oldStatement.Kind()) 926=> node.Kind() is SyntaxKind.RecordDeclaration or SyntaxKind.RecordStructDeclaration; 1389if (node.Kind() is SyntaxKind.UsingDirective or SyntaxKind.NamespaceDeclaration or SyntaxKind.FileScopedNamespaceDeclaration) 1497switch (oldNode.Kind()) 1603=> TryGetDiagnosticSpanImpl(node.Kind(), node, editKind); 1941switch (lambda.Kind()) 1991=> TryGetDisplayNameImpl(node, editKind) ?? throw ExceptionUtilities.UnexpectedValue(node.Kind()); 1995switch (node.Kind()) 2105return node.Parent!.Kind() switch 2224throw ExceptionUtilities.UnexpectedValue(node.Kind()); 2259switch (node.Kind()) 2381switch (newNode.Kind()) 2397switch (node.Kind()) 2421switch (oldNode.Kind()) 2447switch (newNode.Kind()) 2491if (node.Kind() is SyntaxKind.StackAllocArrayCreationExpression or SyntaxKind.ImplicitStackAllocArrayCreationExpression) 2577var kind = current.Kind(); 2595RoslynDebug.Assert(current.Parent.Kind() == SyntaxKind.TryStatement); 2641switch (oldNode.Kind()) 2654throw ExceptionUtilities.UnexpectedValue(oldNode.Kind()); 2675switch (node.Kind()) 2703throw ExceptionUtilities.UnexpectedValue(node.Kind()); 2741switch (node.Parent.Kind()) 2774switch (containingStatementPart.Kind()) 2807switch (statement.Kind()) 2817throw ExceptionUtilities.UnexpectedValue(statement.Kind()); 2956switch (node.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.ExpressionCodeGenerator.cs (4)
47expression.Parent.Kind() == SyntaxKind.EqualsValueClause && 49expression.Parent.Parent.Kind() == SyntaxKind.VariableDeclarator) 64switch (expression.Kind()) 77throw 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)
GenerateType\CSharpGenerateTypeService.cs (2)
96return baseList.Parent.Kind() is 645if (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)
81return 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)
102if (invocationOrCreation?.Kind() is not SyntaxKind.InvocationExpression and not SyntaxKind.ObjectCreationExpression) 291switch (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)
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\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)
79throw 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)
203=> (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)
6494Assert.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)
6610.Where(n => n.Kind() == SyntaxKind.LocalFunctionStatement) 6653.Where(n => n.Kind() == SyntaxKind.LocalFunctionStatement) 6687.Where(n => n.Kind() == SyntaxKind.LocalFunctionStatement) 6782.Where(n => n.Kind() == SyntaxKind.LocalFunctionStatement) 7039var declarations = semanticModel.SyntaxTree.GetRoot().DescendantNodes().Where(n => n.Kind() == SyntaxKind.StructDeclaration).Cast<BaseTypeDeclarationSyntax>().ToArray(); 7077var declarations = semanticModel.SyntaxTree.GetRoot().DescendantNodes().Where(n => n.Kind() == SyntaxKind.StructDeclaration).Cast<BaseTypeDeclarationSyntax>().ToArray(); 7115var declarations = semanticModel.SyntaxTree.GetRoot().DescendantNodes().Where(n => n.Kind() == SyntaxKind.StructDeclaration).Cast<BaseTypeDeclarationSyntax>().ToArray(); 7175var declaration = (BaseTypeDeclarationSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.StructDeclaration); 7247var declaration = (BaseTypeDeclarationSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.StructDeclaration); 7507var declaration = (BaseTypeDeclarationSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.StructDeclaration); 7660var declaration = (BaseTypeDeclarationSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.StructDeclaration); 8399var declaration = (LocalDeclarationStatementSyntax)semanticModel.SyntaxTree.GetRoot().DescendantNodes().Single(n => n.Kind() == SyntaxKind.LocalDeclarationStatement); 8450var 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 (164)
Classification\ClassificationHelpers.cs (5)
64IsControlStatementKind(token.Parent.Kind()); 284=> parentNode.Kind() switch 335=> identifier.Parent!.Kind() switch 359if (token.Parent.Kind() is SyntaxKind.TypeParameterList or 373if (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 (38)
76throw ExceptionUtilities.UnexpectedValue(node.Kind()); 138switch (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()); 1943switch (declaration.Kind()) 1984=> declaration.Kind() switch 2004switch (declaration.Kind()) 2050=> declaration.Kind() switch 2059=> declaration.Kind() switch 2069switch (declaration.Kind()) 2207switch (declaration.Kind()) 2253switch (declaration.Kind()) 2308switch (declaration.Kind()) 2379switch (declaration.Kind()) 2419switch (declaration.Kind()) 2459var result = declaration.Kind() switch 2512var newAccessors = AsAccessorList(accessors, declaration.Kind()); 2535=> declaration.Kind() switch 2559switch (node.Kind()) 2568switch (node.Kind()) 2722if (fullDecl != declaration && fullDecl.IsKind(newFullDecl.Kind())) 2753var kind = decl1.Kind(); 2779var kind = decl1.Kind(); 2941=> declaration.Kind() switch 2979switch (declaration.Kind()) 3023switch (parent.Kind()) 3295switch (expression.Kind())
FindSymbols\CSharpDeclaredSymbolInfoFactoryService.cs (1)
617switch (container.Kind())
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)
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\NameSimplifier.cs (2)
496if (name.Parent.Kind() == SyntaxKind.Attribute || name.IsRightSideOfDotOrColonColon()) 557switch (parent.Kind())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (4)
289switch (parent.Kind()) 292if (parent.Parent?.Kind() == SyntaxKind.TupleExpression) 408switch (parent.Kind()) 524switch (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) 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)
261_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), 379currentToken.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 (3)
116Debug.Assert(oldNode.Kind() == newNode.Kind()); 411=> node.Ancestors().Any(n => n.Kind() is
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)
226_ => throw ExceptionUtilities.UnexpectedValue(node.Kind()), 630=> node.Kind() == SyntaxKind.PropertyPatternClause; 710var kind = node.Kind(); 802switch (node.Kind()) 865Debug.Assert(name != null, "Unexpected node type " + node.Kind()); 1140=> node?.Parent?.Kind() is SyntaxKind.PostIncrementExpression or SyntaxKind.PreIncrementExpression; 1143=> node?.Parent?.Kind() is SyntaxKind.PostDecrementExpression or SyntaxKind.PreDecrementExpression; 1191=> SyntaxFacts.IsDocumentationCommentTrivia(node.Kind()); 1194=> node?.Kind() is SyntaxKind.UsingDirective or SyntaxKind.ExternAliasDirective; 1212if (SyntaxFacts.IsNamespaceMemberDeclaration(node.Kind())) 1228switch (node.Kind()) 1233return node.Parent?.Parent?.Kind() is SyntaxKind.FieldDeclaration or SyntaxKind.EventFieldDeclaration; 1257=> SyntaxFacts.IsTypeDeclaration(node.Kind());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (7)
1174Debug.Assert(currentOld.Kind() == currentNew.Kind()); 1230Debug.Assert(currentOld.Kind() == currentNew.Kind()); 1231if (!haveHitArgumentNode && currentOld.Kind() != SyntaxKind.Argument) 1260Debug.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 (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)
37if (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)
161switch (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)