Thxs Jb !

Having the tools for making this possible is great regardless inner 
complexities


Regards
David


El miércoles, 5 de junio de 2019, 19:01:35 (UTC+2), Jb Evain escribió:
>
> Hi David,
>
> There's no magic bullet I'm afraid. If you're modifying the IL, you need 
> to make sure that all exception blocks are updated to match the new IL.
>
> Jb
>
> On Tue, Jun 4, 2019 at 12:12 PM Molowe <[email protected] <javascript:>> 
> wrote:
>
>> Hi ,
>>
>>
>> I have some issues when instrumenting .NET assemblies. They are related 
>> with the needed to duplicate params when replacing an existing constructor 
>> by a new call to custom static method for custom class. 
>>
>> For instance let´s say that we want to update following code:
>>
>>
>> *StreamWriter sw = new StreamWriter(sourcePath)*
>>
>>
>> By 
>>
>>
>> *StreamWriter sw = new MetaStreamWriter.MyStaticMethod(sourcePath, new 
>> StreamWriter(sourcePath))*
>>
>>
>> *Note*:Signature for MyStaticMethod is 
>> MetaStreamWriter.MyStaticMethod(string, StreamWriter)
>>
>>
>>
>> As this point, I have no issues for importing the 
>> *MetaStreamWriter.MyStaticMethod*, and locale target-instruction at 
>> which to include the parameter duplication:
>>
>>
>> processor.InsertBefore(targetReferenceIntruction, 
>> targetReferenceIntruction);
>>
>> processor.InsertAfter(instruction, aspectInstruction);
>>
>>  
>>
>> The problem is the insertion of new parameter instruction which does not 
>> respect surrounding code-blocks (autogenerated finally block when code is 
>> inside using, else blocks, etc…).
>>
>>
>> In order to be more specific :Let´s suppose that this origin-sentence is 
>> immediately after a using statement [*endfinally*-opCode]
>>
>>
>> *Using (FileInfo fileinfo = new FileInfo(sourcePath))*
>>
>> *{*
>>
>> *// code for using*
>>
>> *}*
>>
>> *StreamWriter sw = new StreamWriter(sourcePath)*
>>
>>
>>
>> Or that origin-sentence is immediately after a [*ret-OpCode*]  something 
>> like
>>
>>
>> *If (null== fileInfo)*
>>
>> *{*
>>
>> *return;*
>>
>> *}*
>>
>>
>> *StreamWriter sw = new StreamWriter(sourcePath)*
>>
>>  
>>
>>
>> Then, when I create the new IL-sentences (*InserAfter, InserBefore*), 
>> the new parameter instruction falls into previous existing blocks which 
>> makes PEVerify to raise very ugly errors. 
>>
>> Is there any alternative way for avoiding these issues
>>
>> Thanks in advance !
>>
>> David
>>
>> -- 
>> -- 
>> --
>> mono-cecil
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "mono-cecil" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/mono-cecil/4be0eed7-f289-4ca7-92e1-4d9c9c1c387a%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/mono-cecil/4be0eed7-f289-4ca7-92e1-4d9c9c1c387a%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mono-cecil/5c723e1e-8265-487d-8b62-b94984a81996%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to