That should be pretty simple. When you're modifying a constructor method,
just look for the first instruction after which the evaluation stack is
empty. That should be the constructor delegation call.

(Disclaimer: I'm not way an IL expert, so I'm not 100% sure about this, but
I'd try it this way.)

2011/12/23 seesharper <[email protected]>

> Hi!
>
> I have this case where I need to inject code in a constructor AFTER
> the call to the base constructor.
>
> This is modifying an existing type so I do not have control over
> calling the base constructor.
>
> Is there any way I can search through the instructions and detect the
> call to the base constructor.
>
>   L_0000: ldarg.0
>   L_0001: call instance void [mscorlib]System.Object::.ctor()
>  -> Inject code here ........
>
> Is there any generic way I can solve this so I can make sure my code
> is injected after the call to the base constructor?
>
> Regards
>
> Bernhard Richter
>
> --
> --
> mono-cecil

-- 
--
mono-cecil

Reply via email to