I have a library that consists of three parts. First is native C++, which provides the actual functionality. Second is a C++/CLI wrapper/adaptor for the C++ library, to simplify the C# to C++ transition. Finally I have a C# library, which invokes the C++ library through the C++/CLI adaptor.
Right now there I have two sets of parallel enum definitions, one stored in a .cs file and the other in a .h file. This poses a double problem:
Right now I'm not sure a solution such as this or that would solve both problems. Thoughts?
Just put your #include "Enum.cs"
directive inside an outer namespace to resolve the naming collision.
EDIT: A variation suggested by Brent is to use #define
to substitute one of the namespaces (or even the enum name itself) declared in the .cs file. This also avoids the naming collision, without making the namespace hierarchy deeper.