diff --git a/src/EditorFeatures/Core/InheritanceMargin/AbstractInheritanceMarginService.cs b/src/EditorFeatures/Core/InheritanceMargin/AbstractInheritanceMarginService.cs
index cd522588ef52f..b48d1535a71f8 100644
--- a/src/EditorFeatures/Core/InheritanceMargin/AbstractInheritanceMarginService.cs
+++ b/src/EditorFeatures/Core/InheritanceMargin/AbstractInheritanceMarginService.cs
@@ -92,8 +92,8 @@ private static bool CanHaveInheritanceTarget(ISymbol symbol)
return false;
}
- if (symbol is INamedTypeSymbol or IEventSymbol or IPropertySymbol ||
- symbol.IsOrdinaryMethod())
+ if (symbol is INamedTypeSymbol or IEventSymbol or IPropertySymbol
+ or IMethodSymbol { MethodKind: MethodKind.Ordinary or MethodKind.ExplicitInterfaceImplementation })
{
return true;
}
diff --git a/src/EditorFeatures/Test/InheritanceMargin/InheritanceMarginTests.cs b/src/EditorFeatures/Test/InheritanceMargin/InheritanceMarginTests.cs
index 7f1c087caf2ba..5dd0a86442d4c 100644
--- a/src/EditorFeatures/Test/InheritanceMargin/InheritanceMarginTests.cs
+++ b/src/EditorFeatures/Test/InheritanceMargin/InheritanceMarginTests.cs
@@ -4,7 +4,6 @@
using System.Collections.Immutable;
using System.Linq;
-using System.Security;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
@@ -33,6 +32,9 @@ private static Task VerifyInSingleDocumentAsync(
string languageName,
params TestInheritanceMemberItem[] memberItems)
{
+ markup = @$"";
+
var workspaceFile = $@"
@@ -138,12 +140,14 @@ private static async Task VerifyInDifferentProjectsAsync(
Assembly2
- {markup1.markupInProject1}
+
- {markup2.markupInProject2}
+
";
@@ -933,18 +937,16 @@ public class {|target5:Bar2|} : Bar1, IBar
[Fact]
public Task TestCSharpFindGenericsBaseType()
{
- var lessThanToken = SecurityElement.Escape("<");
- var greaterThanToken = SecurityElement.Escape(">");
- var markup = $@"
-public interface {{|target2:IBar|}}{lessThanToken}T{greaterThanToken}
-{{
- void {{|target4:Foo|}}();
-}}
+ var markup = @"
+public interface {|target2:IBar|}
+{
+ void {|target4:Foo|}();
+}
-public class {{|target1:Bar2|}} : IBar{lessThanToken}int{greaterThanToken}, IBar{lessThanToken}string{greaterThanToken}
-{{
- public void {{|target3:Foo|}}();
-}}";
+public class {|target1:Bar2|} : IBar, IBar
+{
+ public void {|target3:Foo|}();
+}";
var itemForIBar = new TestInheritanceMemberItem(
lineNumber: 2,
@@ -989,6 +991,63 @@ public class {{|target1:Bar2|}} : IBar{lessThanToken}int{greaterThanToken}, IBar
itemForFooInBar2);
}
+ [Fact]
+ public Task TestCSharpExplicitInterfaceImplementation()
+ {
+ var markup = @"
+interface {|target2:IBar|}
+{
+ void {|target3:Foo|}(T t);
+}
+
+abstract class {|target1:AbsBar|} : IBar
+{
+ void IBar.{|target4:Foo|}(int t)
+ {
+ throw new System.NotImplementedException();
+ }
+}";
+ var itemForIBar = new TestInheritanceMemberItem(
+ lineNumber: 2,
+ memberName: "interface IBar",
+ targets: ImmutableArray.Create(new TargetInfo(
+ targetSymbolDisplayName: "class AbsBar",
+ locationTag: "target1",
+ relationship: InheritanceRelationship.Implemented)));
+
+ var itemForFooInIBar = new TestInheritanceMemberItem(
+ lineNumber: 4,
+ memberName: "void IBar.Foo(T)",
+ targets: ImmutableArray.Create(new TargetInfo(
+ targetSymbolDisplayName: "void AbsBar.IBar.Foo(int)",
+ locationTag: "target4",
+ relationship: InheritanceRelationship.Implemented)));
+
+ var itemForAbsBar = new TestInheritanceMemberItem(
+ lineNumber: 7,
+ memberName: "class AbsBar",
+ targets: ImmutableArray.Create(new TargetInfo(
+ targetSymbolDisplayName: "interface IBar",
+ locationTag: "target2",
+ relationship: InheritanceRelationship.Implementing)));
+
+ var itemForFooInAbsBar = new TestInheritanceMemberItem(
+ lineNumber: 9,
+ memberName: "void AbsBar.IBar.Foo(int)",
+ targets: ImmutableArray.Create(new TargetInfo(
+ targetSymbolDisplayName: "void IBar.Foo(T)",
+ locationTag: "target3",
+ relationship: InheritanceRelationship.Implementing)));
+
+ return VerifyInSingleDocumentAsync(
+ markup,
+ LanguageNames.CSharp,
+ itemForIBar,
+ itemForFooInIBar,
+ itemForAbsBar,
+ itemForFooInAbsBar);
+ }
+
#endregion
#region TestsForVisualBasic