Skip to content

Commit a96a3c2

Browse files
committed
Fixup of extraction.
1 parent 1e2405e commit a96a3c2

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

csharp/extractor/Semmle.Extraction.CSharp/CodeAnalysisExtensions/SymbolExtensions.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,23 @@ public static bool IsPublicOrProtected(this ISymbol symbol) =>
652652
/// <summary>
653653
/// Returns true if the given symbol should be extracted in this context.
654654
/// </summary>
655-
public static bool ShouldExtractSymbol(this ISymbol symbol) =>
656-
symbol.Locations.Any(x => !x.IsInMetadata) || symbol.IsPublicOrProtected();
655+
public static bool ShouldExtractSymbol(this ISymbol symbol)
656+
{
657+
// Extract all source symbols and public/protected metadata symbols.
658+
if (symbol.Locations.Any(x => !x.IsInMetadata) || symbol.IsPublicOrProtected())
659+
{
660+
return true;
661+
}
662+
if (symbol is IMethodSymbol method)
663+
{
664+
return method.ExplicitInterfaceImplementations.Any(m => m.ContainingType.DeclaredAccessibility == Accessibility.Public);
665+
}
666+
if (symbol is IPropertySymbol property)
667+
{
668+
return property.ExplicitInterfaceImplementations.Any(m => m.ContainingType.DeclaredAccessibility == Accessibility.Public);
669+
}
670+
return false;
671+
}
657672

658673
/// <summary>
659674
/// Returns the symbols that should be extracted in the given context.

0 commit comments

Comments
 (0)