I’ve got multiple interfaces. All of them should be inherited and exposed by a single contract interface.
interface A { void X(); }
interface B { void Y(); }
interface C: A, B {} // this is the public contract
How is this possible? I can’t add ServiceContract to A and B because that would lead to multiple endpoints. And I don’t want to new-override every method in C.
You’re are absolutely correct that attributes like
[ServiceContract]and such are not inherited – you need to explicitly set them on any interface that should be a service contract. The same applies to[DataContract]attributes on concrete data classes – those are not inherited, either – if a descendant class of a data contract should itself be a data contract, it needs to be explicitly marked up as much. WCF by default tries to make you be very explicit about your intent (which is a good thing, I would say).Not sure what you gain from composing interfaces like this, but you can most definitely have a service implementation (concrete class) which implements multiple valid WCF service contracts (interfaces) – no problem at all with that setup.