Closed
Description
Having the following code:
public class ExcludedLocalFunctionReproduction
{
public void SomethingThatIsUsingALocalFunction()
{
MethodThatTakesALambda(NewMethod());
[ExcludeFromCodeCoverage(Justification = "Not testable")]
static Func<string, bool> NewMethod()
{
return myString => myString.Length == 10;
}
}
private void MethodThatTakesALambda(Func<string, bool> function)
{
// Do something - the actual function is not invoked to show the issue
bool _ = function != null;
}
}
Coverlet reports the line return myString => myString.Length == 10;
as uncovered even though the local method is excluded from code coverage:
I would expect the local function to be shown as excluded.
The full code (along with other reproductions for already reported issues) is here: https://github.com/meggima/coverlet-reproductions