MSTEST0031:
| 属性 | 值 |
|---|---|
| 规则 ID | MSTEST0031 |
| 标题 |
System.ComponentModel.DescriptionAttribute 对测试方法没有影响。 |
| 类别 | 使用情况 |
| 修复是中断修复还是非中断修复 | 非中断 |
| 默认为启用 | 是 |
| 默认严重性 | 警告:从 4.0.0 开始;信息之前。 |
| 引入版本 | 3.5.0 |
| 是否存在代码修补程序 | 否 |
原因
“System.ComponentModel.DescriptionAttribute”在测试上下文中不起作用。
规则说明
“System.ComponentModel.DescriptionAttribute”在测试上下文中不起作用,因此用户可能希望改用“Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute”。
如何解决冲突
请将“System.ComponentModel.DescriptionAttribute”删除或替换为“Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute”。
何时禁止显示警告
不建议取消诊断,因为 System.ComponentModel.DescriptionAttribute 在测试上下文中不起作用。
抑制警告
如果只想抑制单个冲突,请将预处理器指令添加到源文件以禁用该规则,然后重新启用该规则。
#pragma warning disable MSTEST0031
// The code that's violating the rule is on this line.
#pragma warning restore MSTEST0031
若要对文件、文件夹或项目禁用该规则,请在none中将其严重性设置为 。
[*.{cs,vb}]
dotnet_diagnostic.MSTEST0031.severity = none
有关详细信息,请参阅如何禁止显示代码分析警告。