Where is CopyToNative defined?

I am currently reviewing the decompiled C # IL (using ILSpy) to get an idea of ​​how some of the methods from are System.Runtime.InteropServices

implemented (maybe). When I wanted to check how it is Marshal.Copy()

implemented, I found that it only calls CopyToNative()

, which is defined like this:

// System.Runtime.InteropServices.Marshal
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void CopyToNative(object source, int startIndex, IntPtr destination, int length);

      

Where is it implemented? Is there a way to take a look at its (decompiled) source code? If not, does anyone know how this can be implemented?

+3


source to share


1 answer


Keyword MethodImplAttribute

and extern

indicates that this function is internal to the .NET runtime itself. This feature is almost certainly implemented in C or C ++ in the source code of the runtime.

Without access to the source execution code, your only real option is to parse that particular function and examine the assembly. (Note that this may violate the runtime license agreement.)




You can look at the Mono source code to see one possible implementation.

+6


source







All Articles