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


I’m using SonarLint for Visual Studio (v 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).


1 Like