C# S1172 - Parameters not recognized in value tuples

SonarLint 4.19.0.15817 doesn’t seem to recognize when a parameter is added to a value tuple, e.g.:

using System;

namespace SonarLintTest
{
    static class Program
    {
        static void Main()
        {
            Test("abc");
        }

        private static void Test(string value)
        {
            var x = (value, 7);
            Console.WriteLine(x.value);
        }
    }
}

reports an S1172 error suggesting the parameter value is ignored

Hello Miroslav,

I can’t reproduce the issue with SonarLint 4.19 (therefore with Sonar SonarC# 8.4 analyzer).

Do you have a standalone SonarLint or do you use it in Connected Mode with SonarQube? We did some changes in 8.3 release of SonarC# related to this rule. If you have a SonarQube, you can try to update SonarC# plugin on SQ side.

Hello Pavel,

Thanks for the quick reply.

I have a SonarQube container downloaded, but don’t have it connected with VS at the moment. This was an Intelisense warning which disappears immediately if I reference the parameter directly - so I would say it is the Roslyn based SonarLint.
image
The version is the latest one available through the extensions manager.

Both SonarLint and SonarQube uses SonarC# Roslyn based analyzer. Even having the latest SonarLint with SonarC# 8.4 analyzer, you can have older SonarC# plugin from SQ raising this issue in Visual Studio.

That would explain why you can see this issue (reported by older version of plugin) and I can’t (having empty project with no SQ). Can you try to isolate this procedure to new small project? Without any link to SQ? Just to see if it’s still there.

What version of SonarC# do you have in your SQ server?
Can you update it?

I started using Sonar only a week ago and I also never run SonarQube on this test project. That was actually the reason why this small console app was created - I saw the problem first in a much more complex project, but I din’t have a completely clean case as I was experimenting with SQ there.

I have now checked SonarAnalyzer.CSharp.dll in the VS Extensions folder and the version reported is 8.4.0.15306

Hi,

I need to correct my previous statement: SQ plugin does not override SonarLint embedded version. It’s manual NuGet reference to the analyzer that can do so.

I’m not sure why I couldn’t reproduce it with SL, but I was able to reproduce it on current development version of the analyzer. I’ve created this issue to track it.

Thank you for reporting this.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.