Translate C ++ / CLI to C #

I have a small to medium project that is in C ++ / CLI. I really hate the C ++ / CLI syntax extensions, and I would rather work in C #. Is there a tool that does a decent job of translating one to another?

EDIT: When I said "Managed C ++", before I obviously meant C ++ / CLI

+3
source share
5 answers

You can only translate Managed C ++ code (and C ++ / CLI code) to C # if the C ++ code is clean. If this is not the case - if there is embedded code in the source code - tools like .NET Reflector will not be able to translate the code for you.

If you have built-in C ++ code, I recommend trying to move your own code into a separate DLL, replace your calls to DLL functions with easily identifiable stub functions, compile your project as a clean .NET library, then use the .NET reflector to decompile into C # code. You can then replace the calls with stub functions with p-invoke calls to your native DLL.

Good luck I feel for you!

+4
source

.NET Managed C ++ is like a train wreck. But have you looked into the C ++ CLI? I think Microsoft has done an excellent job in this area to make C ++ a first class .NET citizen.

http://msdn.microsoft.com/en-us/magazine/cc163852.aspx

+2
source

I'm not sure if this will work, but try using the .NET Reflector along with the ReflectionEmitLanguage plugin. The approval of the ReleaselectionEmitLanguage plug-in converts your assembly into C # code.

+2
source

Back ~ 2004 Microsoft had a tool that would convert managed C ++ to C ++ / CLI ... sort of. We launched it on several projects, but, frankly, the amount of work left after cleaning the project was no less than the amount of work that he had to do first. I don’t think the tool has ever released it in a public release, though (perhaps for this reason).

I don’t know which version of Visual Studio you are using, but we have created C ++ code that will not be compiled using Visual Studio 2005/2008 with the / clr: oldSyntax switch, and we still have a VS 2003 relic around This.

I don’t know how to switch from C ++ to C # in a useful way ... you could try to round it through a reflector :)

0
source

Such projects are often executed in C ++ / cli, because C # is not a very elegant option for a task. for example, if you need to interact with some native C ++ libraries or do very high-performance things at a low C level. So just make sure that someone who chose C ++ / cli did not have good reason to do this before doing this is.

Having said that, I am very skeptical of something that does what you ask for the simple reason that not all C ++ / cli code can be translated into C # (and probably vice versa).

0
source

Source: https://habr.com/ru/post/1286577/


All Articles