What's the point of MethodImplOptions.InternalCall?

后端 未结 4 1404
醉梦人生
醉梦人生 2020-12-09 02:07

Many methods in the BCL are marked with the [MethodImpl(MethodImplOptions.InternalCall)] attribute. This indicates that the \"method is implemented within the

4条回答
  •  被撕碎了的回忆
    2020-12-09 02:42

    I think a big reason is that it's quite hard to create a new IL instruction and it could affect a lot of tools, including external ones (ILGenerator, ilasm, ildasm, PEVerify, Reflector, PostSharp, …).

    But creating a new InternalCall method? That's almost as simple as writing the method in C# (I assume, I didn't look at Rotor to verify) and it doesn't affect anything.

    And it's not just about creating it, I think the same applies to maintenance.

提交回复
热议问题