How can I disable a specific warning for a C# project in VS2012?

倖福魔咒の 提交于 2019-11-28 07:01:44

问题


I am trying to generate partial XML documentation during my build process for a C# project in VS2012. When I check the XML documentation file option in Project->Properties->Build, I get a build warning for each public member that lacks documentation. Since we compile with warnings as errors, this blocks the build.

This question suggests getting past this by disabling certain warnings, but I can't figure out how to do that in VS2012! The MSFT documentation here only goes up to VS2010 and only covers VB. How can I disable these warnings at the project level in C#/VS2012?


回答1:


The warning you're getting has a number (e.g. CS2000), so what you need to do is right-click on the project, go to the Build tab, and add that warning to the Suppress warnings text box. You can subsequently suppress more than one by separating them with a comma (e.g. CS2000,CS2001).




回答2:


For the project level go to Project -> Properties -> Build tab

If you want to disable the warning to some code section, try this :

#pragma warning disable XXX,XXX
            //your code 
#pragma warning restore XXX,XXX

Read about #pragma warning




回答3:


You can open the project properties and enter comma separated warning numbers you want to suppress into the Suppress Warnings textbox on the Build tab.




回答4:


It's in the same place as Visual Studio 2010. In the project properties, on the Build tab, called Suppress warnings.



来源:https://stackoverflow.com/questions/17088244/how-can-i-disable-a-specific-warning-for-a-c-sharp-project-in-vs2012

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!