Monday, December 29, 2008

Add file header

To add C# file header according to StyleCop's SA1633 you can use this macro:



Sub AddFileHeader()


        DTE.ActiveDocument.Selection.StartOfDocument()


        DTE.ActiveDocument.Selection.Text = "//-----------------------------------------------------------------------"


        DTE.ActiveDocument.Selection.NewLine()


        DTE.ActiveDocument.Selection.Text = "// <copyright file=""" + DTE.ActiveDocument.Name() + """ company=""MyCompany d.o.o."">"


        DTE.ActiveDocument.Selection.NewLine()


        DTE.ActiveDocument.Selection.Text = "//    Copyright (c) MyCompany d.o.o. All rights reserved."


        DTE.ActiveDocument.Selection.NewLine()


        DTE.ActiveDocument.Selection.Text = "// </copyright>"


        DTE.ActiveDocument.Selection.NewLine()


        DTE.ActiveDocument.Selection.Text = "//-----------------------------------------------------------------------"


        DTE.ActiveDocument.Selection.NewLine(2)


    End Sub


No comments: