Skip to content

[ExcludeFromCodeCoverage] lets through lambdas, yield return and await #129

@SteveGilham

Description

@SteveGilham

This code

    public class Class1
    {
        [ExcludeFromCodeCoverage]
        public int F1(string input)
        {
            Func<char, int> f = (c => { return (int)c; });

            return input.Select(x =>
            {
                var l = new List<char> { x };
                return l.Select(f).Last();
            }).Sum();
        }

        [ExcludeFromCodeCoverage]
        public IEnumerable<int> F2(string input)
        {
            foreach (char c in input)
            {
                yield return c;
            }
        }

        [ExcludeFromCodeCoverage]
        public async Task<string> F3(string input)
        {
            var f = new StreamReader(File.OpenRead(input));
            var r = await f.ReadToEndAsync();
            return r;
        }

        public static string F4(string input)
        {
            return input.ToUpperInvariant();
        }

        [ExcludeFromCodeCoverage]
        public string F5(string input)
        {
            return input.ToUpperInvariant();
        }
    }

with a test to exercise method F4.

Expect just method F4 in the coverage file, with 100% coverage
Get 15.8% line coverage, with the lambda expressions in F1 and generated MoveNext methods in the implementations of F2 and F3 showing uncovered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtenet-coverageIssue related to possible incorrect coverage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions