I have been looking through the walkthroughs and documentation for Roslyn and there are a lot of examples for things such as IDE-warnings/errors and refactorings, but there appears to be no mention of whether Roslyn can be used as a compilation hook (like byteweaving libraries tend to do, but before we have the generated IL).
For example, I would like to convert:
public void DoSomething(Entity e) {
e.DoSomethingElse();
}
to:
public void DoSomething(Entity e) {
using (e.Acquire()) {
e.DoSomethingElse();
}
}
... But every time the 'before' code is compiled, not as a one-time refactoring.
The meaning of my example is not important, I just wonder if such a thing is possible using Roslyn, and if any examples of such exist?