Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • I think a c++/cli solution would require all the c++ projects using the enum to be compiled as c++/cli projects. I would tend to agree that 2 separate enums would be simpler, just make sure to clearly document that changes need to be replicated somewhere else. But I would question why you have so many enums, and if there are other alternatives to consider. Commented Dec 14, 2021 at 9:35
  • Seems like the proposed solution is to some degree based on my former answer on Stackoverflow here. Commented Dec 14, 2021 at 11:50
  • Seems kind of a lot of effort. Your unit/integration tests should cover off having 2 files to maintain. Your inline comments should refer to the other copy to inform developers there are 2 copies. Worst case have a C# step use reflection to code-generate the C++ .h file. Commented Dec 14, 2021 at 22:14
  • Not sure if this rises to the level of an answer or not. But instead of horrendous #if statements, why don't you have a simple source of truth in a simple, single text file and then use a transformation process in the build stream of each application that converts the text to a native source code file for that particular application? EG for C# the T4 system. Not sure of the equivalent for c++ though Commented Dec 15, 2021 at 2:07
  • @JonasH: a C++/CLI program could provide elegant mapping code between a native and a managed enum, still one has to deal with those two enums. Commented Dec 15, 2021 at 13:24