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

Consider explicit interface implementations for collection types #71

LordZoltan opened this Issue Feb 11, 2018 · 0 comments


None yet
1 participant

LordZoltan commented Feb 11, 2018

At present, the implementation of GetBindableCollectionTypeInfo(Type) (in Rezolver.Shared/TypeExtensions.cs) only searches public Add methods, which means that it fails to find explicit interface implementations.

So, a type like LinkedList<T>, which doesn't have a public Add method, but which has an explicit implementation of the ICollection<T>.Add method, can't be bound as a collection even though it probably should (and certainly can be in C#).

So, we need to change the method binder so that if a public Add method is not found declared on the type itself, we should descend through its interfaces to see if one can be found there - if so, then we bind to that interface's method instead.

So, in the example of LinkedList<T>, we'd end up binding to the ICollection<T>.Add method (note: not the explicit implementation, but the method from the interface itself).

There is a disabled test in Rezolver.Tests/CollectionTypeTests.cs ready to be re-enabled and code written to make it pass.

@LordZoltan LordZoltan added this to the 1.4 milestone Feb 11, 2018

@LordZoltan LordZoltan self-assigned this Feb 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment