S1172 False positives in Visual Studio

Hi, since a few versions of SonarAnalyzer.CSharp, I experience several false positives on S1172:

I’m not sure if this is the root cause, but the false positive is not raised when I only reference SonarAnalyzer.CSharp nuget package in my csproj. However it started appearing after I added a reference to Microsoft.Bcl.HashCode v1.1.1. I’ve set up a repro repository here: https://github.com/odalet/Sonar-S1172-repro

NB: I also tried to remove the default value of the parameter in the signature, but it didn’t help.

For the record, the screenshot above is in a C#, .NET 4.8 project using VS2022 and SonarAnalyzer.CSharp v8.36.1.44192.

1 Like

I’m seeing this a lot in both VS and Rider.

It seems to go away when I do a full rebuild, but comes back almost immediately when I start editing the file again.

My instances are equally trivial, as in odalet’s example.

C# .NET 6.0
SonarAnalyzer.CSharp v8.36.1.44192

1 Like

Hi @odalet and @MartinSGill,

Thanks for letting us know about the problem and for all the details. We do have a reported issue on our GitHub repository and you can follow the progress here: S1172 flags used parameters on private method as unused · Issue #5491 · SonarSource/sonar-dotnet · GitHub

2 Likes