99 references to Else
Microsoft.CodeAnalysis.CSharp (13)
Binder\Binder_Statements.cs (2)
2587if (node.Else == null) 2593var elseStatementSyntax = node.Else.Statement;
Binder\LocalBinderFactory.cs (2)
822if (node.Else == null) 827var elseStatementSyntax = node.Else.Statement;
Syntax.xml.Main.Generated.cs (1)
1915=> node.Update(VisitList(node.AttributeLists), VisitToken(node.IfKeyword), VisitToken(node.OpenParenToken), (ExpressionSyntax?)Visit(node.Condition) ?? throw new ArgumentNullException("condition"), VisitToken(node.CloseParenToken), (StatementSyntax?)Visit(node.Statement) ?? throw new ArgumentNullException("statement"), (ElseClauseSyntax?)Visit(node.Else));
Syntax.xml.Syntax.Generated.cs (7)
8372if (attributeLists != this.AttributeLists || ifKeyword != this.IfKeyword || openParenToken != this.OpenParenToken || condition != this.Condition || closeParenToken != this.CloseParenToken || statement != this.Statement || @else != this.Else) 8383public new IfStatementSyntax WithAttributeLists(SyntaxList<AttributeListSyntax> attributeLists) => Update(attributeLists, this.IfKeyword, this.OpenParenToken, this.Condition, this.CloseParenToken, this.Statement, this.Else); 8384public IfStatementSyntax WithIfKeyword(SyntaxToken ifKeyword) => Update(this.AttributeLists, ifKeyword, this.OpenParenToken, this.Condition, this.CloseParenToken, this.Statement, this.Else); 8385public IfStatementSyntax WithOpenParenToken(SyntaxToken openParenToken) => Update(this.AttributeLists, this.IfKeyword, openParenToken, this.Condition, this.CloseParenToken, this.Statement, this.Else); 8386public IfStatementSyntax WithCondition(ExpressionSyntax condition) => Update(this.AttributeLists, this.IfKeyword, this.OpenParenToken, condition, this.CloseParenToken, this.Statement, this.Else); 8387public IfStatementSyntax WithCloseParenToken(SyntaxToken closeParenToken) => Update(this.AttributeLists, this.IfKeyword, this.OpenParenToken, this.Condition, closeParenToken, this.Statement, this.Else); 8388public IfStatementSyntax WithStatement(StatementSyntax statement) => Update(this.AttributeLists, this.IfKeyword, this.OpenParenToken, this.Condition, this.CloseParenToken, statement, this.Else);
Syntax\LookupPosition.cs (1)
457ElseClauseSyntax? elseOpt = ifStmt.Else;
Microsoft.CodeAnalysis.CSharp.CodeStyle (15)
src\Analyzers\CSharp\Analyzers\AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs (2)
127var elseNode = ifStatementNode.Else; 295var elseStatement = statement.Else?.Statement;
src\Analyzers\CSharp\Analyzers\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessAnalyzer.cs (1)
61if (ifStatement.Else != null)
src\Analyzers\CSharp\Analyzers\UseCoalesceExpression\CSharpUseCoalesceExpressionForIfNullStatementCheckDiagnosticAnalyzer.cs (1)
68=> ifStatement.Else != null;
src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUpdateExpressionSyntaxHelper.cs (2)
38whenFalseStatements = ifStatement.Else != null ? ExtractEmbeddedStatements(ifStatement.Else.Statement) : null;
src\Analyzers\CSharp\Analyzers\UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs (1)
128if (ifStatement.Else != null)
src\Analyzers\CSharp\Analyzers\UseNullPropagation\CSharpUseNullPropagationDiagnosticAnalyzer.cs (1)
96if (ifStatement.Else == null)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs (1)
176? ifStatement.Else?.Statement
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (3)
42if (ifStatementNode.Else != null) 44AddSuppressWrappingIfOnSingleLineOperation(list, ifStatementNode.Else.ElseKeyword, ifStatementNode.Else.Statement.GetLastToken(includeZeroWidth: true));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\WrappingFormattingRule.cs (3)
127if (ifStatementNode?.Else != null) 129RemoveSuppressOperation(list, ifStatementNode.Else.ElseKeyword, ifStatementNode.Else.Statement.GetFirstToken(includeZeroWidth: true));
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (7)
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (4)
505if (ifStatement.Else is null) 518var falseStatement = (ExpressionStatementSyntax)UnwrapEmbeddedStatement(ifStatement.Else.Statement); 784if (ifStatement.Else != null) 785yield return UnwrapEmbeddedStatement(ifStatement.Else.Statement);
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionHelpers.cs (3)
33if (ifStatement.Else is null || !ifStatement.Else.ElseKeyword.LeadingTrivia.Any(t => t.IsSingleOrMultiLineComment())) 37.WithColonToken(ColonToken.WithPrependedLeadingTrivia(ifStatement.Else.ElseKeyword.LeadingTrivia))
Microsoft.CodeAnalysis.CSharp.EditorFeatures (1)
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (1)
246if (ifStatementNode.Else == null && ifStatementNode.Parent is BlockSyntax)
Microsoft.CodeAnalysis.CSharp.Features (38)
ConvertLinq\ConvertForEachToLinqQuery\CSharpConvertForEachToLinqQueryProvider.cs (1)
112if (ifStatement.Else == null)
Debugging\CSharpProximityExpressionsService.Worker.cs (2)
261if (ifStatement.Else != null) 263AddLastStatementOfConstruct(ifStatement.Else.Statement);
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs (1)
175.WithElse(VisitNode(node.Else));
Highlighting\KeywordHighlighters\IfStatementHighlighter.cs (3)
46while (ifStatement != null && ifStatement.Else != null) 49var elseKeyword = ifStatement.Else.ElseKeyword; 51if (ifStatement.Else.Statement is IfStatementSyntax elseIfStatement)
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (4)
34=> ifNode.Else == null; 64=> ifNode.Else?.Statement ?? throw new InvalidOperationException(); 160var elseClause = updatedIf.Else != null 161? updatedIf.Else.WithStatement(falseStatementOpt)
SplitOrMergeIfStatements\CSharpIfLikeStatementGenerator.cs (9)
58if (ifStatement.Else?.Statement is IfStatementSyntax elseIfStatement) 92while (ifStatement.Else?.Statement is IfStatementSyntax elseIfStatement) 98if (ifStatement.Else != null) 100builder.Add(ifStatement.Else); 126=> ((IfStatementSyntax)ifStatement).WithElse(((IfStatementSyntax)otherIfStatement).Else); 141var newElseIfStatement = elseIfStatement.WithElse(ifStatement.Else); 144if (ifStatement.Else == null && ContainsEmbeddedIfStatement(ifStatement)) 161var elseClause = parentIfStatement.Else; 163return parentIfStatement.WithElse(elseIfStatement.Else);
src\Analyzers\CSharp\Analyzers\AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs (2)
127var elseNode = ifStatementNode.Else; 295var elseStatement = statement.Else?.Statement;
src\Analyzers\CSharp\Analyzers\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessAnalyzer.cs (1)
61if (ifStatement.Else != null)
src\Analyzers\CSharp\Analyzers\UseCoalesceExpression\CSharpUseCoalesceExpressionForIfNullStatementCheckDiagnosticAnalyzer.cs (1)
68=> ifStatement.Else != null;
src\Analyzers\CSharp\Analyzers\UseCollectionInitializer\CSharpUpdateExpressionSyntaxHelper.cs (2)
38whenFalseStatements = ifStatement.Else != null ? ExtractEmbeddedStatements(ifStatement.Else.Statement) : null;
src\Analyzers\CSharp\Analyzers\UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs (1)
128if (ifStatement.Else != null)
src\Analyzers\CSharp\Analyzers\UseNullPropagation\CSharpUseNullPropagationDiagnosticAnalyzer.cs (1)
96if (ifStatement.Else == null)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.Analyzer.cs (1)
176? ifStatement.Else?.Statement
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (4)
505if (ifStatement.Else is null) 518var falseStatement = (ExpressionStatementSyntax)UnwrapEmbeddedStatement(ifStatement.Else.Statement); 784if (ifStatement.Else != null) 785yield return UnwrapEmbeddedStatement(ifStatement.Else.Statement);
src\Analyzers\CSharp\CodeFixes\UseConditionalExpression\CSharpUseConditionalExpressionHelpers.cs (3)
33if (ifStatement.Else is null || !ifStatement.Else.ElseKeyword.LeadingTrivia.Any(t => t.IsSingleOrMultiLineComment())) 37.WithColonToken(ColonToken.WithPrependedLeadingTrivia(ifStatement.Else.ElseKeyword.LeadingTrivia))
Structure\Providers\BlockSyntaxStructureProvider.cs (2)
44for (var currentElse = ifStatement.Else; currentElse != null;) 50currentElse = nextIfStatement.Else;
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (12)
Generated\Syntax.Test.xml.Generated.cs (2)
12775Assert.Null(node.Else); 12776var newNode = node.WithAttributeLists(node.AttributeLists).WithIfKeyword(node.IfKeyword).WithOpenParenToken(node.OpenParenToken).WithCondition(node.Condition).WithCloseParenToken(node.CloseParenToken).WithStatement(node.Statement).WithElse(node.Else);
Parsing\StatementParsingTests.cs (10)
2031Assert.Null(ss.Else); 2054Assert.NotNull(ss.Else); 2055Assert.NotEqual(default, ss.Else.ElseKeyword); 2056Assert.Equal(SyntaxKind.ElseKeyword, ss.Else.ElseKeyword.Kind()); 2057Assert.NotNull(ss.Else.Statement); 2080Assert.NotNull(ss.Else); 2081Assert.NotEqual(default, ss.Else.ElseKeyword); 2082Assert.Equal(SyntaxKind.ElseKeyword, ss.Else.ElseKeyword.Kind()); 2083Assert.NotNull(ss.Else.Statement); 2085var subIf = (IfStatementSyntax)ss.Else.Statement;
Microsoft.CodeAnalysis.CSharp.Workspaces (6)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (3)
42if (ifStatementNode.Else != null) 44AddSuppressWrappingIfOnSingleLineOperation(list, ifStatementNode.Else.ElseKeyword, ifStatementNode.Else.Statement.GetLastToken(includeZeroWidth: true));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\WrappingFormattingRule.cs (3)
127if (ifStatementNode?.Else != null) 129RemoveSuppressOperation(list, ifStatementNode.Else.ElseKeyword, ifStatementNode.Else.Statement.GetFirstToken(includeZeroWidth: true));
Roslyn.Diagnostics.CSharp.Analyzers (6)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\SuppressFormattingRule.cs (3)
42if (ifStatementNode.Else != null) 44AddSuppressWrappingIfOnSingleLineOperation(list, ifStatementNode.Else.ElseKeyword, ifStatementNode.Else.Statement.GetLastToken(includeZeroWidth: true));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\WrappingFormattingRule.cs (3)
127if (ifStatementNode?.Else != null) 129RemoveSuppressOperation(list, ifStatementNode.Else.ElseKeyword, ifStatementNode.Else.Statement.GetFirstToken(includeZeroWidth: true));
System.Private.CoreLib.Generators (1)
IntrinsicsInSystemPrivateCoreLibAnalyzer.cs (1)
586if (HandleConditionalCase(ifStatement.Condition, ifStatement.Statement, ifStatement.Else))