Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5428aab

Browse files
authored
Fix analyzer RCS1182 (#1502)
1 parent cbf64f8 commit 5428aab

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Fix analyzer [RCS1182](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1182) ([PR](https://github.com/dotnet/roslynator/pull/1502))
13+
1014
## [4.12.4] - 2024-06-01
1115

1216
### Fixed

src/Analyzers/CSharp/Analysis/RemoveRedundantBaseInterfaceAnalyzer.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ private static void AnalyzeBaseList(SyntaxNodeAnalysisContext context)
6363

6464
var isFirst = true;
6565
INamedTypeSymbol typeSymbol = null;
66-
SymbolInterfaceInfo baseClassInfo = default;
6766
List<SymbolInterfaceInfo> baseInterfaceInfos = null;
6867

6968
foreach (BaseTypeSyntax baseType in baseTypes)
@@ -78,14 +77,9 @@ private static void AnalyzeBaseList(SyntaxNodeAnalysisContext context)
7877
ImmutableArray<INamedTypeSymbol> allInterfaces = baseSymbol.AllInterfaces;
7978

8079
if (typeKind == TypeKind.Class)
81-
{
82-
if (!isFirst)
83-
break;
80+
return;
8481

85-
if (allInterfaces.Any())
86-
baseClassInfo = new SymbolInterfaceInfo(baseType, baseSymbol, allInterfaces);
87-
}
88-
else if (typeKind == TypeKind.Interface)
82+
if (typeKind == TypeKind.Interface)
8983
{
9084
var baseInterfaceInfo = new SymbolInterfaceInfo(baseType, baseSymbol, allInterfaces);
9185

@@ -102,14 +96,6 @@ private static void AnalyzeBaseList(SyntaxNodeAnalysisContext context)
10296
Analyze(baseInterfaceInfo2, baseInterfaceInfo);
10397
}
10498
}
105-
106-
if (baseClassInfo.Symbol is not null)
107-
{
108-
if (typeSymbol is null)
109-
typeSymbol = context.SemanticModel.GetDeclaredSymbol((TypeDeclarationSyntax)baseList.Parent, context.CancellationToken);
110-
111-
Analyze(baseInterfaceInfo, baseClassInfo);
112-
}
11399
}
114100
}
115101

src/Tests/Analyzers.Tests/RCS1182RemoveRedundantBaseInterfaceTests.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,10 @@ public class RCS1182RemoveRedundantBaseInterfaceTests : AbstractCSharpDiagnostic
1515
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.RemoveRedundantBaseInterface)]
1616
public async Task Test_IEnumerableOfT()
1717
{
18-
await VerifyDiagnosticAndFixAsync(@"
19-
using System.Collections.Generic;
20-
21-
class Foo1<T> : List<T>, [|IEnumerable<T>|] where T : class
22-
{
23-
}
24-
", @"
18+
await VerifyNoDiagnosticAsync(@"
2519
using System.Collections.Generic;
2620
27-
class Foo1<T> : List<T> where T : class
21+
class Foo1<T> : List<T>, IEnumerable<T> where T : class
2822
{
2923
}
3024
");

0 commit comments

Comments
 (0)