可视化 StyleCop 和代码分析规则违规
我正在建立一个项目,我们决定使用 StyleCop 和 VS2010“代码分析”规则。
我已经设置了构建,因此两组规则都会在每个构建上执行。问题是该项目的开发人员只能能够在构建时看到 StyleCop 和代码分析规则违规情况。
在编写代码时,VS2010 代码编辑器不会像处理构建错误那样突出显示违反规则的情况。恐怕这意味着人们最终会在很长一段时间内编写代码,并且在签入之前必须修复 100 多个规则违规行为。我想探索一个更有机的过程。
在花了过去两周的大部分时间进行谷歌搜索之后,我承认失败了。我发现“StyleCop for Resharper”可以为 StyleCop 规则违规提供内联代码编辑器突出显示。我想知道代码分析是否有类似的东西,或者 StyleCop 是否有其他选项?
谢谢,
--贾斯汀·安吉尔
I'm setting up a project where we've decide to use StyleCop and VS2010 "Code Analysis" rules.
I've setup the build so both sets of rules are executed on every build. The problem is that developers on this project will only be able to see StyleCop and Code Analysis rule violations on build.
While authoring code the VS2010 code editor doesn't highlight rules violations like it would do for build errors. I'm afraid that means folks would end up authoring code for an extended period of time and than prior to checkin have to fix 100+ rules violations. I'd like to explore a more organic process.
After spending the better part of the last two weeks googling, I admit defeat. I've found "StyleCop for Resharper" that would provide inline code editor highlights for StyleCop rules violations. I was wondering if there's something similar for Code Analysis or if there are any other options for StyleCop?
Thanks,
-- Justin Angel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,FxCop 没有与
StyleCop for Resharper
类似的东西。 StyleCop 仅查找风格指南违规行为,这意味着它只需要查看源代码、文本文件。 FxCop 对已编译的程序集进行分析,并查看 P/Invoke 正确性、对Dispose
的多次调用、非托管与托管 API 使用等。虽然工具当然可以对源代码执行此类分析(事实上, Resharper 可以帮助您解决一些(但肯定不是所有 FxCop 警告),要完全做到这一点实际上需要进行编译。如果您正在编译,那么您不妨只使用 FxCop。顺便说一句,Resharper 物有所值。Unfortunately there is nothing similar to
StyleCop for Resharper
for FxCop. StyleCop is looking only for style guideline violations, which means it need only look at source code, text files. FxCop performs analysis on compiled assemblies and looks at things like P/Invoke correctness, multiple calls toDispose
, unmanaged vs. managed API use, etc. While a tool could certainly perform such analysis of source (indeed, Resharper can help you with some, but certainly not all FxCop warnings), to do so fully would effectively require a compile. If you are compiling, then you might as well just use FxCop. By the way, Resharper is worth the money.