#pragma warning

  • Thread starter Thread starter Nick Butler
  • Start date Start date
N

Nick Butler

In C++ there is a very useful function to programatically disable warnings
temporarily.

Can this be done in C# ?
 
Yes, in VS.NET under project properties-->Configuration Properties-->Build
you can change the warning level and/or list specific warnings to be
ignored. In the command-line use the /warn: and /nowarn: switches to
specify.

Richard
 
I guess in that case I should have said: "No, not programmatically, but..."

Mea Culpa,
Richard
 
Hi Nick,

Thank you for posting in the community! My name is Jeffrey, and I will be
assisting you on this issue.

Based on my understanding, you want to find the #pargma diretives
alternative in C#.
=================================================
In C#, there are many directives you can specify in your code, you can find
these directives in C# language specification, please refer to Philip's
reply.

For your concern of #pargma warnning directive, I think you need the
"#warning directives", please refer to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/
vclrfwarning.asp

=================================================
Please apply my suggestion above and let me know if it meets your need.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Nick,

Thanks for your feedback.

Oh,sorry, I think I provide the wrong #pragma warning alternative to you.
Let me correct it.

===========================================
To control the warning level in C#, you can use 2 compile options to get
this done: /warn and /nowarn
/warn gives you 5 level warning control on code, while /nowarn option
allows you to suppress A warning number.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cscomp/html
/vcrefwwarninglevel.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cscomp/html
/vcerrNowarnSuppressSpecifiedWarnings.asp

Visual Studio.Net does not expose the function of specifying these 2
options in C# code. But it allows you to specify through IDE macro with
property WarningLevel and NoWarn, for more information, please refer to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vbgrfnowarnproperty.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vxlrfvslangprojprojectconfigurationpropertieswarninglevel.asp

So you can not get this done directly through your C# code in Visual
Studio.Net 2003.
============================================
If you have any further concern, please feel free to tell me.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top