简体   繁体   English

Visual Studio:未为签名程序集生成代码覆盖率

[英]Visual Studio: Code coverage not generated for signed assemblies

We are developing a system using c# in Visual Studio 2008. 我们正在Visual Studio 2008中使用c#开发系统。

When I configure VS to instrument my dll's and run the tests, only the dll that is not signed gets instrumented (nice way to find that we forgot one). 当我配置VS来检测我的dll并运行测试时,只会检测未签名的dll(找到我们忘记一个的好方法)。

Is there a way to generate code coverage on signed dll's or do I have to un sign them, run the analysis and then sign them again? 有没有一种方法可以在已签名的dll上生成代码覆盖率,还是我必须取消对它们的签名,运行分析然后再次对其进行签名?

Thanks 谢谢

Shiraz 设拉子

The reason you can not instrument a signed assembly is that the instrumentation process changes the contents of the assembly. 无法检测已签名的程序集的原因是检测过程会更改程序集的内容。 This would change the hash of the assembly hence invalidating the digital signature. 这将更改程序集的哈希值,从而使数字签名无效。

The best approach is to unsign the assembly for the profiling run. 最好的方法是为程序运行取消对程序集的签名。

As already stated, an assembly signature is invalidated when instrumenting (or otherwise modifying) a signed assembly. 如前所述,在检测(或修改)已签名的程序集时,程序集签名无效。

The irony is that instrumentation is not required to do profiling/coverage analysis as .NET has an API for this. 具有讽刺意味的是,由于.NET具有用于此目的的API,因此不需要进行分析/覆盖分析的工具。 For some obscure reason, however, the Visual Studio coverage analysis and profiler does not use this API... 但是,由于某些模糊的原因,Visual Studio覆盖率分析和探查器使用此API。

Third party products such as the profilers dotTrace and ANTS, or coverage analysis tools such as NCover, use the API approach and thus have no need to tamper with the assemblies themselves. 诸如探查器dotTrace和ANTS之类的第三方产品,或诸如NCover之类的覆盖率分析工具,都使用API​​方法,因此无需篡改程序集本身。

In our current project, exactly this problem made us purchase 3rd party tooling since developing without signing in our very complex solution would take a massive effort due to a lot of reflection and was out of the question. 在我们当前的项目中,正是这个问题使我们购买了第三方工具,因为在没有签署我们非常复杂的解决方案的情况下进行开发会由于大量的反思而付出巨大的努力,因此是不可能的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM