[Mono-dev] Edit and Continue / Function body rewrite

Kornél Pál kornelpal at gmail.com
Fri Jul 7 18:50:54 EDT 2006


If you want to modify existing assemblies you should use Cecil 
(http://www.mono-project.com/Cecil) because it is designed to do this while 
System.Reflection.Emit is designed to emit new code and in fact it have less 
support for metadata creation than C# requires because Microsoft is not 
using it for C# compilation so they didn't reallized that 
System.Reflection.Emit lacks a lot of features.

Kornél

----- Original Message ----- 
From: "David Srbecky" <dsrbecky at gmail.com>
To: <mono-devel-list at lists.ximian.com>
Sent: Saturday, July 08, 2006 12:38 AM
Subject: Re: [Mono-dev] Edit and Continue / Function body rewrite


> Hello,
>
> Here is a longer description of how I want to make the basic Edit and
> Continue work. My questions are at the end.
>
> Microsoft's .NET runtime will run the modifiable application and the IDE
> with debugger (SharpDevelop).
>
> Mono will be used to do the System.Reflection.Emit stuff - compile the
> application for the first time (gmcs) and then to generate the IL code
> updates.
>
> I will need to use some communication between the runtimes - eg network
> connection. Here is how I imagine the communication could work:
>
> 1) MS -> Mono: "Complie program Foo to assembly Foo.exe"
> 2) Mono -> MS: "Compilation successful. 0 errors"
> 3) MS executes Foo.exe
> 4) MS -> Mono: "Change function Main to '{return 1;}'"
> 5) Mono -> MS: "The new IL code is ..........."
> 6) MS applies the the new IL code
>
> I have managed to get 1-3 working without any problems. I have also
> managed to change a running program under MS runtime by handwriting the
> new IL code.
>
> Now I need to patch Mono's System.Reflection.Emit so that I can use it
> to easily produce the new IL code and metadata. (I do not think that I
> can get all I need from Microsoft's System.Reflection.Emit and I want to
> use Mono's System.Reflection.Emit anyway because I am told that gmcs
> likes it more)
>
>
> Right now, I am just investing whether the Edit and Continue is
> possible. If it is, may plan is to:
>
> A) Define 'update' format - probably XML document
>
> B) Modify SharpDevelop so that it can take the update and apply it to
> the running program
>
> C) Make it possible to produce 'updates' with Mono's
> System.Reflection.Emit - the format of data it produces does not matter
> - I just need to be able to collect it and then convert it to the XML
>
> D) Make a simple sample application that uses Mono's
> System.Reflection.Emit to create the XML 'update'
>
> E) Change gmcs so that after whole compilation it can take source code
> for body of a single method and generate 'update' using Mono's
> System.Reflection.Emit
>
> F) Modify SharpDevelop so that it can work with symbols produced by gmcs
>
> I handle A, B, D and F myself. I would really appreciate your help with
> C and E. I had a few long discussions about the gmcs with Marek Safar
> and I hope he could help me with that.
>
>
>
>
> So back to patching System.Reflection.Emit:
>
> If I want to change a function in a running program, what do I need?
> - whole IL code of the new function
> - new TypeRef and MemberRef rows in metadata (if new external functions
> are called)
> - String heap (if new string is used in function)
> - Anything else???
>
> How can I get these from Mono's System.Reflection.Emit? Is there
> actually any patching necessary or can I get these already?
>
>
>
> Thank you very much,
> David Srbecky
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list 




More information about the Mono-devel-list mailing list