jeudi 28 juillet 2016

Unable to find private void generic function with GetMethod

I have a function with the following signature:

private void Foo<TPoco>(IContext context, List<TPoco> pocos, DateTime modifiedDateTime)
    where TPoco : MyAbstractClass

And I cannot find this function in GetMethods().

Based on this SO post ( GetMethod for generic method ), I have tried these binding flags:

GetType().GetMethods(BindingFlags.Public 
    | BindingFlags.NonPublic 
    | BindingFlags.Instance 
    | BindingFlags.Static 
    | BindingFlags.FlattenHierarchy
)

And this finds 14 other methods in the class, but not this one. It does find this method:

protected void Bar<TContext, TPoco>(List<TPoco> pocosToPersist, TContext context)
    where TContext : IContext, new()
    where TPoco : MyAbstractClass

So the only difference is the access level - but then I can see other private functions.

Even if I change the binding flags to something simpler (which, from what I understand, shouldn't make new items visible):

GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance )

I still don't see the function.





Aucun commentaire:

Enregistrer un commentaire