views:

103

answers:

3

What is the best way to automatically place copyright notices, disclaimers, etc. in all of our C# files? Yes, we could copy & paste but is there a more automatic way? Any macros that would place them?

Edit: This is for all new files only. We are not concerned about existing stuff as they will be updated as necessary on a case by case basis.

+1  A: 

If you use Visual Studio, check out Visual Assist X. You can also comment stubs and similar things with VA X. It's easily worth the cost of its license in time saved.

Edit: Looking back at the original question, I'm not sure you can use VA X to go back and add headings to existing files. You can (probably?) write a script to insert that at the beginning of text files existing in a directory, but I'm not very well-versed in scripting.

Dave McClelland
+1  A: 

With ReSharper plugin you can define your own File Templates for user classes. Unfortunately it isn't free but you can always download 30 days trial. It provides large set of variables and control options. Here is sample FileTemplate:

//
// $Id: $
//
// Place your custom header here
// Module $PROJECT$ 
// 

namespace $NAMESPACE$
{
    public class $CLASS$ 
    {
        $END$
    }
 }

Created templates can be added to quicklist so when you want to create new file from template you open context menu on solution folder and choose Add/New From Template/TemplateName.

EDIT: Moreover you can provide File Header Text that will be pasted into all files (that are missing it) when you execute code cleanup command.

jethro
+2  A: 

Create a new C# class file template with all the text you nee to Documents\Visual Studio 2010\Templates\ItemTemplates\Visual C# and use it when creating new code.

data_smith