的#pragma警告禁止和放大器;恢复 [英] #pragma warning disable & restore

查看:532
本文介绍了的#pragma警告禁止和放大器;恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用C#创建第一个项目。 我有很多的警告错误,这些错误警告要成为一个错误(内部编译器错误。在控制台中看到日志的详细信息。)

I have used c# to create a First Project. I have many warning errors and all these warning errors are to be single Error(Internal compiler error. See the console log for more information.)

有关降低预警错误,我用的#pragma警告禁止。的#pragma警告恢复 前面的问题code回来了。

For Reducing the warning errors I used #pragma Warning disable . #pragma warning restore front and back of the problematic code.

我有疑问,在我的最终版本,我应该离开那个的#pragma警告,禁止和放大器;恢复,因为它是在程序中;或者我需要删除?例如:

I have doubt that in my final build I should leave that #pragma warning disable & restore as it is in the program; or do I need to remove that? e.g:

#pragma warning disable
if (Displayer.instance != null && CTR.Tore== "Keepit")
{
    Displayer.instance.SetFielderProfile (i);
}
#pragma warning restore

有关最终版本,我需要删除或不?

For final build do I need to remove that or not?

推荐答案

最起码你应该具体说明你故意选择忽略这些警告。这样,如果后期维护引入了一个新的警告/你应该知道的问题,对新引进的错误,警告不会在你的毯子编译警告禁用指令pssed燮$ P $。

At the very least you should be specific about which warnings you've deliberately chosen to ignore. That way, if later maintenance introduces a 'new' warning/issue that you should be made aware of, the warning about the newly-introduced error won't be suppressed by your blanket pragma warning disable directive.

您可以得到属于你决定从Visual Studio中的生成输出窗口忽略的建立问题的警告编号。他们通常标有警告CS0168 ......之类的。在这种情况下,你可以专门针对刚才的那些错误(S)你决定忽略像这样:

You can get the warning numbers pertaining to the build issues you've decided to ignore from the build Output window in Visual Studio. They're usually labelled "Warning CS0168...." or similar. In which case you can specifically target just the those error(s) you've decided to ignore like so:

#pragma warning disable 168, 3021

    //Your code that generates warnings CS0168 and CS3021 here

#pragma warning restore 168, 3021

这篇关于的#pragma警告禁止和放大器;恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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