让你的Visual Studio 2010自动添加头部注释信息【转】
2012-10-11 11:41
519 查看
原文连接:http://shinylife.net/blog/article.asp?id=1159
在日常的开发中我们经常需要为我们的类库添加注释和版权等信息,这样我们就需要每次去拷贝粘贴同样的文字,为了减少这种重复性的工作,我们可以把这些信息保存在Visual Studio 2010类库模版文件里。
首先找到Visual Studio 2010的安装路径下\Common7\IDE\ItemTemplatesCache\CSharp\目录,如图:
里面有好多目录,Windows Forms是开发Windows Forms程序的模版目录,Web是Web项目文件的模版目录,其他的同理。进入Web目录有选择2052目录(2052是中文地区的代号)下,会看到好多带有.zip的目录,比如我要修改web页面的模版,就修改\WebForm.zip\Default.aspx.cs,打开Default.aspx.cs会看到如下内容。
复制代码
代码中的"$"符号之间的字符是模版的变量,具体变量含义请参照:
复制代码
下面是我写注释的格式,那我们就按照这个格式做一个模版。
复制代码
首先在对应的地方替换成自己需要使用的变量。
复制代码
最后把上面的文本添加到Default.aspx.cs的最前面就行了。
看下我的最终成果:
复制代码
如需修改其他的就按照上面的步骤找到对应的文件夹就行了。
在日常的开发中我们经常需要为我们的类库添加注释和版权等信息,这样我们就需要每次去拷贝粘贴同样的文字,为了减少这种重复性的工作,我们可以把这些信息保存在Visual Studio 2010类库模版文件里。
首先找到Visual Studio 2010的安装路径下\Common7\IDE\ItemTemplatesCache\CSharp\目录,如图:
里面有好多目录,Windows Forms是开发Windows Forms程序的模版目录,Web是Web项目文件的模版目录,其他的同理。进入Web目录有选择2052目录(2052是中文地区的代号)下,会看到好多带有.zip的目录,比如我要修改web页面的模版,就修改\WebForm.zip\Default.aspx.cs,打开Default.aspx.cs会看到如下内容。
1 using System; 2 using System.Collections.Generic; 3 $if$ ($targetframeworkversion$ >= 3.5)using System.Linq;$endif$ 4 using System.Web; 5 using System.Web.UI; 6 using System.Web.UI.WebControls; 7 8 namespace $rootnamespace$ 9 { 10 public partial class $classname$ : System.Web.UI.Page 11 { 12 protected void Page_Load(object sender, EventArgs e) 13 { 14 15 } 16 } 17 }
复制代码
代码中的"$"符号之间的字符是模版的变量,具体变量含义请参照:
$time$ 日期 $year$ 年份 $clrversion$ CLR版本 $GUID$ 用于替换项目文件中的项目 GUID 的 GUID。最多可以指定 10 个唯一的 GUID(例如,guid1))。 $itemname$ 用户在对话框中提供的名称。 $machinename$ 当前的计算机名称(例如,Computer01)。 $projectname$ 用户在对话框中提供的名称。 $registeredorganization$ HKLM\Software\Microsoft\Windows NT\CurrentVersion\RegisteredOrganization 中的注册表项值。 $rootnamespace$ 当前项目的根命名空间。此参数用于替换正向项目中添加的项中的命名空间。 $safeitemname$ 用户在“添加新项”对话框中提供的名称,名称中移除了所有不安全的字符和空格。 $safeprojectname$ 用户在“新建项目”对话框中提供的名称,名称中移除了所有不安全的字符和空格。 $time$ 以 DD/MM/YYYY 00:00:00 格式表示的当前时间。 $userdomain$ 当前的用户域。 $username$ 当前的用户名。
复制代码
下面是我写注释的格式,那我们就按照这个格式做一个模版。
1 // =============================================================================== 2 // Project Name : Weisenz.Core 3 // Project Description : 4 // =============================================================================== 5 // Class Name : HttpModule 6 // Class Version : v1.0.0.0 7 // Class Description : 8 // Author : Charles 9 // Create Time : 2012/3/29 13:19:28 10 // Update Time : 2012/3/29 13:19:28 11 // =============================================================================== 12 // Copyright © Weisenz 2012 . All rights reserved. 13 // ===============================================================================
复制代码
首先在对应的地方替换成自己需要使用的变量。
1 // =============================================================================== 2 // Project Name : $rootnamespace$ 3 // Project Description : 4 // =============================================================================== 5 // Class Name : $safeitemrootname$ 6 // Class Version : v1.0.0.0 7 // Class Description : 8 // Author : $username$ 9 // Create Time : $time$ 10 // Update Time : $time$ 11 // =============================================================================== 12 // Copyright © $machinename$ $year$ . All rights reserved. 13 // ===============================================================================
复制代码
最后把上面的文本添加到Default.aspx.cs的最前面就行了。
看下我的最终成果:
1 // =============================================================================== 2 // Project Name : Weisenz.Web 3 // Project Description : 4 // =============================================================================== 5 // Class Name : Services 6 // Class Version : v1.0.0.0 7 // Class Description : 8 // Author : Charles 9 // Create Time : 2012/3/29 13:38:53 10 // Update Time : 2012/3/29 13:38:53 11 // =============================================================================== 12 // Copyright © Weisenz 2012 . All rights reserved. 13 // =============================================================================== 14 using System; 15 using System.Collections.Generic; 16 17 using System.Web; 18 using System.Web.UI; 19 using System.Web.UI.WebControls; 20 21 namespace Weisenz.Web 22 { 23 public partial class Services : System.Web.UI.Page 24 { 25 protected void Page_Load(object sender, EventArgs e) 26 { 27 28 } 29 } 30 }
复制代码
如需修改其他的就按照上面的步骤找到对应的文件夹就行了。
相关文章推荐
- 关于Visual Studio 2010自动添加头部注释信息
- 让你的Visual Studio 2010自动添加头部注释信息
- 让你的Visual Studio 2010自动添加头部注释信息
- Visual Studio 2010自动添加头部注释信息
- 关于Visual Studio 2010自动添加头部注释信息
- [转]让你的Visual Studio 2010自动添加头部注释信息
- 让你的Visual Studio 2010自动添加头部注释信息
- 让你的Visual Studio 2010自动添加头部注释信息
- 让Visual Studio 自动添加头部注释信息
- 让Visual Studio 自动添加头部注释信息
- Visual Studio自动添加头部注释 -C#开发2010-2013验证
- 关于Visual Studio 20**自动添加头部注释信息
- 让Visual Studio 自动添加头部注释信息
- 关于Visual Studio 20**自动添加头部注释信息
- Visual Studio 20**自动添加头部注释信息
- 如何在 Visual Studio 2015 中自动给 cpp 和 h 文件添加头部注释
- VS 2015 自动添加头部注释,作者,版本信息
- Eclipse新建类的时候如何自动添加注释(作者,时间的信息等)
- VS中为类,函数代码自动添加版权注释信息
- 第一个 想创建文件时 文件的头部注释会自动生成我自己想要的信息 怎么配置呢