C# 从代码覆盖范围中排除类-.runsettings

C# 从代码覆盖范围中排除类-.runsettings,c#,.net,code-coverage,C#,.net,Code Coverage,我使用.runsettings文件将一些代码从代码覆盖率中排除,但它并没有将它们从代码覆盖率中排除,因为我的代码覆盖率百分比根本没有改变。也没有错误 代码: 然后在函数标签中这样做: <Function>xxx.DI.Mobile.Core.State.ViewModels.xxx.xxx</Function> xxx.DI.Mobile.Core.State.ViewModels.xxx.xxx 在我的函数标记中尝试这些正则表达式,但没有一个有效: <Func

我使用.runsettings文件将一些代码从代码覆盖率中排除,但它并没有将它们从代码覆盖率中排除,因为我的代码覆盖率百分比根本没有改变。也没有错误

代码:

然后在函数标签中这样做:

<Function>xxx.DI.Mobile.Core.State.ViewModels.xxx.xxx</Function>
xxx.DI.Mobile.Core.State.ViewModels.xxx.xxx
在我的函数标记中尝试这些正则表达式,但没有一个有效:

<Function>^xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Vehicle\.xxx$</Function>
<Function>^xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Vehicle\.xxx$</Function>
<Function>.*\.xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Policies\.xxx$</Function>
<Function>.*xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Dashboard\.xxx$</Function>
<Function>xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Common\.xxx</Function>
^xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Vehicle\.xxx$
^xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Vehicle\.xxx$
.*.xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Policies\.xxx$
*xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Dashboard\.xxx$
xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Common\.xxx

为什么不将我的任何代码排除在代码覆盖范围之外?

我猜系统无法解释排除中的
块,可能是尝试给出正则表达式

请尝试以下内容:

<Function>^xxx\.DI\.Mobile\.Core\.State\.ViewModels\.Common\.GetAQuoteViewModel$</Function> 
^xxx\.DI\.Mobile\.Core\.State\.ViewModels\.Common\.getaqueoteviewmodel$

*\.DI\.Mobile\.Core\.State\.ViewModels\.Common\.getaqueoteviewmodel$
此外,前两个排除项被解释为

anystring.test.dll

anystring.csv.dll

希望你能接受

我想您已经知道规则了,具体到这个代码覆盖率设置

但请看下面的列表

*匹配任何字符的字符串

。匹配一个点”

()匹配括号“()”

\匹配文件路径分隔符“\”

^匹配字符串的开头

$匹配字符串的结尾,
标记排除函数。因此,要排除整个类,只需将
\..*
添加到类的末尾,其中
\.
表示点,
*
表示任何内容。这门课的所有功能。例如:

xxx.xxx.Mobile.Core.xxx.ViewModels.Vehicle.xxx\..*

尽管点的意思是
\.
,但在我的文件夹名之间只包含一个
,不管怎样都是有效的

<Function>^xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Vehicle\.xxx$</Function>
<Function>^xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Vehicle\.xxx$</Function>
<Function>.*\.xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Policies\.xxx$</Function>
<Function>.*xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Dashboard\.xxx$</Function>
<Function>xxx\.DI\.Mobile\.Core\.xxx\.ViewModels\.Common\.xxx</Function>
<Function>^xxx\.DI\.Mobile\.Core\.State\.ViewModels\.Common\.GetAQuoteViewModel$</Function> 
<Function>.*\\.DI\.Mobile\.Core\.State\.ViewModels\.Common\.GetAQuoteViewModel$</Function>