The original concept of allowNonPublicAccessors only considers the accessor's root type access, and not its members' access. However, IsFullyPublic, the method that determines whether the accessor needs to be delegated, considers members.
This means that if you have a public type you want to access, its non-public members are not accessible, even if you explicitly ask for them via allowNonPublicAccessors: true. This is demonstrated in the accompanying unit tests. Now, maybe the field really means that (accessors, not members), but it seems in spirit with what the library is meant to provide, that it would not hide private members. In fact, all of my use cases over the last five years involve wanting to manipulate private members in a non-public accessor.
As a side benefit, in order to avoid calling reflection for properties and fields twice, once when spinning up an accessor, and again when asking for a member set for the first time, we cache the MemberInfo[] collection after doing a safe-ish filter on backing fields. This is a common request: to make reflection info available so that consumers don't have to pay the tax on accessor creation, and then again in their own app for other introspection tasks: just use the cached member info on the accessor itself. This helps library authors centralize "stuff for type access".
The original concept of
allowNonPublicAccessors
only considers the accessor's root type access, and not its members' access. However,IsFullyPublic
, the method that determines whether the accessor needs to be delegated, considers members.This means that if you have a public type you want to access, its non-public members are not accessible, even if you explicitly ask for them via
allowNonPublicAccessors: true
. This is demonstrated in the accompanying unit tests. Now, maybe the field really means that (accessors, not members), but it seems in spirit with what the library is meant to provide, that it would not hide private members. In fact, all of my use cases over the last five years involve wanting to manipulate private members in a non-public accessor.As a side benefit, in order to avoid calling reflection for properties and fields twice, once when spinning up an accessor, and again when asking for a member set for the first time, we cache the
MemberInfo[]
collection after doing a safe-ish filter on backing fields. This is a common request: to make reflection info available so that consumers don't have to pay the tax on accessor creation, and then again in their own app for other introspection tasks: just use the cached member info on the accessor itself. This helps library authors centralize "stuff for type access".