PVS Studio Suppress Single Warning For Entire C# File

328 Views Asked by At

I am trying to suppress a warning for an entire C# file using syntax found at https://www.viva64.com/en/m/0017/.

According to the documentation //-V::3085 at the beginning of a file should suppress all V3085 warnings in the file.

Using the following code I still see the warning. What am I doing wrong?

//-V::3085
namespace ClassLibrary
{
    public class Class
    {
        public static string Property => null;

        public sealed class InnerClass
        {
            public string[] Property { get; set; }
        }
    }
}
1

There are 1 best solutions below

0
Paul Eremeeff On

According to the documentation //-V::3085 at the beginning of a file should suppress all V3085 warnings in the file.

This syntax works for compilation units, not for single files, and it works as a comment in source file in C++ only - for C# you need to add a pvsconfig file (described in the link you've provided above) to your project, and add this line there - this will disable the warning for the whole project (as, in C#, the whole project is a single compilation unit).