brady gaster

yadnb

Coding Standards? Write a Macro!

So there's this weird standard my new client has implemented. They love to see things like...

//foreach
//for
//if
//else
//Function_Name
//try
//catch

Yeah, it may seem a little anal. Sure. So let's write a macro to do this sort of thing automatically! I've got a regex which goes through the code and locates all of the hanging } symbols. It looks like the following fragment, and we use it pretty extensivly right before code review to make sure our code's all good.

\}$

Thing is, how would one augment that regex or implement a macro to do this sort of thing? Any suggestions? Can't seem to find anything out there to help with this little tidbit!

Comments

denny said:

what the...

Well we could go back to the days when I haxed C with some *VERY* od macros

so I could write basic like stuff

if ( A AND b) THEN
ELSE
ENDIF

where the macros emited text like && and { etc....

for a while I thought it was slick, then I grew up ....
# June 2, 2004 6:42 PM

Jay Nathan said:

I've done it before, but you have to write it in VB.NET. In VS.NET go to Tools -> Macros -> Macors IDE.

There you will find some samples and the code for some of the built in macros in VS.NET. That should get you started!
# June 4, 2004 2:59 PM

TrackBack said:

^_^,Pretty Good!
# April 14, 2005 8:50 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)