winformsvisual-studiotelerikwarningsvisual-studio-2008-sp1

Hide a specific instance of a warning in Visual Studio?


I am working on a Windows Forms project that uses Telerik RadControls, including the RadGridView. The control in question automatically creates a RadGridView instance named MasterTemplate as a class member, as well as the one I named, due to the way it works internally.

This causes Visual Studio to give me a "The field [...] is never used" warning for each RadGridView in the entire project, of which there are many.

Is it in any way possible to tell Visual Studio to "never bother me with this warning about this variable again, but do keep telling me about other warnings"?


Solution

  • From Microsoft's documentation for Visual Studio, How to: Suppress compiler warnings:

    Suppress specific warnings for Visual C# or F# 

    Use the Build property page to suppress specific warnings for C# and F# projects.

    1. In Solution Explorer, choose the project in which you want to suppress warnings.

    2. On the menu bar, choose View > Property Pages.

    3. Choose the Build page.

    4. In the Suppress warnings box, specify the error codes of the warnings that you want to suppress, separated by semicolons.

    5. Rebuild the solution.

    According to this documentation, the ability to suppress the display of specified warnings was made available at least as far back as Visual Studio 2015. I can confirm that this guidance is working for me in Visual Studio 2017. Also, I have found that whitespace is permitted after the semicolon (and before as well, if you like). For example:

    CS1587; CS1591
    

    Finally, the linked documentation indicates that warnings can also be suppressed for the following: