How does it work? Does it have distinct parts - some methods are managed, some are unmanaged, does it convert every method to managed, trying to keep everything managed and doing the interop calls when he must?
There are three different compiler switches related to managed code generation in C++/CLI:
/clr:pure
makes the compiler produce MSIL code. No unmanaged functions are allowed (everything is compiled to MSIL). This mode is similar to unsafe
C# code. In this mode, you can use the CRT there's a pure MSIL version of it available. Assemblies compiled in this mode cannot be used in partial trust environments that require verifiable code (e.g. some SQL Server hosted assemblies).
/clr:safe
makes the compiler produce verifiable MSIL code, similar to the C# compiler. No C++ interop is allowed. You can run /clr:safe
assemblies in partial trust environments where verifiability is enforced by security policy.
/clr
generates mixed assemblies. The binary will contain both MSIL code and native code. They are not mixed together in say, a single class. Managed and unmanaged parts are separate and the compiler will generate code to interop and marshal data between two parts as necessary.
To directly answer your question, no specific "conversion" is performed. Unmanaged code is simply not allowed in pure
and safe
modes. Where it's allowed, managed stuff are compiled down to MSIL and unmanaged stuff are compiled to machine code. Any interop between them requires the compiler to generate code. There's no magic there. It just hides some interop stuff from the programmer but the code is there nonetheless.