Note that there are some explanatory texts on larger screens.

plurals
  1. POC# internal static extern with InternalCall attribute - internal or external?
    primarykey
    data
    text
    <p>In <a href="https://stackoverflow.com/questions/1200602/why-is-there-no-managed-md5-implementation-in-the-net-framework">another question</a> I asked, a comment arose indicating that the .NET framework's <code>Array.Copy</code> method uses unmanaged code. I went digging with <a href="http://www.red-gate.com/products/reflector/" rel="nofollow noreferrer">Reflector</a> and found the signature one of the <code>Array.Copy</code> method overloads is defined as so:</p> <pre><code>[MethodImpl(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.MayCorruptInstance, Cer.MayFail)] internal static extern void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable); </code></pre> <p>After looking at this, I'm slightly confused. The source of my confusion is the <code>extern</code> modifier which means (<a href="http://msdn.microsoft.com/en-us/library/e59b22c5.aspx" rel="nofollow noreferrer">MSDN</a> link):</p> <blockquote> <p>The extern modifier is used to declare a method that is implemented externally.</p> </blockquote> <p>However, the method declaration is also decorated with a <code>MethodImplOptions.InternalCall</code> attribute, which indicates (<a href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions.aspx" rel="nofollow noreferrer">MSDN</a> link):</p> <blockquote> <p>Specifies an internal call. An internal call is a call to a method that is implemented within the common language runtime itself.</p> </blockquote> <p>Can anyone explain this seemingly apparent contradiction?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload