Skip to content

Commit 4916574

Browse files
Fix location for diagnostic
1 parent 1ddc8a0 commit 4916574

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

CheckedExceptions.Tests/CheckedExceptionsAnalyzerTests.DeclaredSuperClassDetection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void CallerMethod()
2525
""";
2626

2727
var expected = Verifier.RedundantExceptionDeclarationBySuperType("InvalidOperationException")
28-
.WithSpan(6, 13, 6, 44);
28+
.WithSpan(6, 20, 6, 43);
2929

3030
await Verifier.VerifyAnalyzerAsync(test, expected);
3131
}

CheckedExceptions/CheckedExceptionsAnalyzer.DeclaredSuperClassDetection.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ private void CheckForRedundantThrowsDeclarationsHandledByDeclaredSuperClass(
1414
ImmutableArray<AttributeData> throwsAttributes)
1515
{
1616
var declaredTypes = new HashSet<INamedTypeSymbol>(SymbolEqualityComparer.Default);
17-
var typeToArgMap = new Dictionary<INamedTypeSymbol, ExpressionSyntax>(SymbolEqualityComparer.Default);
17+
var typeToArgMap = new Dictionary<INamedTypeSymbol, TypeOfExpressionSyntax>(SymbolEqualityComparer.Default);
1818

1919
foreach (var attrData in throwsAttributes)
2020
{
@@ -52,7 +52,7 @@ private void CheckForRedundantThrowsDeclarationsHandledByDeclaredSuperClass(
5252
{
5353
context.ReportDiagnostic(Diagnostic.Create(
5454
RuleDuplicateThrowsByHierarchy,
55-
expression.GetLocation(), // ✅ precise location
55+
expression.Type.GetLocation(), // ✅ precise location
5656
otherType.Name));
5757
}
5858
break;
@@ -79,7 +79,7 @@ private void CheckForRedundantThrowsHandledByDeclaredSuperClass(
7979
{
8080
var semanticModel = context.SemanticModel;
8181
var declaredTypes = new HashSet<INamedTypeSymbol>(SymbolEqualityComparer.Default);
82-
var typeToExprMap = new Dictionary<INamedTypeSymbol, ExpressionSyntax>(SymbolEqualityComparer.Default);
82+
var typeToExprMap = new Dictionary<INamedTypeSymbol, TypeOfExpressionSyntax>(SymbolEqualityComparer.Default);
8383

8484
foreach (var throwsAttribute in throwsAttributes)
8585
{
@@ -112,7 +112,7 @@ private void CheckForRedundantThrowsHandledByDeclaredSuperClass(
112112
{
113113
context.ReportDiagnostic(Diagnostic.Create(
114114
RuleDuplicateThrowsByHierarchy,
115-
expr.GetLocation(),
115+
expr.Type.GetLocation(),
116116
otherType.Name));
117117
}
118118
break;

0 commit comments

Comments
 (0)