362 references to IfStatementSyntax
Microsoft.CodeAnalysis.CSharp (26)
Binder\Binder_Statements.cs (6)
76result = BindIfStatement((IfStatementSyntax)node, diagnostics); 2533private BoundStatement BindIfStatement(IfStatementSyntax node, BindingDiagnosticBag diagnostics) 2537static BoundStatement bindIfStatement(Binder binder, IfStatementSyntax node, BindingDiagnosticBag diagnostics) 2539var stack = ArrayBuilder<(Binder, IfStatementSyntax IfStatementSyntax, BoundExpression Condition, BoundStatement Consequence)>.GetInstance(); 2555if (elseStatementSyntax is IfStatementSyntax ifStatementSyntax) 2596protected virtual bool TryGetBoundElseIfStatement(IfStatementSyntax node, out BoundStatement? alternative)
Binder\ExpressionVariableFinder.cs (1)
203public override void VisitIfStatement(IfStatementSyntax node)
Binder\LocalBinderFactory.cs (2)
815public override void VisitIfStatement(IfStatementSyntax node) 829if (elseStatementSyntax is IfStatementSyntax ifStatementSyntax)
Compilation\MemberSemanticModel.cs (1)
2526protected override bool TryGetBoundElseIfStatement(IfStatementSyntax node, out BoundStatement alternative)
Lowering\Instrumentation\DebugInfoInjector.cs (2)
360var syntax = (IfStatementSyntax)original.Syntax;
Lowering\LocalRewriter\LocalRewriter_IfStatement.cs (4)
81var syntax = (IfStatementSyntax)node.Syntax; 102var syntax = (IfStatementSyntax)node.Syntax;
Parser\LanguageParser.cs (3)
9514private IfStatementSyntax ParseIfStatement(SyntaxList<AttributeListSyntax> attributes) 9553IfStatementSyntax ifStatement; 9579private IfStatementSyntax ParseMisplacedElse(SyntaxList<AttributeListSyntax> attributes)
Syntax\IfStatementSyntax.cs (3)
11public IfStatementSyntax Update(SyntaxToken ifKeyword, SyntaxToken openParenToken, ExpressionSyntax condition, SyntaxToken closeParenToken, StatementSyntax statement, ElseClauseSyntax? @else) 20public static IfStatementSyntax IfStatement(ExpressionSyntax condition, StatementSyntax statement, ElseClauseSyntax? @else) 23public static IfStatementSyntax IfStatement(SyntaxToken ifKeyword, SyntaxToken openParenToken, ExpressionSyntax condition, SyntaxToken closeParenToken, StatementSyntax statement, ElseClauseSyntax? @else)
Syntax\LookupPosition.cs (4)
343return ((IfStatementSyntax)statement).IfKeyword; 406return GetFirstExcludedIfStatementToken((IfStatementSyntax)statement); 453private static SyntaxToken GetFirstExcludedIfStatementToken(IfStatementSyntax ifStmt) 462if (elseOpt.Statement is IfStatementSyntax nestedIf)
Microsoft.CodeAnalysis.CSharp.CodeStyle (49)
src\Analyzers\CSharp\Analyzers\AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs (11)
126if (statement is IfStatementSyntax ifStatementNode) 200if (statement is IfStatementSyntax ifStatement && ifStatement.Statement == embeddedStatement) 246var outermostIfStatement = GetOutermostIfStatementOfSequence(statement); 256/// Gets the top-most <see cref="IfStatementSyntax"/> for which <paramref name="ifStatementOrElseClause"/> is 265private static IfStatementSyntax GetOutermostIfStatementOfSequence(SyntaxNode ifStatementOrElseClause) 267IfStatementSyntax result; 270result = (IfStatementSyntax)ifStatementOrElseClause.GetRequiredParent(); 275result = (IfStatementSyntax)ifStatementOrElseClause; 279result = (IfStatementSyntax)result.GetRequiredParent().GetRequiredParent(); 288private static bool AnyPartOfIfSequenceUsesBraces(IfStatementSyntax? statement) 300statement = elseStatement as IfStatementSyntax;
src\Analyzers\CSharp\Analyzers\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessAnalyzer.cs (5)
49var ifStatement = (IfStatementSyntax)syntaxContext.Node; 114IfStatementSyntax ifStatement, 167IfStatementSyntax ifStatement, 217IfStatementSyntax ifStatement,
src\Analyzers\CSharp\Analyzers\UseCoalesceExpression\CSharpUseCoalesceExpressionForIfNullStatementCheckDiagnosticAnalyzer.cs (5)
26IfStatementSyntax> 40protected override ExpressionSyntax GetConditionOfIfStatement(IfStatementSyntax ifStatement) 60protected override bool TryGetEmbeddedStatement(IfStatementSyntax ifStatement, [NotNullWhen(true)] out StatementSyntax? whenTrueStatement) 69protected override bool HasElseBlock(IfStatementSyntax ifStatement) 72protected override StatementSyntax? TryGetPreviousStatement(IfStatementSyntax ifStatement)
src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUpdateExpressionSyntaxHelper.cs (2)
35var ifStatement = (IfStatementSyntax)statement;
src\Analyzers\CSharp\Analyzers\UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs (3)
105IfStatementSyntax ifStatement, 125var ifStatement = (IfStatementSyntax)context.Node;
src\Analyzers\CSharp\Analyzers\UseConditionalExpression\CSharpUseConditionalExpressionForAssignmentDiagnosticAnalyzer.cs (1)
15: AbstractUseConditionalExpressionForAssignmentDiagnosticAnalyzer<IfStatementSyntax>
src\Analyzers\CSharp\Analyzers\UseConditionalExpression\CSharpUseConditionalExpressionForReturnDiagnosticAnalyzer.cs (1)
16: AbstractUseConditionalExpressionForReturnDiagnosticAnalyzer<IfStatementSyntax>
src\Analyzers\CSharp\Analyzers\UseNullPropagation\CSharpUseNullPropagationDiagnosticAnalyzer.cs (2)
28IfStatementSyntax, 68IfStatementSyntax ifStatement,
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs (2)
164var ifStatement = (IfStatementSyntax)current;
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpIsAndCastCheckDiagnosticAnalyzer.cs (2)
77out var ifStatement, out var localDeclarationStatement, 164[NotNullWhen(true)] out IfStatementSyntax? ifStatement,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (1)
136(nodeParent is IfStatementSyntax ifStatement && ifStatement.Condition == node) ||
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (3)
121IfStatementSyntax or 136IfStatementSyntax n => n.Statement, 714IfStatementSyntax n => (n.OpenParenToken, n.CloseParenToken),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (2)
291IfStatementSyntax ifStatement => ifStatement.CloseParenToken.Equals(token), 364return node is IfStatementSyntax or
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (2)
291if (node is IfStatementSyntax ifStatement && ifStatement.Statement != null && !(ifStatement.Statement is BlockSyntax)) 299if (elseClause.Statement is not (BlockSyntax or IfStatementSyntax))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (1)
38if (node is IfStatementSyntax ifStatementNode)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\WrappingFormattingRule.cs (2)
130var ifStatementNode = node as IfStatementSyntax;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (1)
107var node = TryGetAncestorForLocation<IfStatementSyntax>(root, position);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (3)
497else if (currentOriginalNode is IfStatementSyntax originalIfStatement) 499var newIfStatement = (IfStatementSyntax)currentReplacedNode;
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (26)
src\Analyzers\CSharp\CodeFixes\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessCodeFixProvider.cs (5)
81var ifStatement = (IfStatementSyntax)root.FindNode(ifStatementLocation.SourceSpan); 128var ifStatement = (IfStatementSyntax)root.FindNode(ifStatementLocation.SourceSpan); 156private static T AppendTriviaWithoutEndOfLines<T>(T newStatement, IfStatementSyntax ifStatement) where T : SyntaxNode
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (2)
504else if (node is IfStatementSyntax ifStatement) 784else if (node is IfStatementSyntax ifStatement)
src\Analyzers\CSharp\CodeFixes\UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs (1)
53if (coalesceOrIfStatement is IfStatementSyntax ifStatement)
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionForAssignmentCodeFixProvider.cs (2)
26StatementSyntax, IfStatementSyntax, LocalDeclarationStatementSyntax, VariableDeclaratorSyntax, ExpressionSyntax, ConditionalExpressionSyntax> 45IfStatementSyntax ifStatement, StatementSyntax statement)
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionForReturnCodeFixProvider.cs (3)
23: AbstractUseConditionalExpressionForReturnCodeFixProvider<StatementSyntax, IfStatementSyntax, ExpressionSyntax, ConditionalExpressionSyntax> 32IfStatementSyntax ifStatement, StatementSyntax statement) 46if (operation.Syntax is IfStatementSyntax { Condition: CheckedExpressionSyntax exp })
src\Analyzers\CSharp\CodeFixes\UseNullPropagation\CSharpUseNullPropagationCodeFixProvider.cs (2)
28IfStatementSyntax, 47protected override SyntaxNode PostProcessElseIf(IfStatementSyntax ifStatement, StatementSyntax newWhenTrueStatement)
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpIsAndCastCheckCodeFixProvider.cs (8)
57var ifStatement = (IfStatementSyntax)ifStatementLocation.FindNode(cancellationToken); 79var currentIf = (IfStatementSyntax)i; 84private static IfStatementSyntax GetUpdatedIfStatement( 87IfStatementSyntax originalIf, 88IfStatementSyntax currentIf) 90var newIf = currentIf.ReplaceNode(currentIf.Condition, updatedCondition);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (3)
162IfStatementSyntax ifStatement => InferTypeInIfStatement(ifStatement), 229IfStatementSyntax ifStatement => InferTypeInIfStatement(ifStatement, token), 1270private IEnumerable<TypeInferenceInfo> InferTypeInIfStatement(IfStatementSyntax ifStatement, SyntaxToken? previousToken = null)
Microsoft.CodeAnalysis.CSharp.EditorFeatures (9)
AutomaticCompletion\AutomaticLineEnderCommandHandler.cs (1)
337or IfStatementSyntax
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (8)
162IfStatementSyntax ifStatementNode => AddBraceToIfStatement(services, root, ifStatementNode, formattingOptions, statement, cancellationToken), 230IfStatementSyntax ifStatementNode, 294if (elseClauseNode.Statement is IfStatementSyntax) 314if (elseClauseNode.Parent is IfStatementSyntax { Parent: BlockSyntax }) 479IfStatementSyntax ifStatementNode => ShouldAddBraceForIfStatement(ifStatementNode, caretPosition), 678private static bool ShouldAddBraceForIfStatement(IfStatementSyntax ifStatementNode, int caretPosition) 698if (elseClauseNode.Statement is IfStatementSyntax ifStatementNode) 947IfStatementSyntax ifStatementNode => ifStatementNode.WithStatement(block),
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (3)
RefactoringHelpers\RefactoringHelpersTests.cs (3)
1650await TestAsync<IfStatementSyntax>( 1676await TestAsync<IfStatementSyntax>( 1702await TestMissingAsync<IfStatementSyntax>(
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (4)
Semantics\OutVarTests.cs (2)
8800var statement = (IfStatementSyntax)SyntaxFactory.ParseStatement(@"
Semantics\PatternMatchingTests_Scope.cs (2)
1281var statement = (IfStatementSyntax)SyntaxFactory.ParseStatement(@"
Microsoft.CodeAnalysis.CSharp.Features (149)
Completion\KeywordRecommenders\ElseKeywordRecommender.cs (1)
37foreach (var ifStatement in token.GetAncestors<IfStatementSyntax>())
ConvertIfToSwitch\CSharpConvertIfToSwitchCodeRefactoringProvider.cs (2)
18: AbstractConvertIfToSwitchCodeRefactoringProvider<IfStatementSyntax, ExpressionSyntax, BinaryExpressionSyntax, PatternSyntax> 43if (syntaxToRemove is (IfStatementSyntax or BlockSyntax) and { Parent: ElseClauseSyntax elseClause } &&
ConvertIfToSwitch\CSharpConvertIfToSwitchCodeRefactoringProvider.Rewriting.cs (1)
69public override SyntaxNode CreateSwitchStatement(IfStatementSyntax ifStatement, SyntaxNode expression, IEnumerable<SyntaxNode> sectionList)
ConvertLinq\ConvertForEachToLinqQuery\AbstractConverter.cs (4)
86var ifStatement = (IfStatementSyntax)node.Node; 273var ifStatement = (IfStatementSyntax)node.Node;
ConvertLinq\ConvertForEachToLinqQuery\CSharpConvertForEachToLinqQueryProvider.cs (2)
111var ifStatement = (IfStatementSyntax)current;
Debugging\CSharpProximityExpressionsService.RelevantExpressionsCollector.cs (1)
47public override void VisitIfStatement(IfStatementSyntax node)
Debugging\CSharpProximityExpressionsService.Worker.cs (2)
259var ifStatement = statement as IfStatementSyntax;
EditAndContinue\BreakpointSpans.cs (2)
729var ifStatement = (IfStatementSyntax)statement;
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (6)
816return AreEquivalentActiveStatements((IfStatementSyntax)oldStatement, (IfStatementSyntax)newStatement); 849private static bool AreEquivalentActiveStatements(IfStatementSyntax oldNode, IfStatementSyntax newNode) 1798var ifStatement = (IfStatementSyntax)node;
EditAndContinue\SyntaxComparer.cs (4)
875var leftIf = (IfStatementSyntax)leftNode; 876var rightIf = (IfStatementSyntax)rightNode;
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs (1)
169public override SyntaxNode VisitIfStatement(IfStatementSyntax node)
ExtractMethod\CSharpSelectionValidator.Validator.cs (2)
36IfStatementSyntax or 64IfStatementSyntax or
Highlighting\KeywordHighlighters\IfStatementHighlighter.cs (4)
25internal sealed class IfStatementHighlighter() : AbstractKeywordHighlighter<IfStatementSyntax>(findInsideTrivia: false) 31IfStatementSyntax ifStatement, List<TextSpan> highlights, CancellationToken cancellationToken) 40IfStatementSyntax ifStatement, List<TextSpan> highlights) 50if (ifStatement.Else.Statement is IfStatementSyntax elseIfStatement)
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (12)
28SyntaxKind, StatementSyntax, IfStatementSyntax, StatementSyntax> 33protected override bool IsElseless(IfStatementSyntax ifNode) 36protected override bool CanInvert(IfStatementSyntax ifNode) 39protected override SyntaxNode GetCondition(IfStatementSyntax ifNode) 42protected override StatementRange GetIfBodyStatementRange(IfStatementSyntax ifNode) 57protected override StatementSyntax GetIfBody(IfStatementSyntax ifNode) 63protected override StatementSyntax GetElseBody(IfStatementSyntax ifNode) 132protected override IfStatementSyntax UpdateIf( 134IfStatementSyntax ifNode, 152var updatedIf = ifNode 154.WithStatement(trueStatement is IfStatementSyntax 180private static bool ShouldKeepFalse(IfStatementSyntax originalIfStatement, [NotNullWhen(returnValue: true)] StatementSyntax? falseStatement)
Snippets\CSharpElseSnippetProvider.cs (1)
43foreach (var ifStatement in token.GetAncestors<IfStatementSyntax>())
Snippets\CSharpIfSnippetProvider.cs (4)
21internal sealed class CSharpIfSnippetProvider() : AbstractIfSnippetProvider<IfStatementSyntax, ExpressionSyntax> 30protected override ExpressionSyntax GetCondition(IfStatementSyntax node) 33protected override int GetTargetCaretPosition(IfStatementSyntax ifStatement, SourceText sourceText) 39protected override Task<Document> AddIndentationToDocumentAsync(Document document, IfStatementSyntax ifStatement, CancellationToken cancellationToken)
SplitOrMergeIfStatements\CSharpIfLikeStatementGenerator.cs (37)
29public bool IsIfOrElseIf(SyntaxNode node) => node is IfStatementSyntax; 33if (expression.Parent is IfStatementSyntax ifStatement && ifStatement.Condition == expression) 45if (node is IfStatementSyntax && node.Parent is ElseClauseSyntax) 47parentIfOrElseIf = (IfStatementSyntax)node.Parent.Parent; 57var ifStatement = (IfStatementSyntax)ifOrElseIf; 58if (ifStatement.Else?.Statement is IfStatementSyntax elseIfStatement) 70var ifStatement = (IfStatementSyntax)ifOrElseIf; 76var ifStatement = (IfStatementSyntax)ifOrElseIf; 80ifStatement = (IfStatementSyntax)elseClause.Parent; 88var ifStatement = (IfStatementSyntax)ifOrElseIf; 92while (ifStatement.Else?.Statement is IfStatementSyntax elseIfStatement) 108var ifStatement = (IfStatementSyntax)ifOrElseIf; 114var ifStatement = (IfStatementSyntax)ifOrElseIf; 120var ifStatement = (IfStatementSyntax)ifOrElseIf; 121var otherIfStatement = (IfStatementSyntax)otherIfOrElseIf; 126=> ((IfStatementSyntax)ifStatement).WithElse(((IfStatementSyntax)otherIfStatement).Else); 132=> ((IfStatementSyntax)ifOrElseIf).WithElse(null); 138var ifStatement = (IfStatementSyntax)currentNode; 139var elseIfStatement = (IfStatementSyntax)elseIfClause; 141var newElseIfStatement = elseIfStatement.WithElse(ifStatement.Else); 142var newIfStatement = ifStatement.WithElse(ElseClause(newElseIfStatement)); 160var parentIfStatement = (IfStatementSyntax)currentNode; 162var elseIfStatement = (IfStatementSyntax)elseClause.Statement; 167private static bool ContainsEmbeddedIfStatement(IfStatementSyntax ifStatement)
SplitOrMergeIfStatements\CSharpMergeConsecutiveIfStatementsCodeRefactoringProvider.cs (2)
29if (node is IfStatementSyntax ifStatement) 46if (node is ElseClauseSyntax elseClause && elseClause.Statement is IfStatementSyntax elseIfStatement)
SplitOrMergeIfStatements\CSharpMergeNestedIfStatementsCodeRefactoringProvider.cs (2)
29if (node is IfStatementSyntax ifStatement) 46if (node is ElseClauseSyntax elseClause && elseClause.Statement is IfStatementSyntax elseIfStatement)
src\Analyzers\CSharp\Analyzers\AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs (11)
126if (statement is IfStatementSyntax ifStatementNode) 200if (statement is IfStatementSyntax ifStatement && ifStatement.Statement == embeddedStatement) 246var outermostIfStatement = GetOutermostIfStatementOfSequence(statement); 256/// Gets the top-most <see cref="IfStatementSyntax"/> for which <paramref name="ifStatementOrElseClause"/> is 265private static IfStatementSyntax GetOutermostIfStatementOfSequence(SyntaxNode ifStatementOrElseClause) 267IfStatementSyntax result; 270result = (IfStatementSyntax)ifStatementOrElseClause.GetRequiredParent(); 275result = (IfStatementSyntax)ifStatementOrElseClause; 279result = (IfStatementSyntax)result.GetRequiredParent().GetRequiredParent(); 288private static bool AnyPartOfIfSequenceUsesBraces(IfStatementSyntax? statement) 300statement = elseStatement as IfStatementSyntax;
src\Analyzers\CSharp\Analyzers\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessAnalyzer.cs (5)
49var ifStatement = (IfStatementSyntax)syntaxContext.Node; 114IfStatementSyntax ifStatement, 167IfStatementSyntax ifStatement, 217IfStatementSyntax ifStatement,
src\Analyzers\CSharp\Analyzers\UseCoalesceExpression\CSharpUseCoalesceExpressionForIfNullStatementCheckDiagnosticAnalyzer.cs (5)
26IfStatementSyntax> 40protected override ExpressionSyntax GetConditionOfIfStatement(IfStatementSyntax ifStatement) 60protected override bool TryGetEmbeddedStatement(IfStatementSyntax ifStatement, [NotNullWhen(true)] out StatementSyntax? whenTrueStatement) 69protected override bool HasElseBlock(IfStatementSyntax ifStatement) 72protected override StatementSyntax? TryGetPreviousStatement(IfStatementSyntax ifStatement)
src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUpdateExpressionSyntaxHelper.cs (2)
35var ifStatement = (IfStatementSyntax)statement;
src\Analyzers\CSharp\Analyzers\UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs (3)
105IfStatementSyntax ifStatement, 125var ifStatement = (IfStatementSyntax)context.Node;
src\Analyzers\CSharp\Analyzers\UseConditionalExpression\CSharpUseConditionalExpressionForAssignmentDiagnosticAnalyzer.cs (1)
15: AbstractUseConditionalExpressionForAssignmentDiagnosticAnalyzer<IfStatementSyntax>
src\Analyzers\CSharp\Analyzers\UseConditionalExpression\CSharpUseConditionalExpressionForReturnDiagnosticAnalyzer.cs (1)
16: AbstractUseConditionalExpressionForReturnDiagnosticAnalyzer<IfStatementSyntax>
src\Analyzers\CSharp\Analyzers\UseNullPropagation\CSharpUseNullPropagationDiagnosticAnalyzer.cs (2)
28IfStatementSyntax, 68IfStatementSyntax ifStatement,
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs (2)
164var ifStatement = (IfStatementSyntax)current;
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpIsAndCastCheckDiagnosticAnalyzer.cs (2)
77out var ifStatement, out var localDeclarationStatement, 164[NotNullWhen(true)] out IfStatementSyntax? ifStatement,
src\Analyzers\CSharp\CodeFixes\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessCodeFixProvider.cs (5)
81var ifStatement = (IfStatementSyntax)root.FindNode(ifStatementLocation.SourceSpan); 128var ifStatement = (IfStatementSyntax)root.FindNode(ifStatementLocation.SourceSpan); 156private static T AppendTriviaWithoutEndOfLines<T>(T newStatement, IfStatementSyntax ifStatement) where T : SyntaxNode
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (2)
504else if (node is IfStatementSyntax ifStatement) 784else if (node is IfStatementSyntax ifStatement)
src\Analyzers\CSharp\CodeFixes\UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs (1)
53if (coalesceOrIfStatement is IfStatementSyntax ifStatement)
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionForAssignmentCodeFixProvider.cs (2)
26StatementSyntax, IfStatementSyntax, LocalDeclarationStatementSyntax, VariableDeclaratorSyntax, ExpressionSyntax, ConditionalExpressionSyntax> 45IfStatementSyntax ifStatement, StatementSyntax statement)
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionForReturnCodeFixProvider.cs (3)
23: AbstractUseConditionalExpressionForReturnCodeFixProvider<StatementSyntax, IfStatementSyntax, ExpressionSyntax, ConditionalExpressionSyntax> 32IfStatementSyntax ifStatement, StatementSyntax statement) 46if (operation.Syntax is IfStatementSyntax { Condition: CheckedExpressionSyntax exp })
src\Analyzers\CSharp\CodeFixes\UseNullPropagation\CSharpUseNullPropagationCodeFixProvider.cs (2)
28IfStatementSyntax, 47protected override SyntaxNode PostProcessElseIf(IfStatementSyntax ifStatement, StatementSyntax newWhenTrueStatement)
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpIsAndCastCheckCodeFixProvider.cs (8)
57var ifStatement = (IfStatementSyntax)ifStatementLocation.FindNode(cancellationToken); 79var currentIf = (IfStatementSyntax)i; 84private static IfStatementSyntax GetUpdatedIfStatement( 87IfStatementSyntax originalIf, 88IfStatementSyntax currentIf) 90var newIf = currentIf.ReplaceNode(currentIf.Condition, updatedCondition);
Structure\Providers\BlockSyntaxStructureProvider.cs (2)
39if (parent is IfStatementSyntax { Parent: not ElseClauseSyntax } ifStatement) 46if (currentElse.Statement is IfStatementSyntax nextIfStatement)
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (25)
IOperation\IOperationTests_IIfStatement.cs (21)
56VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 112VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 159VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 233VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 305VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 361VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 447VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 550VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 603VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 664VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 720VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 768VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 815VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 873VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 949VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 1126VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 1285VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 1344VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 1419VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 1473VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 1541VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics);
IOperation\IOperationTests_InvalidStatement.cs (2)
211VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics); 276VerifyOperationTreeAndDiagnosticsForTest<IfStatementSyntax>(source, expectedOperationTree, expectedDiagnostics);
IOperation\IOperationTests_IUnaryOperatorExpression.cs (2)
2961VerifyOperationTreeForTest<IfStatementSyntax>(source, expectedOperationTree); 3022VerifyOperationTreeForTest<IfStatementSyntax>(source, expectedOperationTree);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (5)
Semantics\BindingTests.cs (2)
4038var ifStmt = tree.GetRoot().DescendantNodes().OfType<IfStatementSyntax>().First();
Semantics\NullableReferenceTypesTests.cs (3)
146454var ifStatement = root.DescendantNodes().OfType<IfStatementSyntax>().Single(); 146458var newIfStatement = ifStatement.ReplaceNode(cast, replaceWith);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (12)
Compilation\GetSemanticInfoTests.cs (2)
974var ifStatement = (IfStatementSyntax)methodDecl.Body.Statements[0];
Compilation\SemanticModelAPITests.cs (4)
4427var ifStatement = root.DescendantNodes().OfType<IfStatementSyntax>().Single(); 4428var replacementIfStatement = (IfStatementSyntax)SyntaxFactory.ParseStatement(replacementSource);
Symbols\Source\NullablePublicAPITests.cs (6)
1361var ifStatement = root.DescendantNodes().OfType<IfStatementSyntax>().Single(); 1513var ifStatement = root.DescendantNodes().OfType<IfStatementSyntax>().Single(); 1569var ifStatement = root.DescendantNodes().OfType<IfStatementSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (25)
Generated\Syntax.Test.xml.Generated.cs (5)
10637private static IfStatementSyntax GenerateIfStatement() 12624var node = GenerateIfStatement(); 12633var newNode = node.WithAttributeLists(node.AttributeLists).WithIfKeyword(node.IfKeyword).WithOpenParenToken(node.OpenParenToken).WithCondition(node.Condition).WithCloseParenToken(node.CloseParenToken).WithStatement(node.Statement).WithElse(node.Else); 17635var oldNode = GenerateIfStatement(); 17651var oldNode = GenerateIfStatement();
Parsing\StatementParsingTests.cs (8)
2022var ss = (IfStatementSyntax)statement; 2045var ss = (IfStatementSyntax)statement; 2071var ss = (IfStatementSyntax)statement; 2085var subIf = (IfStatementSyntax)ss.Else.Statement;
Syntax\SyntaxNodeTests.cs (4)
2126var ifstatement = (IfStatementSyntax)SyntaxFactory.ParseStatement("if (a < b) m(c)"); 2166var ifstatement = (IfStatementSyntax)SyntaxFactory.ParseStatement("if (a < b) m(c)");
Syntax\SyntaxRewriterTests.cs (8)
553var ifStmt1 = (IfStatementSyntax)SyntaxFactory.ParseStatement("if (true)"); 570var ifStmt2 = (IfStatementSyntax)rewriter.Visit(ifStmt1); 601var ifStmt1 = tree1.GetCompilationUnitRoot().DescendantNodes().OfType<IfStatementSyntax>().Single(); 616var ifStmt2 = (IfStatementSyntax)rewriter.Visit(ifStmt1);
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
LocalVariableDeclaratorsCollector.cs (1)
60public override void VisitIfStatement(IfStatementSyntax node)
Microsoft.CodeAnalysis.CSharp.Workspaces (19)
CodeGeneration\CSharpSyntaxGenerator.cs (1)
3133falseArray is [IfStatementSyntax ifStatement] ? ifStatement : CreateBlock(falseArray)));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ParenthesizedExpressionSyntaxExtensions.cs (1)
136(nodeParent is IfStatementSyntax ifStatement && ifStatement.Condition == node) ||
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (3)
121IfStatementSyntax or 136IfStatementSyntax n => n.Statement, 714IfStatementSyntax n => (n.OpenParenToken, n.CloseParenToken),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\FormattingHelpers.cs (2)
291IfStatementSyntax ifStatement => ifStatement.CloseParenToken.Equals(token), 364return node is IfStatementSyntax or
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (2)
291if (node is IfStatementSyntax ifStatement && ifStatement.Statement != null && !(ifStatement.Statement is BlockSyntax)) 299if (elseClause.Statement is not (BlockSyntax or IfStatementSyntax))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (1)
38if (node is IfStatementSyntax ifStatementNode)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\WrappingFormattingRule.cs (2)
130var ifStatementNode = node as IfStatementSyntax;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (1)
107var node = TryGetAncestorForLocation<IfStatementSyntax>(root, position);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (3)
497else if (currentOriginalNode is IfStatementSyntax originalIfStatement) 499var newIfStatement = (IfStatementSyntax)currentReplacedNode;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (3)
162IfStatementSyntax ifStatement => InferTypeInIfStatement(ifStatement), 229IfStatementSyntax ifStatement => InferTypeInIfStatement(ifStatement, token), 1270private IEnumerable<TypeInferenceInfo> InferTypeInIfStatement(IfStatementSyntax ifStatement, SyntaxToken? previousToken = null)
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (6)
CodeGeneration\SyntaxGeneratorTests.cs (6)
559VerifySyntax<IfStatementSyntax>( 563VerifySyntax<IfStatementSyntax>( 567VerifySyntax<IfStatementSyntax>( 572VerifySyntax<IfStatementSyntax>( 578VerifySyntax<IfStatementSyntax>( 584VerifySyntax<IfStatementSyntax>(
Microsoft.DotNet.CodeAnalysis (2)
Analyzers\AppContextDefaultsAnalyzer.cs (2)
80var containingIfStatement = call.Ancestors().FirstOrDefault(n => n.IsKind(SyntaxKind.IfStatement)) as IfStatementSyntax;
System.Private.CoreLib.Generators (1)
IntrinsicsInSystemPrivateCoreLibAnalyzer.cs (1)
584if (ancestorNode is IfStatementSyntax ifStatement)