且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C#:任何方式压制类似抑制警告消息编译器错误?

更新时间:2022-12-22 16:30:25

有没有办法抑制,而不是修复它以外的错误。

There is no way to suppress an error other than to fix it.

这是错误,由于其性质,则指示该编译器相信它不能产生有效代码。压制错误的唯一方法是解决这些问题。只需添加收益语句就是了,然后提高对 Microsoft连接问题表明您认为编译器得到这一个错误。

An error, by its nature, is indicating that the compiler believes it cannot generate valid code. The only way to suppress errors is to fix them. Just add the return statement it wants and then raise an issue on Microsoft Connect indicating that you believe the compiler is getting this one wrong.

我怀疑,但是,这是正常现象,因为编译器不知道该方法您呼叫总会抛出,并确定在可预​​见的方式对任何可能调用树将是困难的,甚至是不可能的(想象一下,如果你用一个扔结束之前调用的20个方法链)。

I suspect, however, that this is expected behaviour as the compiler is not aware that the method you are calling will always throw and to determine that in a predictable manner for any possible call tree would be difficult, if not impossible (imagine if you called a chain of 20 methods before concluding with a throw).