I have the following (simplified) scenario.
There is a WCF service (MyService), which exposes some entity MyEntityDTO. On the client side, I have created an interface IMyServiceClient which is being passed to my client-side components, so they can request MyEntityDTOs from any underlying implementation. And also now I can run client-side unit tests using some MockedMyServiceClient : IMyServiceClient. Seems good so far.
Now I have created an actual MyRealWCFServiceClient : IMyServiceClient, which essentially just wraps around the WCF service reference created by Visual Studio.
One issue is that WCF service reference returns a completely another kind of MyEntityDTO, so I have to map it from the service reference entity type to MyEntityDTO type which is returned from IMyServiceClient. I can use AutoMapper for this.
But here comes the biggest issue. Let's say, I want to reuse my MyRealWCFServiceClient in some other applications in my project. If each of these applications will have it's own WCF service reference with it's own DTO types, I'll have to somehow pass all the DTO types of the current service reference and configure AutoMapper with some tricky Reflection to inject my Generic types into it. What a mess...
But I could collect my common WCF references with their wrapping MyRealWCFServiceClients in some common library, so all MyRealWCFServiceClients use only those known common WCF references.
I wonder, is it a good practice to create a common library for service references? Is there a better solution for this?