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