注意缩进格式。
A C# document may only contain a single class at the root level unless all of the classes are partial and are of the same type:【猜】C#文档一般只能包含对一个类的描述。除非这些类是partial类型或者是同类型的。这种错误一般是在一个*.cs文件中有多个不同类型的类。
函数规范:
The method must have an access modifier:方法需要访问修饰符(public private protected..)
The method must have a documentation header:方法必须要文档说明就是以‘///’开头的。
‘///’规范要求:
标签内的内容不允许为空。内容最好是用空格隔开否则会报‘The documentation text within the summary tag does not contain any whitespace between words, indicating that it most likely does not follow a proper grammatical structure required for documentation text’;
实例:
字段规范:
The field must have an access modifier:字段必须要有修饰符
Variable names must start with a lower-case letter:字段的名字必须是小写开头的
The field must have a documentation header:字段必须要有文档说明,以///开头的
有些程序员喜欢以_开头来命名字段,但是StyleCop是不推荐的。(Field names must not start with an underscore)
StyleCop放在http://stylecop.codeplex.com/,最新版本是2012年7月5日发布 4.7.44版本。更多的信息可以关注StyleCop开发团队的blog:http://blogs.msdn.com/sourceanalysis
StyleCop提供了简单和有效的方式来对项目的代码编写风格进行检查。StyleCop可以多种方式运行,可以插件的方式在Visual Studio的IDE中运行;也可以MSBuild任务的方式运行,可整合到程序构建流程中;或者以命令行的方式运行,可针对一个或多个代码文件进行检查。
StyleCop的命令行使用方法:
Usage: StyleCopCmd [options] [path]
Options: -a Process all source files found under the start path (default) -cs {file} Analyze the specified file. -f Perform a full analyze (ignore cached results) -u Do not write results cache files. -o {file} Apply the given StyleCop options file to all projects and files -l {file} Save violation report at the given location. If omitted, saves StyleCopViolations.xml in the current directory. -p {path} Attempts to discover StyleCop AddIn modules under the given path. This flag may be specified multiple times to search under multiple paths -i Ignore the default StyleCop AddIn path under the All Users\Applica tion Data folder
Conditional Compilation Flags: -define:FLAG1;FLAG2;FLAG3
Path: Specifies the path to begin search for source files. If this is omitted, uses the current directory as the start path.
CodeProject上有一篇文章详细的讲述StyleCop的使用方法C# Code Reviews using StyleCop – Detailed Article
优质内容筛选与推荐>>
1、rss是什么?2、第十五周课堂实践3、一个基于JRTPLIB的轻量级RTSP客户端(myRTSPClient)——实现篇:(九)以g711-mulaw为例添加新的编码格式解析支持4、中国互联网十种经典的商业模式5、python-基础