S3220: False positive with overloads having Action and Func as parameter

Hi,

I’m using SonarLint for Visual Studio (v 4.7.0.3891) and I’m facing a false positive about S3220.

    class Program
    {
        static void Main(string[] args)
        {
            M1(() => Console.WriteLine("hi"));
        }

        public static void M1(params Action[] a) { /* */ }
        public static void M1<T>(Func<T> f) { /* */ }
        public static void M1(Func<Task> f) { /* */ }
    }

The call M1(() => Console.WriteLine("hi")); is flagged with S3220 and says:

S3220|Review this call, which partially matches an overload without 'params'. The partial match is 'void Program.M1<T>(Func<T> f)'

Action and Func do have different semantics (returning nothing and returning a value), so in my opinion there should be no issue, because the lambda doesn’t return anything.

Hi @MarkusAmshove,

Thanks for the feedback! I have managed to reproduce the issue and so I have created a ticket in our backlog to fix it (see here).

Cheers,
Amaury

1 Like