Skip to content

Commit 7134965

Browse files
committed
Add option for including explicit interface implementations
1 parent cabaa2f commit 7134965

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

src/Microsoft.DocAsCode.Dotnet/DotnetApiCatalog.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ private static ExtractMetadataConfig ConvertConfig(MetadataJsonItemConfig config
110110
ShouldSkipMarkup = configModel?.ShouldSkipMarkup ?? false,
111111
FilterConfigFile = configModel?.FilterConfigFile is null ? null : Path.GetFullPath(Path.Combine(EnvironmentContext.BaseDirectory, configModel.FilterConfigFile)),
112112
IncludePrivateMembers = configModel?.IncludePrivateMembers ?? false,
113+
IncludeExplicitInterfaceImplementations = configModel?.IncludeExplicitInterfaceImplementations ?? false,
113114
GlobalNamespaceId = configModel?.GlobalNamespaceId,
114115
UseCompatibilityFileName = configModel?.UseCompatibilityFileName ?? false,
115116
MSBuildProperties = configModel?.MSBuildProperties,

src/Microsoft.DocAsCode.Dotnet/ExtractMetadata/ExtractMetadataConfig.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ internal class ExtractMetadataConfig
2121

2222
public bool IncludePrivateMembers { get; init; }
2323

24+
public bool IncludeExplicitInterfaceImplementations { get; init; }
25+
2426
public bool UseCompatibilityFileName { get; init; }
2527

2628
public string GlobalNamespaceId { get; init; }

src/Microsoft.DocAsCode.Dotnet/MetadataJsonItemConfig.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ internal class MetadataJsonItemConfig
3030
[JsonProperty("includePrivateMembers")]
3131
public bool IncludePrivateMembers { get; set; }
3232

33+
[JsonProperty("includeExplicitInterfaceImplementations")]
34+
public bool IncludeExplicitInterfaceImplementations { get; set; }
35+
3336
[JsonProperty("globalNamespaceId")]
3437
public string GlobalNamespaceId { get; set; }
3538

src/Microsoft.DocAsCode.Dotnet/SymbolFilter.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,25 @@ private bool IsSymbolAccessible(ISymbol symbol)
9494
if (symbol.IsImplicitlyDeclared && symbol.Kind is not SymbolKind.Namespace)
9595
return false;
9696

97+
if (_config.IncludeExplicitInterfaceImplementations)
98+
{
99+
bool isEii = symbol.Kind switch
100+
{
101+
SymbolKind.Method => IsEiiAndIncludesContainingSymbols(((IMethodSymbol)symbol).ExplicitInterfaceImplementations),
102+
SymbolKind.Property => IsEiiAndIncludesContainingSymbols(((IPropertySymbol)symbol).ExplicitInterfaceImplementations),
103+
SymbolKind.Event => IsEiiAndIncludesContainingSymbols(((IEventSymbol)symbol).ExplicitInterfaceImplementations),
104+
_ => false,
105+
};
106+
107+
if (isEii)
108+
return true;
109+
}
110+
97111
if (_config.IncludePrivateMembers)
98112
{
113+
if (_config.IncludeExplicitInterfaceImplementations)
114+
return true;
115+
99116
return symbol.Kind switch
100117
{
101118
SymbolKind.Method => IncludesContainingSymbols(((IMethodSymbol)symbol).ExplicitInterfaceImplementations),
@@ -114,6 +131,11 @@ bool IncludesContainingSymbols(IEnumerable<ISymbol> symbols)
114131
{
115132
return !symbols.Any() || symbols.All(s => IncludeApi(s.ContainingSymbol));
116133
}
134+
135+
bool IsEiiAndIncludesContainingSymbols(IEnumerable<ISymbol> symbols)
136+
{
137+
return symbols.Any() && symbols.All(s => IncludeApi(s.ContainingSymbol));
138+
}
117139
}
118140
}
119141
}

0 commit comments

Comments
 (0)