I want to know how to suppress a specific compiler warning within VS Code for the entire project.
I have seen this queston: Is it possible to disable specific compiler warnings? but it is for Visual studio, not Visual Studio Code.
Here are the answers that where recommended in the question linked above:
1. Solution Explorer
> View
> Properties
> Build
> Suppress Warnings
and
2. #pragma warning disable warning-list
For #1: I can't find the Solution Explorer anywhere within VS Code.
For #2 This only works if I include it at the top of each of the scripts. I need a way to do so for the entire Project.
Updates:
I tried using <noWarn>01699,8019</noWarn
> in my .csproj files, but no go.
After reviewing the last changes, I noticed that it had reverted to <noWarn>0169</noWarn>
. I then realised that what I needed was <noWarn>0169;8019</noWarn>
. Switching the ,
for a ;
Solved the problem.
Well, it turns out that the above solution didn't work after all. As soon as I restarted VS Code, all the warnings came back. Maybe the error code I need isn't 8019, even though it worked as the error code within a #pragma
statement. Are the codes used within a <noWarn>
different than the codes used at the end of a #pragma
statement?
For those saying too switch to VS Community, that's not the point. I'm using VS Code AS a text editor with Unity Editor. I'm looking for which file I need to change and what changes need to be made to apply a statement like #pragma warning disable 8019
to the entire project.
Choose Build, and go to the Errors and warnings subsection. In the Suppress warnings or Suppress specific warnings box, specify the error codes of the warnings that you want to suppress, separated by semicolons. For a list and descriptions of warning codes, see C# Compiler Messages. Rebuild the solution.
If you want to turn it on (or off) in the project setting, you have to go to: Configuration Properties -> C/C++ -> Command Line and then under Additional Options you can enter: /w3#### to set your warning to level 3, and thus enable it; or you can enter /wd#### to disable a warning.
To answer your question about disabling specific warnings in GCC, you can enable specific warnings in GCC with -Wxxxx and disable them with -Wno-xxxx. From the GCC Warning Options: You can request many specific warnings with options beginning -W , for example -Wimplicit to request warnings on implicit declarations.
I was able to get this to work. My solution looks something like this:
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion>
<NoWarn>0169;8019</NoWarn>
</PropertyGroup>
<NoWarn>
is PascalCase rather than camelCase, and the element is nested inside of a <PropertyGroup>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With