1. 程式人生 > 其它 >修改Visual Studio類模板新增版權註釋資訊

修改Visual Studio類模板新增版權註釋資訊

在開發過程中,經常需要給類或介面與新增public修飾符和一些相關的註釋資訊,這個工作是機械而枯燥的,而這個簡單的需求可以通過修改VS自帶類模板來實現的。

開啟Visual Studio的安裝目錄,找到C:Program Files (x86)Microsoft Visual Studio2017CommunityCommon7IDEItemTemplatesCSharpCode2052Class三個目錄下面的cs檔案,並新增如下程式碼:

/*********************************************************************
 * Copyright(c) $year$$registeredorganization$ All Rights Reserved.
 * CLR 版本: $clrversion$
 * 機器名稱:$machinename$
 * 公司名稱:$registeredorganization$
 * 名稱空間:$rootnamespace$
 * 檔名:$safeitemname$
 * 版本號:V1.0.0.0
 * 唯一標識:$guid10$
 * 當前的使用者域:$userdomain$
 * 建立人:$username$
 * 電子郵箱:[email protected]
 * 建立時間:$time$
 ******************************************************/

通常情況而言,首行版權資訊,機器名稱,公司名稱可以不寫。

當然也可以像我這樣加點奇奇怪怪的東西上去!

/***************************** Raphael96  NS96.com ********************************
* 建立人:$username$                      
* 電子郵箱:[email protected]            
* 建立時間:$time$                         
* CLR 版本: $clrversion$                  
* 名稱空間:$rootnamespace$                
* 檔名:$safeitemname$
* 版本號:V1.0.0.0
* 唯一標識:$guid10$
* Copyright(c) $year$$registeredorganization$ All Rights Reserved.
*    ┏┓   ┏┓
*   ┏┛┻━━━┛┻┓
*   ┃       ┃
*   ┃   ━   ┃
*   ┃ ┳┛ ┗┳ ┃
*   ┃       ┃
*   ┃   ┻   ┃
*   ┃       ┃
*   ┗━┓   ┏━┛ Codes are far away from bugs with the animal protecting
*     ┃   ┃     神獸保佑,程式碼無bug
*     ┃   ┃
*     ┃   ┗━━━┓
*     ┃         ┣┓
*     ┃          ┏┛
*     ┗┓┓┏━┳┓┏┛
*      ┃┫┫ ┃┫┫
*      ┗┻┛ ┗┻┛
* *********************** Talk is cheap,Show me the code! ***********************/