-
Notifications
You must be signed in to change notification settings - Fork 1k
/
AccessibilitySymbolFilter.cs
43 lines (37 loc) · 1.62 KB
/
AccessibilitySymbolFilter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.CodeAnalysis;
namespace Microsoft.DotNet.ApiSymbolExtensions.Filtering
{
/// <summary>
/// Implements the logic of filtering out symbols based on a provided accessibility level (i.e. public / internal).
/// </summary>
public class AccessibilitySymbolFilter : ISymbolFilter
{
/// <summary>
/// Include internal API.
/// </summary>
public bool IncludeInternalSymbols { get; }
/// <summary>
/// Include effectively private API.
/// </summary>
public bool IncludeEffectivelyPrivateSymbols { get; }
/// <summary>
/// Include explicit interface implementation API.
/// </summary>
public bool IncludeExplicitInterfaceImplementationSymbols { get; }
public AccessibilitySymbolFilter(bool includeInternalSymbols,
bool includeEffectivelyPrivateSymbols = false,
bool includeExplicitInterfaceImplementationSymbols = false)
{
IncludeInternalSymbols = includeInternalSymbols;
IncludeEffectivelyPrivateSymbols = includeEffectivelyPrivateSymbols;
IncludeExplicitInterfaceImplementationSymbols = includeExplicitInterfaceImplementationSymbols;
}
/// <inheritdoc />
public bool Include(ISymbol symbol) =>
symbol.IsVisibleOutsideOfAssembly(IncludeInternalSymbols,
IncludeEffectivelyPrivateSymbols,
IncludeExplicitInterfaceImplementationSymbols);
}
}