This article describes the method of C# to automatically add copyright annotation information to class and function codes, and is shared with you for your reference. The specific methods are as follows:
Take web projects as an example:
1: Add comments to the class
1. Under the installation path of visual studio
For example: [Drive Letter]:/Program files/Microsoft Visual Studio 8/Common7/IDE/ItemTemplates/web/cshare/2052/ , change the inside to:
/*---------------------------------------------------------------- // all rights reserved. // // file name: // File function description: // // // Create the ID: // // Modify the logo: // Modify the description: // // Modify the logo: // Modify the description: //----------------------------------------------------------------*/ using System; using ; using ; using ; using ; using ; using ; using ; using ; /// <summary> /// Summary description of $safeitemrootname$/// </summary> public class $safeitemrootname$ { public $safeitemrootname$() { // // TODO: Add constructor logic here // } } /*---------------------------------------------------------------- // all rights reserved. // // file name: // File function description: // // // Create the ID: // // Modify the logo: // Modify the description: // // Modify the logo: // Modify the description: //----------------------------------------------------------------*/ using System; using ; using ; using ; using ; using ; using ; using ; using ; /// <summary> /// Summary description of $safeitemrootname$/// </summary> public class $safeitemrootname$ { public $safeitemrootname$() { // // TODO: Add constructor logic here // } }
Save the file (decompress first, modify it)
2: VS macro script adds function comment template
Nowadays, IDE is getting stronger and stronger, saving us a lot of lazy people. In order to understand the code yourself or others, commenting is essential. When adding comments to functions, the format is fixed. If you write each function once or copy it from another function, it is troublesome and easy to make mistakes. This kind of repetitive work makes people feel upset and have the desire to write comments. At this time, VS's macro can kill these "dirty, messy, and tired" physical tasks.
After taking a look, the macro script for vs2010 is VBScript, which is easy to get started. I wrote a macro script that generates function comment templates. It's easier to read the code:
Imports System Imports EnvDTE Imports EnvDTE80 Imports EnvDTE90 Imports Public Module Module1 Sub AddFunComment() Dim DocSel As DocSel = () = "/******************************************************************************" () = "* Function name: " () = "* Function: " () = "* Parameter: " () = "* Return Value: " () = "* Author: Lonkil" () = "* Email: lonkil{AT} ( {AT} -> @ )" () = "* Created date: " + () () = "************************************************************************/" End Sub End Module Imports System Imports EnvDTE Imports EnvDTE80 Imports EnvDTE90 Imports Public Module Module1 Sub AddFunComment() Dim DocSel As DocSel = () = "/******************************************************************************" () = "* Function name: " () = "* Function: " () = "* Parameter: " () = "* Return Value: " () = "* Author: Lonkil" () = "* Email: lonkil{AT} ( {AT} -> @ )" () = "* Created date: " + () () = "************************************************************************/" End Sub End Module
Specific creation steps: vs2010 IDE -> Tools -> Macros -> Create a new macro project and select the location to save. Then copy the script you want to above and save it.
Specific use: The macro binding shortcut keys written for you, vs2010 IDE -> Tools -> Options -> Select "Keyboard" in the left list -> In the "Show Command Inclusion" on the right, select you to create a macro-> Position the cursor to "Press Shortcut Key" -> Enter the shortcut key you want to name, such as "Alt+C", and save.
One thing to note: Visual Studio 2005 Team Suite requires SP1 patch to be used before the macro can be used otherwise it will be invalid.
I believe that the description in this article has certain reference value for everyone's C# programming.