How to modify code before compilation?
Using Roslyn, I would like to modify my C# code before the actual compilation. For now, I will just need something like: [MyAnotatedMethod] public void MyMethod() { // method-body } And based on the annotation, I would like to inject some code at the beginning of the method, and at the end of the method. I'm aware of PostSharp, but that's not what I would like. Is this possible to do with Roslyn? And if yes, could you give me an example? Here is a quick and dirty way of doing what you want. It's based on one of the above comments, which points to SebbyLive . It is just a proof of concept, I