Skip to content

Commit

Permalink
Simplify a visibility check
Browse files Browse the repository at this point in the history
- remove redundant bits
  • Loading branch information
dougbu committed Apr 1, 2020
1 parent 509dcba commit 3f3138c
Showing 1 changed file with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,18 @@ public virtual bool Include(ITypeDefinition type)

public virtual bool Include(ITypeDefinitionMember member)
{
// Include based on member visibility (simple cases).
switch (member.Visibility)
// Include internal and private protected members.
if (member.Visibility == TypeMemberVisibility.Family ||
member.Visibility == TypeMemberVisibility.FamilyAndAssembly)
{
case TypeMemberVisibility.Assembly:
case TypeMemberVisibility.FamilyOrAssembly:
case TypeMemberVisibility.Public:
return true;

case TypeMemberVisibility.Family:
case TypeMemberVisibility.FamilyAndAssembly:
// Similar to special case in PublicOnlyCciFilter, include protected members even of a sealed type.
// This is necessary to generate compilable code e.g. a derived type in current assembly may
// override the protected member.
return true;
// Similar to special case in PublicOnlyCciFilter, include protected members even of a sealed type.
// This is necessary to generate compilable code e.g. callers with IVT dependencies on this assembly
// may call internal methods in a sealed type. (IsVisibleToFriendAssemblies() includes the IsSealed
// check for other use cases besides this one.)
return true;
}

// Include explicit interface implementations.
// Include public(-ish) members and explicit interface implementations.
if (member.IsVisibleToFriendAssemblies())
{
return true;
Expand Down

0 comments on commit 3f3138c

Please sign in to comment.