I'm working on a large API project that needs to release 2 DLLs with many interfaces written in C++/CLI (one DLL contains interfaces for public use and the other extends some of the public interfaces for internal company use only).
All implementation classes for all interfaces are in a separate project and are all contained in a separate DLL as well.
Most internal interfaces usually just extend the public version by one by 1 or 2 methods, I opted to reuse the same implementation classes for code reuse.
Here's an example:
//Company.PublicInterfaces.dll
namespace Company
{
namespace PublicInterfaces
{
//contains public properties, methods, etc that any developer can use
public interface class ICompanyProduct
{
void GetProductInfo();
//...etc
}
public interface class IOtherStuff
{
void GetOtherStuff();
}
//...plus many more interface definitions
}
}
//Company.InternalInterfaces.dll
namespace Company
{
namespace InternalInterfaces
{
//extends the public interface to include secret methods that only company developers can use
public interface class ICompanyProductInternal : ICompanyProduct
{
void GetSecretInfo();
//...etc
}
//...plus many more interface definitions
}
}
//Company.InterfaceImplementations.dll
#include "Company.InternalInterfaces.h"
namespace Company
{
namespace InterfaceImplementations
{
public ref class CompanyProductImplementer : ICompanyProduct, ICompanyProductInternal
{
//implements both interfaces
}
public ref class OtherStuffImplementer : IOtherStuff
{
//implement other stuff
}
//...plus many more interface implementations
}
}
//C# Test App
using Company.InternalInterfaces
using Company.PublicInterfaces
using Company.InterfaceImplementations
namespace TestApp
{
class TestAppProgram
{
static void Main()
{
//write code that uses both interfaces for reusability or for whatever reason....
ICompanyProductInternal internalProduct = new CompanyProductImplementer();
IOtherStuff otherStuff = new OtherStuffImplementer();
}
}
}
The Company.InternalInterfaces project references the Company.PublicInterfaces project.
Since we can't ship Company.InternalInterfaces.dll, the Company.InterfacesImplementation project can only reference Company.PublicInterfaces or we risk exposing the internal interfaces.
But since class CompanyProductImplementer also implements ICompanyProductInternal, I had to include "Company.InternaInterfaces.h".
When building the C# test app, Visual Studio 2013 complains of
Error: The type 'Company.InternalInterfacs.ICompanyProduct' exists in both 'Company.InterfacesImplementation.dll' and 'Company.InternalInterfaces.dll'
The only way it works is if the implementation project also references the internal interface project, but that's not possible because I'll have to ship the internal interface library as well.
How can I solve this? Obviously this is a typical scenario with regards to many companies wanting to reuse their code for public and internal use in large projects.