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.
Anton Tykhyy is right. Type analysis is what you need; searching through IL is not going to help you. I recommend the reading of the following articles to decide if you're doing it right.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With