Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #9956 - Add support for private and protected methods in DbFunctions #10040

Closed
wants to merge 1 commit into from

Conversation

pmiddleton
Copy link
Contributor

Resolves #9956

Adds support for private, protected, internal, and protected internal

@pmiddleton pmiddleton changed the title Add support for private and protected methods in DbFunctions Fix #9956 - Add support for private and protected methods in DbFunctions Oct 11, 2017
@smitpatel smitpatel requested a review from anpete October 11, 2017 23:29
@smitpatel smitpatel self-assigned this Oct 11, 2017
while(contextType != typeof(DbContext))
{
var functions = contextType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance
| BindingFlags.Static | BindingFlags.DeclaredOnly)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BindingFlags.DeclaredOnly to search only the methods declared on the Type, not methods that were simply inherited.

I believe this should be different. When working with multi-context scenarios (using different contexts for read/write), user may want to just put method on common base instead of the exact context instance.

Also FlattenHierarchy should be there to find static members from base classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The while loop will walk up the inheritance chain pulling methods until it gets to DbContext.

We need to do this because base class private methods are not returned when methods are pulled from derived types.

FlattenHierarchy is disabled to prevent duplicate static methods from being returned during the inheritance walk.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. didn't realize the loop.

@smitpatel
Copy link
Contributor

@pmiddleton - If you get some time then can you rebase this on latest dev?

@smitpatel
Copy link
Contributor

Merged via 843929d
Thanks for contribution.

@smitpatel smitpatel closed this Oct 19, 2017
@pmiddleton pmiddleton deleted the privateFunc branch October 22, 2017 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants