When debugging #2448 I noticed that the filtering of properties in ApplyBindingFlags has the same problem as filtering of methods in #2448. The documentation says
https://msdn.microsoft.com/en-us/library/kyaxdd3x(v=vs.110).aspx#Remarks
Specify BindingFlags.NonPublic to include non-public properties (that is, private, internal, and protected properties) in the search. Only protected and internal properties on base classes are returned; private properties on base classes are not returned.
But the code only returns private properties for BindingFlags.NonPublic
|
if (pub && !priv) |
|
infos = infos.Where(p => (p.GetMethod != null && p.GetMethod.IsPublic) || (p.SetMethod != null && p.SetMethod.IsPublic)); |
|
if (priv && !pub) |
|
infos = infos.Where(p => (p.GetMethod == null || p.GetMethod.IsPrivate) && (p.SetMethod == null || p.SetMethod.IsPrivate)); |
The solution to this can probably be done similar to #2448 (replacing p.GetMethod.IsPrivate with !p.GetMethod.IsPublic), so the main issue is to write some tests that capture the intended behaviour.
When debugging #2448 I noticed that the filtering of properties in
ApplyBindingFlagshas the same problem as filtering of methods in #2448. The documentation sayshttps://msdn.microsoft.com/en-us/library/kyaxdd3x(v=vs.110).aspx#Remarks
But the code only returns private properties for
BindingFlags.NonPublicnunit/src/NUnitFramework/framework/Compatibility/ReflectionExtensions.cs
Lines 346 to 349 in 6980e95
The solution to this can probably be done similar to #2448 (replacing
p.GetMethod.IsPrivatewith!p.GetMethod.IsPublic), so the main issue is to write some tests that capture the intended behaviour.