I’m trying to make sure that my Managed to Unmanaged calls are optimized. Is there a quick way to see by looking at the IL if any non-blittable types have accidentally gotten into my pinvoke calls?
I tried just writing two unmanaged functions in a .dll, one that uses bool (which is non-blittable) and one that uses ints. But I didn’t see anything different when looking at the IL to let me know that it was doing something extra to marshal the bool.
There is no marshaling-related stuff in IL. Instead, you should analyze methods’ parameter types (with modifiers) and return types following the rules described in MSDN. These rules are fairly simple, it ought to be possible to write an automated checker and plug it into e.g. FxCop.