This is mostly academic - but I was looking at the implementation of Equals() for ValueTypes. The source code is here: http://referencesource.microsoft.com/#mscorlib/system/valuetype.cs#38
The code that caught my eye was this:
// if there are no GC references in this object we can avoid reflection
// and do a fast memcmp
if (CanCompareBits(this))
return FastEqualsCheck(thisObj, obj);
FastEqualsCheck() is declared as follows:
[System.Security.SecuritySafeCritical]
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern bool FastEqualsCheck(Object a, Object b);
My understanding is that the '[MethodImplAttribute(MethodImplOptions.InternalCall)]' indicates that this is implemented in the CLR (source not available), but I thought I would be able to call it directly from my code. When I try, I get a SecurityException
ECall methods must be packaged into a system module.
Can I make these calls myself (or are they meant for internal consumption only)? If I can call them directly, what is the appropriate way of doing so?