Many methods in the BCL are marked with the [MethodImpl(MethodImplOptions.InternalCall)]
attribute.
This indicates that the "method is implemented within the common language runtime itself".
What was the point of designing the framework in this way over having specified explicit CIL instructions that the runtime would be forced to implement? Ultimately, the attribute is creating contractual obligations for the runtime, but in a way that appears to me to be confusing and not immediately obvious.
For example, Math.Pow
could have been written this way (excuse my informal mixture of C# + IL and the IL itself if it is bad; this is only a sample to explain my point):
public static double Pow(double x, double y)
{
ldarg.0
ldarg.1
pow // Dedicated CIL instruction
ret
}
instead of the current way:
[MethodImpl(MethodImplOptions.InternalCall)]
public static double Pow(double x, double y);
Why does MethodImplOptions.InternalCall
exist?
InternalCall
methods were there in the first place. Just asking... – Immotile// Dedicated CIL instruction
is a good hint. – Presignify