Skip to content

Commit 864734c

Browse files
committed
Added eval of annotated-only interface classes
1 parent b1d5661 commit 864734c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Rubberduck.CodeAnalysis/Inspections/Concrete/ImplementedInterfaceMemberInspection.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
using Rubberduck.Parsing.Symbols;
88
using Rubberduck.Inspections.Inspections.Extensions;
99
using Rubberduck.Common;
10+
using System;
1011

1112
namespace Rubberduck.Inspections.Concrete
1213
{
1314
/// <summary>
14-
/// Identifies members of class modules that are used as interfaces, but that have a concrete implementation.
15+
/// Identifies class modules that define an interface with one or more members containing a concrete implementation.
1516
/// </summary>
1617
/// <why>
1718
/// Interfaces provide an abstract, unified programmatic access to different objects; concrete implementations of their members should be in a separate module that 'Implements' the interface.
@@ -43,7 +44,13 @@ public ImplementedInterfaceMemberInspection(Parsing.VBA.RubberduckParserState st
4344

4445
protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
4546
{
46-
return State.DeclarationFinder.FindAllUserInterfaces()
47+
var annotatedAsInterface = State.DeclarationFinder.Classes
48+
.Where(cls => cls.Annotations.Any(an => an.Annotation.Name.Equals("Interface"))).Cast<ClassModuleDeclaration>();
49+
50+
var implementedAndOrAnnotatedInterfaceModules = State.DeclarationFinder.FindAllUserInterfaces()
51+
.Union(annotatedAsInterface);
52+
53+
return implementedAndOrAnnotatedInterfaceModules
4754
.SelectMany(interfaceModule => interfaceModule.Members
4855
.Where(member => ((ModuleBodyElementDeclaration)member).Block.ContainsExecutableStatements(true)
4956
&& !member.IsIgnoringInspectionResultFor(AnnotationName)))

0 commit comments

Comments
 (0)