使用 StyleCop 配置花括号
是否有可能让 StyleCop 说这是使用大括号的正确方法?
if (request.Query == string.Empty) {
return SearchResponse.Empty;
}
但不是这个
if (request.Query == string.Empty)
return SearchResponse.Empty;
或这个:
if (request.Query == string.Empty)
{
return SearchResponse.Empty;
}
我也希望 if、else、else if、while、foreach 和 for 具有这种行为。但不适用于类声明或方法声明。
Is it possible to get StyleCop to say that this is the correct way to use curly braces?
if (request.Query == string.Empty) {
return SearchResponse.Empty;
}
But not this
if (request.Query == string.Empty)
return SearchResponse.Empty;
Or this:
if (request.Query == string.Empty)
{
return SearchResponse.Empty;
}
I also want this behavior for if, else, else if, while, foreach and for. But not for class declarations or method declarations.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为它是开箱即用的;但是,StyleCop 附带了一个 SDK,其中包含有关如何编写自定义规则的说明。尽管如果有人已经创建了完成您所描述的内容的自定义规则,这将是最有帮助的,但您可能会发现您必须推出自己的规则。
我本来打算添加 SDK 文档的链接,但 .CHM 当时似乎已损坏。您可能需要从 http://stylecop.codeplex.com 获取整个项目以了解详细信息。
祝你好运!
I don't think it does that out of the box; however, StyleCop ships with an SDK that includes instructions on how to author custom rules. Although it would be most helpful if someone has already created a custom rule accomplishing what you describe, you may find that you must roll your own.
I was going to add a link to the SDK docs, but the .CHM appeared to be broken at the time. You may need to get the whole project from http://stylecop.codeplex.com to read up on details.
Good luck!