views:

133

answers:

3

I was looking to write/get a visual studio addin.

I want to be able to write descriptive log calls at the top and bottom of a function.

like this

log.debug("TheClass.TheMethod(string TheStringParam ="+TheStringParam+") - in");

log.debug("TheClass.TheMethod(string TheStringParam ="+TheStringParam+") - out");

Is there an adin that does this? Is there source anywhere for an add in like Ghost Doc that does reflection(or whatever) to parse the parameters and such?

+2  A: 

Sounds like you might want to look into AOP to achieve this. Here's a CodeProject example. Here's a blog post on it. Should be enough to get you started.

RichardOD
I see how Before and after would be a clever way to do this, but what I want is to click on a method in an already existing App, hit a key combo, and it inserts the lines at the top and the bottom of the method.Much like how Ghost Doc adds html comments for a function.
Eric Brown - Cal
PostSharp would be great for this. Take a look at http://www.postsharp.org/ and the "Trace" example. Does exactly what you want with attributes.
Jeremy Roberts
A: 

CodeRush ships with a feature (Selection Embedding) which allows you to select a block of code/text, press a key and have the block wrapped in your choice of code/text.

This text can be calculated at the time of insertion based on the surrounding context if required. Many built it StringProviders (Tokens) are available out of the box, and others can be created fairly easily based on your needs.

For example. The «?MethodName» StringProvider is built in, but some work (not much) would need to be done, in order to create a «?ParameterValues»

The DXCore (The free plugin framework on which CodeRush was built) allows the creation of 3rd party plugins that can run alongside CodeRush or stand alone using just the DXCore. Such a plugin could be created to apply a similar logic to a single method, or all within a file, class, project or solution

Rory Becker