如何从代码覆盖率数据中忽略生成的代码 [英] How to ignore generated code from code coverage data

查看:95
本文介绍了如何从代码覆盖率数据中忽略生成的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2010,并且想从代码覆盖率统计信息中排除生成的服务参考代码。

I am using Visual Studio 2010 and would like to exclude the generated service reference code from my code coverage statistics.

我找到了文章在2010年之前的文章中提到使用DebuggerNonUserCode和DebuggerHidden属性。我已经尝试过了,它的广告效果不错。 DebuggerNonUserCode是在类级别设置的,但是每个生成的服务参考代码文件中都生成了50多个类,所以这不是一个有吸引力的选择。

I found an article pre 2010 that mentions using DebuggerNonUserCode and DebuggerHidden attributes. I have tried this an it works as advertised. DebuggerNonUserCode is set at the class level, but with 50+ classes generated in each of the generated service reference code files, this is not an attractive option.

任何人都有吗替代解决方案?

Does anyone have any alternative solutions?

推荐答案

您可以创建一个代码生成器,该生成器使用 DebuggerNonUserCode 属性。

You could create a code generator that emits partial classes with the DebuggerNonUserCode attribute.

这篇关于如何从代码覆盖率数据中忽略生成的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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