C # Implementation of the method of automatically adding copyright annotation information to class and function code

Source: Internet
Author: User

The example of this article describes the C # implementation of the class and function code to automatically add the copyright annotation information method, share for everyone for reference. Here's how:

Take the Web project as an example:


One: to annotate the class

1. Under the installation path for Visual Studio

such as: [Drive letter]:/program Files/microsoft Visual Studio 8/common7/ide/itemtemplates/web/cshare/2052/class.zip, Change the Class.cs inside to:

/*----------------------------------------------------------------//All rights reserved. FileName://File Function Description://////Create identity:////Modify the Identity://Modify the Description:////Modify the Identity://Modify the Description://------------------------------------------------ ----------------*/using system;using system.data;using system.configuration;using system.web;using System.web.security;using system.web.ui;using system.web.ui.webcontrols;using System.Web.UI.WebControls.WebParts; A summary description of the using system.web.ui.htmlcontrols;///<summary>///$safeitemrootname $//</summary>public class $ safeitemrootname${public $safeitemrootname $ () {//////TODO: Add constructor logic here//}}/*------------------------------ ----------------------------------//All rights reserved. FileName://File Function Description://////Create identity:////Modify the Identity://Modify the Description:////Modify the Identity://Modify the Description://------------------------------------------------ ----------------*/using system;using system.data;using system.configuration;using system.web;using System.web.security;using system.web.ui;using system.web.ui.webcontrols;using System.Web.UI.WebControls. Webparts;using system.web.ui.htmlcontrols;///<summary>///$safeitemrootname $ summary description///</summary>public Class $safeitemrootname ${public $safeitemrootname $ () {//////TODO: Add constructor logic here//}}

Save the file (unzip first, modify it)


Two: VS macro script Add function comment template

Now the IDE more and more powerful, for me and other lazy people save a lot. In order to use the future code yourself or others can understand it, it is essential to annotate this stuff. When you add a comment to a function, the format is fixed. Each function is written once, or copied from another function, which is cumbersome and error prone. This repetitive work is annoying, there is no desire to write comments, then the macro of VS can kill these "dirty, chaotic, tired" manual work.

Look, VS2010 's macro script is VBScript, and it's easy to get started. I wrote a macro script that generates a function comment template, which is easier to see code:

Imports systemimports envdteimports envdte80imports envdte90imports system.diagnosticspublic Module Module1 Sub Addfuncomment () Dim Docsel as envdte.textselection Docsel = DTE. Activedocument.selection docsel.newline () Docsel.text = "/******************************************************** "Docsel.newline () Docsel.text =" * Function name: "Docsel.newline () Docsel.text =" * Function: "docsel.new Line () Docsel.text = "* Parameter:" Docsel.newline () Docsel.text = "* Return value:" Docsel.newline () Docsel.text = "    * Author: Lonkil "Docsel.newline () Docsel.text =" * e-mail: lonkil{at}gmail.com ({at}-@) "Docsel.newline () Docsel.text = "* Date Created:" + System.DateTime.Now.ToLongDateString () docsel.newline () Docsel.text = "***************** /"End subend moduleimports systemimports envdteimports Envdte80imports envdte90imports system.diagnosticspublic Module Module1 Sub addfuncomment () Dim doCSel as Envdte.textselection Docsel = DTE. Activedocument.selection docsel.newline () Docsel.text = "/******************************************************** "Docsel.newline () Docsel.text =" * Function name: "Docsel.newline () Docsel.text =" * Function: "docsel.new Line () Docsel.text = "* Parameter:" Docsel.newline () Docsel.text = "* Return value:" Docsel.newline () Docsel.text = "    * Author: Lonkil "Docsel.newline () Docsel.text =" * e-mail: lonkil{at}gmail.com ({at}-@) "Docsel.newline () Docsel.text = "* Date Created:" + System.DateTime.Now.ToLongDateString () docsel.newline () Docsel.text = "***************** /"End SubEnd Module

Specific steps: Create a new macro project, vs2010 IDE, Tools, and select a location to save. Then you will copy the above script and save it.

Specific use: For you to write the macro binding shortcut key, vs2010 IDE, Tools, Options, select Keyboard in the list on the left, and in the show command contains on the right, select you create a macro, and then locate the cursor to "press shortcut key", enter you want to Named shortcut keys, such as "Alt+c", can be saved.

It is important to note that Visual Studio 2005 Team Suite needs to be patched SP1, and the macro can be used otherwise.

It is believed that this article has certain reference value for the C # program design of everybody.

In addition to the Declaration, Running GuestArticles are original, reproduced please link to the form of the address of this article
C # Implementation of the method of automatically adding copyright annotation information to class and function code

This address: http://www.paobuke.com/develop/c-develop/pbk23525.html






Related Content C # Two simple code examples to connect to MySQL C # retrieves case-insensitive and highlights an instance of the list in a C # array, dictionary's mutual conversion problem C # for loop, while loop loop execution method
C # Implementation of the method to add a watermark to a picture C # Implement a method to copy a file in a folder to another folder C # Set boot entry, Cancel boot entry devexpress get treelist Visual Area node Collection implementation method

C # Implementation of the method of automatically adding copyright annotation information to class and function code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.