Reputation: 813
I am building a vspackage for Visual Studio 2010, and need to be able to inject code invisibly into every function in the solution during the build process.
Currently I can use this:
TextDocument doc = (elemInfo.ProjectItem.Document.Object() as TextDocument);
EditPoint ep = doc.CreateEditPoint(elemInfo.StartPoint);
ep.Insert(sb.ToString());
which inserts the code directly into the code file for all to see. This works, but as the code only collects runtime data I never need to see it. Is there a way to inject the code during the build process without publically inserting the code like above?
I could create temporary files for all the code files in the solution, and inject the code into them, then dispose of them after the debug session ends. Would this be the best way?
When intellitrace collects data from the running executable, wouldn't it need to do something similiar to this? I assume it Injects code into each method to save variable states.
Upvotes: 0
Views: 500
Reputation: 4795
PostSharp, http://www.sharpcrafters.com/ Essentially AOP as per @bzlm
Upvotes: 1