Description
Consider a class, e.g.
class MyClass
{
public int MyValue { get; set; }
}
The property would be excluded because it's getter/setter has the CompilerGeneratedAttribute set. Now consider this class:
class MyClass
{
public int MyValue { get; set; } = 42;
}
The line is included in coverage. I think this is because in the IL code, the initializers are actually part of the constructor. While this may be a sensible default even if explicitly opting out of compiler generated code, there should be an option to exclude initializers from coverage analysis.
The use case for this is when you have large model objects that contain code that you actually want coverage on, but also contains lots of pure data members.
Suggestion is to include an option, e.g. ExcludeInitializers
, that ignores all initializers from coverage.
I saw e.g. issue #316, but I would argue something more specific than an arbitrary "IgnoreTrivial" is more suitable.