禁用code分析警告.NET [英] Disable Code analysis warnings .NET

查看:178
本文介绍了禁用code分析警告.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在视觉工作室,我可以运行在我的.NET项目code分析。我运行的基本正确性,并有85警告。这是一个有点多。另外大部分是外code。

如何禁用特定的警告,这样我可以专注于更重要的警告?我想下面的,但它不承认code分析警告。 (我第一次尝试W / O型的CA)

 的#pragma警告禁止CA1820 CA1065 CA2100
 

解决方案

您需要复制一个code分析规则集,并停用你不喜欢的规则。

转至项目属性,选择一个规则集,从开始,然后单击打开。
取消选中,你不喜欢规则,然后单击另存为。
最后,选择该规则在项目属性进行设置。

您也可以从头开始,通过右键单击该项目或解决方案,然后单击添加新项,$ C C分析规则集$。

In visual studios i can run code analysis on my .NET project. I am running basic correctness and have 85 warnings. Which is a little much. Also majority of them are in external code.

How do i disable specific warnings so i can focus on the more important warnings? I tried the below but it does not recognize code analysis warnings. (I first tried w/o the CA)

#pragma warning disable CA1820 CA1065 CA2100

解决方案

You need to copy a code analysis ruleset and disable the rules you don't like.

Go to the Project Properties, select a ruleset to start from, then click Open.
Uncheck the rules that you don't like, then click Save As.
Finally, select that rule set in Project Properties.

You can also start from scratch, by right-clicking the project or solution and clicking Add New Item, Code Analysis Rule Set.

这篇关于禁用code分析警告.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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