Adding author name automatically in C#

拈花ヽ惹草 提交于 2021-01-28 05:36:40

问题


I want to add creator name into when all .cs and .xml files created. So I could use Eclipse as follows, but I cannot use this in Visual Studio

Window -> Preferences -> Java -> Code Style -> Code templates

/**
 * @author ${user}
 *
 * ${tags}
 */

I'm open to suggestions on how to do this.


回答1:


You can change the template for your classes that can usually be found under:

C:\Program Files (x86)\Microsoft Visual Studio version\Common7\IDE\ItemTemplates\CSharp\

Something like this:

using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
$endif$using System.Text;

/**
* @author $username$
*
* @date - $time$ 
*/

namespace $rootnamespace$
{
    class $safeitemrootname$
    {
    }
}

The complete list of Template Parameters you can find Here.

In VS2015 the cs file located in:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.cs



来源:https://stackoverflow.com/questions/46195179/adding-author-name-automatically-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!