Dynamically replace the contents of a C# method?
What I want to do is change how a C# method executes when it is called, so that I can write something like this: [Distributed] public DTask<bool> Solve(int n, DEvent<bool> callback) { for (int m = 2; m < n - 1; m += 1) if (m % n == 0) return false; return true; } At run-time, I need to be able to analyse methods that have the Distributed attribute (which I already can do) and then insert code before the body of the function executes and after the function returns. More importantly, I need to be able to do it without modifying code where Solve is called or at the start of the function (at