How can I exclude lambda functions in properties from code coverage?

I'm trying to collect some nice code coverage statistics for my C # application, but I would like to ignore the SubSonic classes I created, since there is no real point in collecting code coverage statistics for these functions.

I edited the ActiveRecord.tt file to include the [ExcludeFromCodeCoverage] attribute for each method and property, and this removed most of the irrelevant results in the code coverage window. However, despite the presence of the code coverage exclusion attribute, lambda expressions inside properties are marked as unclosed. As an example:

[ExcludeFromCodeCoverage]
int GetValue
{
    get
    {
        this.SomeMethod(); // this is excluded
        return this.Find(x => x.Value == this._Value); // this.Find is excluded
                                                       // but x => x.Value == ...
                                                       // is not.
    }
}

This only happens in properties. Lambda expressions are ignored inside methods, as expected.

, , , . , 95%. , , .

ActiveRecord.tt, .

.

+3
2

, , get:

int GetValue
{
    [ExcludeFromCodeCoverage]
    get
    {
        this.SomeMethod();
        return this.Find(x => x.Value == this._Value);
    }
}

, GetValue get_GetValue : int

+1

[ExcludeFromCoverage] . , .

0

Source: https://habr.com/ru/post/1763109/


All Articles