VS2008中的代码分析/FxCop

发布于 2024-07-10 17:25:00 字数 226 浏览 7 评论 0原文

FxCops 对我来说是新事物,但我一如既往地想了解新事物。 据我所知,FxCops 已经包含在 VS2008 中。 我猜这是“代码分析”功能。 每当我尝试运行它时,它似乎都会开始重建并以“完成重建”状态结束。
我检查了输出窗口,那里有很多警告。 但如果我没记错的话,应该有更多的 GUI,而不是输出窗口中的文本墙,对吗?
我是否错过了应该弹出的窗口? 我可以在某个地方打开它吗? 或者还有什么我想念的吗?

FxCops is something new to me, but as always I would like to get to know the new things..
From what I've read, FxCops is already included in VS2008. I guess it's the "Code Analysis" function. Whenever I try to run it though, it seems to start a rebuild and end in the "Finished Rebuilding" state.
I checked the output window and there are a bunch of warnings there. But if I'm not mistaking, there should be more of a GUI for this then the wall of text in my output window, right?
Am I missing a window that should have popped up? Can I open it somewhere? Or is there anything else I'm missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

那片花海 2024-07-17 17:25:00

是的,代码分析是 FxCop 的一个好听又友好的名字。 但是,我不知道除了应该出现的错误/警告列表之外还有一个友好的窗口,前缀为 CA

在项目属性屏幕上有一个代码分析选项卡,您可以在其中将警告视为错误以强制执行您关心的规则。

Yes, Code Analysis is the nice friendly name for FxCop. However, I'm not aware of a friendly window beyond the errors / warning list where they should appear, prefixed CA.

On the project properties screen there is a Code analysis tab where you can treat warnings as errors to enforce the rules you care about.

疯狂的代价 2024-07-17 17:25:00

众所周知,因为我花了很长时间才弄清楚这一点...代码分析/FxCop仅包含在VS 2008的Team System和Team Suite版本中,而不包含在专业版中。

Just so everyone knows, because it took me a long time to figure this out.... Code Analysis / FxCop is only included in Team System and Team Suite versions of VS 2008, not in the Professional Edition.

百变从容 2024-07-17 17:25:00

你不会错过任何东西——没有弹出窗口。

输出窗口中的问题列表几乎就是您在 FxCop 中得到的全部内容。 只是 FxCop 是一个独立的应用程序。

这是一篇关于 FxCop 和代码分析的不错的文章:

链接

You're not missing anything - there isn't a pop-up window.

The list of issues in the output window is pretty much all you'd get in FxCop. It's just that FxCop is a standalone application.

Here's a decent article on FxCop and Code Analysis:

Link

水溶 2024-07-17 17:25:00

FxCop 的替代方法是使用 NDepend 工具,它可以让您编写 C# LINQ 查询的代码规则(即CQLinq)。 NDepend 集成在 VS 2012、2010 和 2008 中。免责声明:我是该工具的开发人员之一

html" rel="nofollow noreferrer">默认建议200条代码规则。 借助众所周知的 C# LINQ 语法,自定义现有规则或创建自己的规则非常简单。

NDepend 代码规则可以在 Visual Studio 中实时验证,并在构建过程中进行验证,生成的 HTML+javascript 报告

您似乎对误报的数量感到担忧。 为了保持较低的误报数量,CQLinq 提供了独特的功能,可以通过以 notmycode 为前缀的特殊代码查询来定义 JustMyCode 集合。 有关此功能的更多说明可以在此处找到。 例如,以下是两个 notmycode 默认查询:

为了保持较低的误报数量,使用 CQLinq,您还可以将规则结果仅集中在添加的代码或重构的代码上,因为定义的 过去的基线。 请参阅以下规则,检测自基线以来添加或重构过于复杂的方法:

warnif count > 0 
from m in Methods
where m.CyclomaticComplexity > 20 &&
      m.WasAdded() || m.CodeWasChanged()
select new { m, m.CyclomaticComplexity }

An alternative to FxCop would be to use the tool NDepend that lets write Code Rules over C# LINQ Queries (namely CQLinq). NDepend is integrated in VS 2012, 2010 and 2008. Disclaimer: I am one of the developers of the tool

More than 200 code rules are proposed by default. Customizing existing rules or creating your own rules is straightforward thanks to the well-known C# LINQ syntax.

NDepend code rules can be verified live in Visual Studio and at build process time, in a generated HTML+javascript report.

You seems concerned by the number of false-positive. To keep the number of false-positives low, CQLinq offers the unique capabilities to define what is the set JustMyCode through special code queries prefixed with notmycode. More explanations about this feature can be found here. Here are for example two notmycode default queries:

To keep the number of false-positives low, with CQLinq you can also focus rules result only on code added or code refactored, since a defined baseline in the past. See the following rule, that detect methods too complex added or refactored since the baseline:

warnif count > 0 
from m in Methods
where m.CyclomaticComplexity > 20 &&
      m.WasAdded() || m.CodeWasChanged()
select new { m, m.CyclomaticComplexity }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文