winforms - 在 Visual Studio 中隐藏警告的特定实例?

标签 winforms visual-studio telerik warnings visual-studio-2008-sp1

我正在开发一个使用 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.

    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.


    根据此文档,至少早在 就可以使用抑制显示指定警告的功能。 Visual Studio 2015 .我可以确认此指南在 Visual Studio 2017 中对我有用。此外,我发现在分号之后(如果您愿意,也可以在之前)使用空格。例如:
    CS1587; CS1591
    
    最后,链接的文档表明还可以抑制以下警告:
  • Visual C++
  • Visual Basic
  • NuGet 包
  • 关于winforms - 在 Visual Studio 中隐藏警告的特定实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31454055/

    相关文章:

    .net - 我应该在Windows Forms Chart Control中选择Line还是FastLine?

    vb.net - 滚动到 Datagridview 选定的行

    c++ - Winsock 的 send() 工作异常

    asp.net - 网格选择禁用/不可见

    c# - 如何使用 LINQ 查询嵌入的 XML 文件?

    wpf - 我可以在WinForms中使用WPF控件来实现透明效果吗?

    azure - 重新输入您的凭据 - 无法连接到 Azure

    python - IronPython visual studio 控制台应用程序 : no module named clr

    asp.net - Telerik rad 日期选择器在用户键入 future 日期时显示错误消息

    泰勒瑞克 : How to edit text from footer "Displaying items xx-yy of zz"