I was curious about some serialization stuff so I went poking around FormatterServices and found a method called nativeGetUninitializedObject that actually handles the initialization (without calling the custructor) of a given type. This method is decorated with the extern keyword and the following attribute: [MethodImpl(MethodImplOptions.InternalCall), SecurityCritical]
I'm left wondering: where does this method actually exist? What code does the CLR call to get the given type initialized (without calling the constructor)?
This method actually exists in the native portion of the CLR. The
MethodImplOptions.InternalCallsignifies a call which is forwarded to the CLR native code and is implemented there.From MSDN: