Visual studio 创建文件时自动添加备注

描述

要求每回添加一个类,普通类或单元测试类文件头自动添加备注, 比如:Copyright, FileName, Author and so on.

 

普通类文件

操作步骤:

1. 找出Class.cs, 存放位置:C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class。

2. 编辑Class.cs文件, 添加上文件备注(绿色部分)。

/*===============================================================================================

 Copyright© $year$ xxx Ltd. All rights reserved.
 
 File     : $safeitemname$.cs
 Author   : xxx xxx
 Created  : $time$ 
 Summary  : 

 ===============================================================================================*/
using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
$endif$using System.Text;
$if$ ($targetframeworkversion$ >= 4.5)using System.Threading.Tasks;
$endif$
namespace $rootnamespace$
{
    class $safeitemrootname$
    {
    }
}


 单元测试类文件(此处用的是NUnit测试类)

  操作步骤:

 1. 找到 UnitTest.cs, 存放位置:C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplates\CSharp\Test\1033\BasicUnitTest

 2. 编辑UnitTest.cs文件, 添加上文件备注(绿色部分), [TestFixture] and [Test]。

/*===============================================================================================

 Copyright© $year$ xxx Ltd. All rights reserved.
 
 File     : $safeitemname$.cs
 Author   : xxx xxx
 Created  : $time$ 
 Summary  : 

 ===============================================================================================*/

using System;
using NUnit.Framework;

namespace $rootnamespace$
{
    [TestFixture]
    public class $safeitemname$
    {
        [Test]
        public void TestMethod1()
        {
        }
    }
}

 

 

相关文章:

  • 2021-12-29
  • 2022-12-23
  • 2021-11-25
  • 2021-09-24
  • 2021-08-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2021-10-21
  • 2021-08-17
  • 2021-07-30
相关资源
相似解决方案