Blittable Vs. Non-Blittable in IL

I'm trying to make sure my managed unmanaged calls are optimized. Is there a quick way to see, looking at the IL, if any unresponsive types accidentally hit my pinvoke calls?

I tried just writing two unmanaged functions in a .dll that uses bool (which is not blittable) and one that uses ints. But I did not see anything else, looking at IL to tell me that he was doing something extra for Marshal bool.

+3
source share
3 answers

There are no marshaling related things in IL. Instead, you should analyze the types of method parameters (with modifiers) and the types of data returned, following the rules described in MSDN . These rules are quite simple, it should be possible to write an automatic check and connect it, for example. FxCop.

+3
source
Anton Tikhiy is right. Type analysis is what you need; searching through the IL will not help you. I recommend reading the following articles to decide if you are doing the right thing.

, .

+3

.

.

"bool" , , "bool" . , MS ++ "bool" , 1 , "BOOL", 4 . , ,.Net bool - 1 , , bool.

+2
source

Source: https://habr.com/ru/post/1737955/


All Articles