我无法重现您面临的问题。我创建了一个ConsoleApplication (C#)
并使用了默认代码。然后我选择了所有问题,右键单击并Suppress in Suppression File。我尝试重建、清理、重新启动 VS 并且不再出现警告。
程序.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication14
{
class Program
{
static void Main(string[] args)
{
}
}
}
全局抑制.cs
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Sonar Code Smell", "S1172:Unused method parameters should be removed", Justification = "<Pending>", Scope = "member", Target = "~M:ConsoleApplication14.Program.Main(System.String[])")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Sonar Code Smell", "S1186:Methods should not be empty", Justification = "<Pending>", Scope = "member", Target = "~M:ConsoleApplication14.Program.Main(System.String[])")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Sonar Code Smell", "S1118:Utility classes should not have public constructors", Justification = "<Pending>", Scope = "type", Target = "~T:ConsoleApplication14.Program")]
我正在使用最新的 SonarLint 版本 (2.9.0.384)。您能否创建一个简单的复制案例,以便我可以使用它来了解发生了什么?