Adding Author Name in document Header using StyleCop

南笙酒味 提交于 2020-01-03 05:44:30

问题


I am using StyleCop with Visual Studio. Whenever i add a new file it adds few information like company name ,copyright details. I want to add author name and creation date also .Is it possible to update the StyleCop Setting somewhere to support this ?


回答1:


http://blogs.msdn.com/b/sourceanalysis/archive/2008/05/25/sharing-source-analysis-settings-across-projects.aspx

http://blogs.msdn.com/b/sourceanalysis/archive/2008/05/25/managing-source-analysis-project-settings.aspx

Between them you are sorted ;)

So you create a stylecop settings file for a project (right click on project -> stylecop settings) then copy it into solution root and all the projects will basically inherit their stylecop settings from it.




回答2:


The StyleCop templates are located at /Common7/IDE/ItemTemplates/CSharp/Code/1033 relative to the Visual Studio install location (VS2010 by default will be either C:/Program Files/Microsoft Visual Studio 10.0 or C:/Program Files (x86)/Microsoft Visual Studio 10.0, look first in the x86 folder if both exist).

The templates are supplied in zip files containing a .cs file and a .vstemplate file. Extract the zip file, modify the .cs file, re-zip the two files and place it back in the original folder (I recommend creating a backup of the original just in case). In order to have Visual Studio actually use your new, modified template, run this command in a command prompt:

"%ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE\devenv.com" /setup"

You'll notice that the template format is a bit different than a regular C# file. This allows for the ability to customize how the template appears based on different settings. MSDN has several guides on how these work and how to use them:

http://msdn.microsoft.com/en-us/library/ms247113.aspx

http://msdn.microsoft.com/en-us/library/eehb4faa.aspx

http://msdn.microsoft.com/en-us/library/ms185311.aspx



来源:https://stackoverflow.com/questions/9139571/adding-author-name-in-document-header-using-stylecop

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