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.
.designer.cs
file is pointless as it would be edited by the designer itself.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"?
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.
In Solution Explorer, choose the project in which you want to suppress warnings.
On the menu bar, choose View > Property Pages.
Choose the Build page.
In the Suppress warnings box, specify the error codes of the warnings that you want to suppress, separated by semicolons.
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: