将实时代码分析替换为静态代码分析(FxCop)? [英] Live Code Analysis as Static Code Analysis (FxCop) replacement?

查看:63
本文介绍了将实时代码分析替换为静态代码分析(FxCop)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当VS2015到来时,我对实时代码分析("Roslyn")功能感到非常兴奋,但是很快意识到,甚至在构建过程中还无法替代作为静态代码分析提供的FxCop规则. .号码 现有LCA程序集中实施的规则很差.

When VS2015 came I got quite excited about the Live Code Analysis ("Roslyn") feature, but realized quite quickly that it was not even close to be a replacement to the FxCop rules provided as Static Code Analysis during build. The number of rules implemented in the existing LCA assemblies was to poor.

现在将近两年后,我看到仍然没有LCA软件包可以替代FxCop规则.

Now almost two years later, I can see that there are still no LCA packages that can replace the FxCop rules.

在构建过程中使用静态代码分析的最大问题是它太耗时.在较大的解决方案中,如果打开代码分析,则可能最多花费10倍的时间才能构建.这就是为什么我希望将整个CA-during-build问题替换为 LCA,但现在我意识到这永远不会发生.至少没有我们想要的规则集.

The big problem with Static Code Analysis during build is that it's too time consuming. In larger solutions it can take up to 10 times longer to build if code analysis is turned on. That's why I was hoping to replace the whole CA-during-build problem with LCA, but now I realize that this will never happen. At least not with the rulesets we want.

因此,我认为也许我们可以同时进行,在项目中配置LCA并在构建缺失规则时保留SCA.但是,在构建期间是否可以从SCA中忽略LCA规则?我看到的都是使用规则集文件,但是 您不能在不同的规则集中为同一规则设置不同的配置:

So I thought that maybe we can do both, configuring LCA in the projects and keeping SCA when building for the missing rules. However, is it possible to ignore the LCA rules from SCA during build time? What I can see, both are using the ruleset files, but you can't have different configurations for the same rule in different rulesets:

此配置将导致编译器说它无法读取文件,因为规则1821具有不同的操作.

This configuration will cause the compiler to say it can't read the file becasue the rule 1821 have different actions.

那么,如果我同时启用了两者,在代码分析过程中,SCA是否仍将对所有代码执行1821规则,还是因为它存在于LCA中而将其跳过?

So, what if I enable both, will the SCA still execute the 1821 rule on all code during code analysis, or will it skip it because it exist in LCA?

正如您可能理解的,我要问的是;使用LCA会缩短我们的构建时间吗?

As you might understand, what I'm asking is; will using LCA ever speed up our build times?

/Staffan

推荐答案

嗨斯塔凡,

我在这里用一个简单的类库项目测试一个简单的示例,这将违反规则.

I test a simple sample here with a simple class library project which will go against the rule.

如果我仅使用VS默认规则,则会收到如下图所示的警告.

If I just use the VS default rule, I will get the warning like this screen shot.

然后我使用块页面: https://www.nuget.org/packages/Microsoft.AnalyzerPowerPack/

And then I use the nugget page: https://www.nuget.org/packages/Microsoft.AnalyzerPowerPack/

我将得到如屏幕截图2所示的结果:

I will get the result like the screen shot 2:

>>那么,如果我同时启用了这两个选项,那么SCA是否仍将在代码分析期间对所有代码执行1821规则,或者因为它存在于LCA中而会跳过它?

>>So, what if I enable both, will the SCA still execute the 1821 rule on all code during code analysis, or will it skip it because it exist in LCA?

>>如您可能理解的,我要问的是;使用LCA会缩短我们的构建时间吗?

>>As you might understand, what I'm asking is; will using LCA ever speed up our build times?

因此,对于您先前的问题,即使它们具有类似的代码警告消息,它也会调用两个规则.

So for your previous issue, it will call two rules even if they have the similar code warning messages.

最好的问候,

杰克


这篇关于将实时代码分析替换为静态代码分析(FxCop)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆