我正在开发一个使用 Telerik RadControls 的 Windows 窗体项目,包括 RadGridView
.有问题的控件会自动创建一个 RadGridView
实例名为 MasterTemplate
作为类(class)成员,以及我命名的成员,由于其内部工作方式。
这会导致 Visual Studio 为每个 RadGridView
发出“该字段 [...] 从未使用过”警告。在整个项目中,其中有很多。
.designer.cs
文件是没有意义的,因为它会由设计者自己编辑。 是否可以以任何方式告诉 Visual Studio“永远不要再用有关此变量的警告来打扰我,但请继续告诉我其他警告”?
最佳答案
来自 Microsoft 的 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.
根据此文档,至少早在 就可以使用抑制显示指定警告的功能。 Visual Studio 2015 .我可以确认此指南在 Visual Studio 2017 中对我有用。此外,我发现在分号之后(如果您愿意,也可以在之前)使用空格。例如:
CS1587; CS1591
最后,链接的文档表明还可以抑制以下警告:关于winforms - 在 Visual Studio 中隐藏警告的特定实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31454055/