-
Notifications
You must be signed in to change notification settings - Fork 392
Closed
Labels
bugSomething isn't workingSomething isn't workingtenet-coverageIssue related to possible incorrect coverageIssue related to possible incorrect coverage
Description
Noticed that when trying to apply the excludeFromCoverage attribute to getters and setters from a
class property, they are not taken into account
public class Key
{
[ExcludeFromCodeCoverage]
public int Id { get; set; }
public Guid Uuid { get; set; }
public Guid Kid { get; set; }
}
"/build/src/Keys.Data/Entities/Key.cs": {
"Keys.Data.Entities.Key": {
"System.Int32 Keys.Data.Entities.Key::get_Id()": {
"Lines": {
"10": 0
},
This can easily be seen in action in existing tests within coverlet. In InstrumenterTests.cs, in the TestInstrument_ClassesWithExcludeAttributeAreExcluded
Just remove the [ExcludeFromCodeCoverage] attribute from one of the classes that this method uses in Samples.cs and add a property like this Id one.
For example in Samples.cs change this class as follows:
public class ClassExcludedByCoverletCodeCoverageAttr
{
public string Method(string input)
{
if(string.IsNullOrEmpty(input))
throw new ArgumentException("Cannot be empty", nameof(input));
return input;
}
[ExcludeFromCodeCoverage]
public int Id { get; set; }
}
Then you will that in method InstrumentType from Instrumenter.cs the attributes don't show up, because the method name is changed to get_Id() (autogenerated) and so it gets instrumented anyway.
Can we fix this somehow?
consultwithmike and StingyJack
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtenet-coverageIssue related to possible incorrect coverageIssue related to possible incorrect coverage