C# S3626 - The "Redundant Jump" warning is raised on exceptions in lambdas

I got the S3626 warning in a case when no jumps were specified, but an exception was thrown in a lambda expression being passed to a function:

private static void TestAction(Action action)
{
    //...
}

private static void DoTest()
{
    TestAction(() => throw new Exception(""));
}

image

This seems to happen regardless of the number of lambda parameters (could be a Func or Action with any number of params).

P.S. While this example might not make much sense, this pattern occurred when trying to identify invalid REST API calls which should raise errors. Even if this is not the best practice, the warning seems to be wrong…

The analyzer version is 8.4.0.15306

Hello Miroslav,

Thank you for reporting this. Similar case was already reported and we have an issue created for that.