-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
With interfaces now having the ability to have default implementations members, they can now contain code, which can show up on a code coverage report. The AttributeUsage attribute on ExcludeFromCodeCoverageAttribute does not specify AttributeTargets.Interface so applying the attribute to an interface will cause a compiler error.
Reproduction Steps
Try to compile the following code:
[ExcludeFromCodeCoverage]
public interface ILogger
{
void Log(string message);
// Default interface method (C# 8+)
void LogWarning(string message)
=> Log($"[WARN] {message}");
}Expected behavior
The provided sample code to be compiled without error.
Actual behavior
You will get a compilation error as ExcludeFromCodeCoverageAttribute can't be applied to an interface.
Regression?
No regression
Known Workarounds
I would expect applying the attribute to the individual method implementations would work.
Configuration
All versions of .NET, any OS, any architecture.
Other information
Missing AttributeTargets.Interface on the AttributeUsage attribute of ExcludeFromCodeCoverageAttribute.