mgravell / fast-member

Automatically exported from code.google.com/p/fast-member
Apache License 2.0
1.02k stars 137 forks source link

Extend meaning/value of allowNonPublicAccessors #70

Closed danielcrenna closed 5 years ago

danielcrenna commented 5 years ago

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".

danielcrenna commented 5 years ago

@mgravell Any comment?

mgravell commented 5 years ago

Sorry, have been tied up with 70 other things. Will try to look as soon as I can.

danielcrenna commented 5 years ago

switched to TypeKitchen