有没有办法强制所有cs文件包含标题注释?

时间:2013-06-13 08:19:15

标签: visual-studio visual-studio-2012 code-analysis

我们正在使用visual studio 2012.理想情况下,所有csharp文件(xxx.cs)都应该在文件的标题中包含一个版权注释,如

#region Copyright GOOGLE 2013
// 
// All rights are reserved. Reproduction or transmission in whole or in part, in 
// any form or by any means, electronic, mechanical or otherwise, is prohibited 
// without the prior written consent of the copyright owner. 
// 
#endregion

我的问题是,如果在创建文件时有一种方法可以自动包含该注释吗?或者可以使用代码分析来防止签入非注释cs文件。

1 个答案:

答案 0 :(得分:0)

您可以自定义Visual Studio在创建新文件时使用的模板

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

您自己的自定义模板可能包含所需的版权声明。

办理登机手续时的自动分析是否以及如何标记此类文件取决于您使用的源代码管理系统。许多人提供登记前和登记后的钩子。

相关问题