Attach to W3WP so you never need to open the Attach To Process dialog.
Note that the macro is trying to attach to the first w3wp.exe process that is runs under your credentials. If you call the function again, it will attach to the next w3wp available, as sometimes you might have more than just one.
Of course if it doesn't find a w3wp.exe running under your account, it will attach to the first that it finds.
It also contains an Attach To IE function so you can easily debug javascript and attaching to IE.exe.
Note that calling the function multiple times, will attach to the next available IE.exe process.
For an easier use of these macros I suggest you should map your custom shortcuts - I am using alt+3 and alt+4 for these.
------------------------
How many times have are you looking through some old code and you can't figure out who created that 'weird' thing?
What about when is not your code , isn't hard to look after the fields, methods, properties etc. as they are not in the right order you are used with?
Here is a tool which can help you tracking and arranging the the code.
Have a look on this simple example:

It is weird aligned and it is not commented at all.
Usually there is a certain order every developer respect. For example:
Of course this is just a small example, but on real code it gets very messy.
Well, that's about to be changed.
As you can notice the code is nicely arranged and well commented.Usually there is a certain order every developer respect. For example:
- Fields
- Constructors
- Properties
- Events
- Util methods
- Virtual/Override methods
- Business/Static methods
- Other classes, delegates, structs etc.
Of course this is just a small example, but on real code it gets very messy.
Well, that's about to be changed.
![]() | ![]() |
Now you know when a piece of code was actually created and who to blame on
Features:
- Move code in regions
- Group regions in an useful order
- Author and date-time stamp for source-code tracking
- Automatic xml-doc comment generated for properties i.e. Gets the Name - or - Gets or Sets the Date
- Automatic xml-doc comment generated for event handlers i.e. Handles the Page's Load event
- Automatic xml-doc comment generated for event raisers i.e Raises the Init event
- Automatic xml-doc comment generated for constructors, classes, interfaces, delegates, structs, enums
- The ability to add the comments/author/timestamp without moving all the code in regions
- The ability to arrange the code (move in regions) without commenting it
- The ability to move the code and comment it at the same time
- The ability to comment the code with the currently logged in user (Environment.UserName)
- The ability to comment the code with a customized/predefined username or timestamp
How to install it:
- Download the attached macro version for VS2008
or for VS2010 - Open Visual Studio 2008/2010, and go to Tools->Macros->Macro Explorer (Alt+F8)
- Locate Samples -> Utilities, right click -> Edit
- Copy the code from the downloaded file and paste it right after Public Module Utilities
- Under project exporer right click References and Add Reference to System.Web.dll version 2.0
- Make sure you add on the imports section these lines:
Imports System.Collections
Imports System.Text
Imports System.Text.RegularExpressions - Save the samples (Ctrl+S) and go back in Visual Studio 2008/2010 on Tools->Options->Environment->Keyboard
- On 'Show command containing' type PutInRegionsWithoutCreatedAuthor
- On 'Press shortcut keys' type your favorite shortcut i.e. Ctrl+Alt+\ (Ctrl+Alt+Backshash) and press Assign
- On 'Show command containing' type CommentWholeCode
- Select CommentWholeCode if you like your windows login account name to be used for comments, or CommentWholeCodeSpecific if you want to override with your custom name
To change the specific name locate the CommentWholeCodeSpecific method in the macros editor and fill in your desired name.
- On 'Press shortcut keys' type your favorite shortcut i.e. Ctrl+Alt+/ (Ctrl+Alt+Slash) and press Assign
- Now go to any class file (*.cs) and test the macros by pressing your shortcuts. eg. Ctrl+Alt+/ and Ctrl+Alt+\
Notes
- Sometimes VisualStudio goes crazy and shows up an error. To get around it just open the File Search dialog (Ctrl+F) and do a dummy search and run the macros again. The error should be gone. Monday, 6 July 2009, Laurentiu Macovei: This has been fixed and should work smoothly. Also tested on VS2010 and works.
- This version only works for .cs files located in CSharp (.cs) projects, or files from App_Code folder within a website
- Does not work for stand-alone files (out of solution files)
- Does not work for Visual Basic .vb files - just yet
The comment/put in regions operations can be undone by pressing Undo on your document so your document is safe.

Basically every time when you add a new method, property, etc. you should run the CommentWholeCode macro (Ctrl+Alt+/) so it will be commented with your username. Otherwise, some other developer may 'take' your code under his username, and that's not desired.
If you have any questions, please let me know.
Happy code tracking!
>Now you know when a piece of code was actually created and who to blame on
ReplyDeleteSorry, but doesn't every decent VCS out there support finding out who changed what and when, and in a much finer grained manner than this?
Ya, but you don't always have the code in the same VCS.
ReplyDeleteI use this in parallel with the SVN comments and find it very useful over the years.
Speaking so, it's very hard to see in 1000 revisions who did that particular method.
Works smoothly in VS 2008. Is there any plan to upgrade it to VS 2010 Beta 1 ? I'm installing it right now !
ReplyDeleteThanks.
Yup, just tested it on VS2010 and works smoothly as well ;)
ReplyDeleteJust make sure you open the find dialog first and do some dummy search (the old VS bug still happens on vs2010) so no error "Value does not fall within the the expected range".
Anyways, I have fixed this bug so just make sure you are using the latest version of the macro again.
WHEN WILL IT WORK WITH VB. Still its not working with vb
ReplyDelete