Skip to content

Commit 3a0144c

Browse files
Exclude ValueType and Enum implementations (#25)
When `-IncludeObject` is not specified we also do not want to see implementations by `ValueType` or `Enum`. Fixes #24
1 parent cfae566 commit 3a0144c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/ClassExplorer/MemberSearch.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,27 @@ protected override void InitializeFastFilters(List<Filter<MemberInfo>> filters,
214214
if (!_options.IncludeObject)
215215
{
216216
filters.AddFilter(
217-
static (member, _) => member.DeclaringType != typeof(object),
217+
static (member, _) =>
218+
{
219+
// Show members by default if the caller is querying the
220+
// class directly.
221+
Type? reflectedType = member.ReflectedType;
222+
if (reflectedType == typeof(object)
223+
|| reflectedType == typeof(ValueType)
224+
|| reflectedType == typeof(Enum))
225+
{
226+
return true;
227+
}
228+
229+
// Otherwise check the declaring type. This tells us if the
230+
// method is overridden. Also check for ValueType and Enum
231+
// as we typically don't want to see their implementations
232+
// either.
233+
Type? declaringType = member.DeclaringType;
234+
return declaringType != typeof(object)
235+
&& declaringType != typeof(ValueType)
236+
&& declaringType != typeof(Enum);
237+
},
218238
FilterOptions.ExcludeNot);
219239
}
220240
}

0 commit comments

Comments
 (0)