如何删除警告:CodeContracts:assert为false [英] How to remove warning: CodeContracts: assert is false

查看:63
本文介绍了如何删除警告:CodeContracts:assert为false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个代码块,我想在调试版本中始终断言,所以我有:

I have a code block that I want to always assert in a debug build so I have:

Debug.Assert(false,"找不到Unity.config" ;);

Debug.Assert(false, "Could not find Unity.config");

有没有办法告诉代码合约没有对此发出警告?

Is there a way to tell Code Contracts to not warn on this?

推荐答案

<您好Robin,

您可以尝试在方法中添加 SuppressMessageAttribute 。 要获得适当的
checkId 值,请将 -outputwarnmasks 选项添加到额外静态检查器选项
字段项目的
属性
窗口中的代码合同标签,然后检查您必须在属性中指定的值的构建输出窗口。

You could try adding SuppressMessageAttribute to the method.  To get an appropriate checkId value, add the -outputwarnmasks option to the Extra Static Checker Options field on the Code Contracts tab in your project's Properties window and then examine the build output window for the value that you must specify in the attribute.

代码合同文档提供了更多信息。 它通常可以在以下位置找到:C:\Program Files \ Microsoft &\\Contracts \Documentation\

The Code Contracts documentation provides more information.  It can typically be found under: C:\Program Files\Microsoft\Contracts\Documentation\

- Dave


这篇关于如何删除警告:CodeContracts:assert为false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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