This is a mirror of official site: http://jasper-net.blogspot.com/

Add document header for files automatically in Visual Studio

| Monday, December 13, 2010
In this blog post I am going to share  how you can add a document header of xml comments with code file automatically. This is going to be an very interesting and helpful for all of you who are using styleCop to maintain coding standard. Actually extensive using of StyleCop helped me to think to make it automate. There are many tools available which can helps us in this case to do this automatically. But I always prefer let’s Visual studio do the job for me.  Here I am going to share with  you two different approaches to deal with this issue. Now it’s up to you which one to use.


Problem :  StyleCop warning due to file header missing or mismatch for any “.cs” file.
Warning Message : “The file has no header,the header xml is invalid or the header is not located at the top of the file.”
Error No : SA1633


What I used to do?
I used to follow a dumb approach  to save my bit of time. I save the template text in toolbox. And for each file, drag and drop the content from tool box and change the file name.

image_thumb15.png?w=541&h=101

Two Different approaches  to automatically add document header. Well, we have two different approaches to automate this stuff.

1. Using Templates
2. Using Macro

1. Using Templates :
we can rewrite the Visual Studio code templates to customize the templates as per requirements. below is the default template for visual studio classes.

Read more: Abhijit's World of .NET

Posted via email from .NET Info

0 comments: