I've got an interface inheritance issue that has been vexing me for some time. It doesn't seem to make any sense, and I can only conclude that I'm missing something fundamental.
Overview
The code below is from part of a fluent interface for our ORM tool. It provides a SQL-like syntax for pulling data from the database. You don't have to completely grok all the interrelations to understand the problem -- the real issue is the EndClause method.
The EndClause Issue
There's a method called EndClause that doesn't show up in one expected spot -- IOrderQueryRoot. As far as I know, it should show up because it inherits from two different interfaces that both have a method called EndClause, but when I consume an object that implements IOrderQueryRoot, EndClause does not pop up in intellisense.
There are some more implementation details below.
First though, if you look at IOrderQueryRoot (which contains EndClause), you can see that it inherits IHasOrderLogicalOperators, and also IHasOrderFields (which also contains EndClause).
Public Interface IHasOrderLogicalOperators
Function [And]() As IHasOrderFields
Function [AndNot]() As IHasOrderFields
Function [Not]() As IHasOrderFields
Function [Or]() As IHasOrderFields
Function [OrNot]() As IHasOrderFields
Function EndClause() As IHasOrderLogicalOperators
End Interface
Public Interface IHasOrderFields
Function OrderID(ByVal value As Int32) as IHasOrderLogicalOperators
Function OrderID() As IHasOrderComparisonOperators
Function PracticeID(ByVal value As Int32) as IHasOrderLogicalOperators
Function PracticeID() As IHasOrderComparisonOperators
'note: I cut about a page of additional order-related fields you don't need to see.
Function BeginClause() As IHasOrderFields
Function EndClause() As IHasOrderLogicalOperators
End Interface
Public Interface IOrderQueryRoot
Inherits IHasOrderFields, IHasOrderLogicalOperators
End Interface
I think the problem must have something to do with the fact that the EndClause method comes into IOrderQueryRoot twice from different places in the inheritance chain. It does need to work that way.
Since you might want to see the place where I actually consume the interfaces, here's the code I'm using:
Public Function EndClause() As IHasOrderLogicalOperators Implements IHasOrderFields.EndClause, IHasOrderLogicalOperators.EndClause
Me.Query.EndClause()
Return New OrderQueryElement(Query)
End Function
At this point, the interface is working fine -- if I were to remove this method, VS would scream that I have to implement both EndClause methods. The problem is one level down, when the "end developer" is trying to actually write code against the interface.
Please let me know if something jumps out at you -- this one has been driving me crazy for a long time!