VS2010 modifying template files, adding default annotations

Source: Internet
Author: User

In fact, this article is reproduced from the Internet, but cannot find the reproduced link, can only copy it over

The////document comments in VS are similar to/** */documentation comments in Java. can automatically generate the Help document.

If I want to automatically generate a document comment each time I create a file (note that the document comments are automatically generated instead of the Help document), as in the following code, you need to set up a template for VS, and the newly created CS class file will be generated based on what the template looks like. There are 3 commonly used vs file templates, namely Class.zip, Interface.zip, From.zip.

I use the Class.zip template setting as an example, the path of the template under VS2010

C:\Program Files (x86) \microsoft Visual Studio 10.0\common7\ide\itemtemplatescache\csharp\code\2052\class.zip

Here and on the Internet is a little different, the online province \code\ directory, perhaps vs2008 do not have this directory.

Double hit Open class.zip directly edit the Class.cs, do not unzip, save after editing. The template code is set up as follows:

1/* ============================================================================== 2  * Function Description: $safeitemrootname $   3  * Created by: $username $4  * Date Created: $time $5  * ========================================================== ====================*/6 using System; 7 using System.Collections.Generic; 8 $if $ ($targetframeworkversion $ >= 3.5) using System.Linq; 9 $endif $using system.text;10 namespace $rootnamespace $/<summary>14//     $safeitemrootname $     </summary>16 public     class $safeitemrootname $17     {     }19}

Here $var$ are system variables, template parameters are to be case-sensitive, we need to pay attention to. The available parameters for the system are as follows:

The parameter description clrversion the current version of the common language runtime (CLR).

GUID [1-10] is used to replace the GUID of the project GUID in the project file. You can specify a maximum of 10 unique GUIDs (for example, GUID1).

ItemName the name that is provided by the user in the Add New Item dialog box.

MachineName the current computer name (for example, Computer01).

ProjectName the name that is provided by the user in the New Project dialog box.

RegisteredOrganization the registry key value in HKLM\Software\Microsoft\Windows Nt\currentversion\registeredorganization.

RootNamespace the root namespace of the current project. This parameter is used to replace the namespace in the item that is added in the forward project.

Safeitemname the name that is provided by the user in the Add New Item dialog box, removing all unsafe characters and spaces from the name.

Safeprojectname the name that is provided by the user in the New Project dialog box, removing all unsafe characters and spaces from the name.

The current time in dd/mm/yyyy 00:00:00 format.

UserDomain the current user domain.

Username the current user name.

The current year in YYYY format.

Save and close, complete the template settings, and you will find the newly created class file as you wish.

Other VS versions have the same setup steps. Search the physical path of template files such as class.zip in the VS root directory

The difference between itemtemplates and Itemtemplatescache is that if you set a template under ItemTemplates, you need to run the Devenv/setup command on the VS command line. The Itemtemplatescache template is generated with the itemtemplates template, which means that the Itemtemplatescache template's settings are restored by the original itemtemplates template. So it is best not to easily change the content under the ItemTemplates template (he cannot restore).

VS2010 modifying template files, adding default annotations

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.