【发布时间】:2017-12-02 10:57:30
【问题描述】:
在哪里可以找到SuppressMessage 的检查 ID 列表?
下面的代码摘自微软关于SuppressMessageAttribute.CheckId的在线文档。我想知道SuppressMessage 的有效值列表,例如"Microsoft.Performance" 和"CA1804:RemoveUnusedLocals"。
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "isChecked")]
[SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "fileIdentifier")]
static void FileNode(string name, bool isChecked)
{
string fileIdentifier = name;
string fileName = name;
string version = String.Empty;
}
我想取消警告“为方法使用表达式主体”,但我不知道应该为 SuppressMessage 赋予什么值。
代码示例:
namespace MyNameSpace
{
public class MyClass
{
// This code raises a warning "Use expression body for methods".
public string MyMethod()
{
return MyPrivateMethod();
}
// This code raises a warning "Use expression body for methods".
string MyPrivateMethod()
{
return "Hello";
}
// This code raises a warning "Use block body for methods".
public string MyMethod2() => MyPrivateMethod2();
// This code raises a warning "Use block body for methods".
string MyPrivateMethod2() => "Hello";
}
}
在方法名称上移动光标将显示警告。该行为会阻止显示该方法的文档注释(如果有)。
Visual Studio 开发者社区:IDE0022 missmatch to IDE description
【问题讨论】:
-
请向我们展示生成您试图抑制的警告的代码。 minimal reproducible example
-
@mjwills 我添加了一个生成警告的代码示例。
-
@mjwills Visual Studio for Mac(社区),版本 7.2.2(内部版本 11)。将光标移动到方法名称上并显示警告。该行为会阻止显示该方法的文档注释。
标签: c# visual-studio suppress-warnings visual-studio-mac