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

6

38

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?

Hanser answered 13/6, 2013 at 13:25 Comment(1)
Does this help at all? Supress warnings VS2012Cabdriver
H
23

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).

Heredia answered 13/6, 2013 at 13:34 Comment(2)
make sure to drop the CS prefix, e.g. use 1591 over CS1591Allyn
In VisualStudio 2019 the suppression works both ways: WITH prefix and WITHOUT prefix. So, you can specify "CS2000, CS2001" as well as "2000, 2001"Alston
H
41

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

enter image description here

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

Hubbub answered 13/6, 2013 at 13:32 Comment(1)
In my question I explicitly ask for how to disable warnings at the project level. This answer does not seem to apply.Hanser
H
23

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).

Heredia answered 13/6, 2013 at 13:34 Comment(2)
make sure to drop the CS prefix, e.g. use 1591 over CS1591Allyn
In VisualStudio 2019 the suppression works both ways: WITH prefix and WITHOUT prefix. So, you can specify "CS2000, CS2001" as well as "2000, 2001"Alston
I
23

Just add NoWarn block in the csproj:

<PropertyGroup>
 <NoWarn>1998;1999</NoWarn>
</PropertyGroup>
Inviting answered 9/11, 2020 at 12:26 Comment(0)
Y
4

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.

Yuki answered 13/6, 2013 at 13:34 Comment(0)
P
2

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

Pacesetter answered 13/6, 2013 at 13:33 Comment(0)
C
1

Try adding _ALLOW_KEYWORD_MACROS to Current Property Pages, Your Project, C/C++, Preprocessor, Preprocessor Definitions

Charnel answered 20/7, 2020 at 3:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.