Skip to content

Commit c93cc75

Browse files
Hosch250Vannevelj
authored andcommitted
Make SwitchDoesNotHandleAllEnumOptions show lines on the expression. (#531)
* Make SwitchDoesNotHandleAllEnumOptions show lines on the expression. * Fix cast in code fix.
1 parent 137f803 commit c93cc75

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

VSDiagnostics/VSDiagnostics/VSDiagnostics/Diagnostics/General/SwitchDoesNotHandleAllEnumOptions/SwitchDoesNotHandleAllEnumOptionsAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private void AnalyzeSymbol(SyntaxNodeAnalysisContext context)
8282

8383
if (!switchHasSymbol)
8484
{
85-
context.ReportDiagnostic(Diagnostic.Create(Rule, switchBlock.GetLocation()));
85+
context.ReportDiagnostic(Diagnostic.Create(Rule, switchBlock.Expression.GetLocation()));
8686
return;
8787
}
8888
}

VSDiagnostics/VSDiagnostics/VSDiagnostics/Diagnostics/General/SwitchDoesNotHandleAllEnumOptions/SwitchDoesNotHandleAllEnumOptionsCodeFix.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private async Task<Solution> AddMissingCaseAsync(Document document, CompilationU
4040
{
4141
var semanticModel = await document.GetSemanticModelAsync();
4242

43-
var switchBlock = (SwitchStatementSyntax) statement;
43+
var switchBlock = (SwitchStatementSyntax) statement.Parent;
4444

4545
var enumType = (INamedTypeSymbol) semanticModel.GetTypeInfo(switchBlock.Expression).Type;
4646
var caseLabels = switchBlock.Sections.SelectMany(l => l.Labels)

0 commit comments

Comments
 (0)