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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mono-cecil/4be0eed7-f289-4ca7-92e1-4d9c9c1c387a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to