Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExcludeFromCodeCoverage for interface with default implementations #143

Open
rpgrca opened this issue Nov 18, 2024 · 0 comments
Open

ExcludeFromCodeCoverage for interface with default implementations #143

rpgrca opened this issue Nov 18, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@rpgrca
Copy link

rpgrca commented Nov 18, 2024

Currently the ExcludeFromCodeCoverage attribute can only be placed on classes, constructors, methods, structs, properties, events and assemblies. However, now that C# 8.0 introduced interfaces with default implementations it could be useful to be able to be able to use the attribute on these as well.

As an example, in the visitor pattern I'm using an interface with default implementation so that visitors don't have to override every method:

public interface IVisitor
{
    void Visit(FullName fullName) => throw new NotImplementedException();
    void Visit(Address address) => throw new NotImplementedException();
    void Visit(PhoneInfo phoneInfo) => throw new NotImplementedException();
}

Since testing these concrete methods (in my case) is not necessary, I would like to tag the interface with the ExcludeFromCodeCoverage attribute which is currently not possible. While I've got a few workarounds (adding the ExcludeFromCodeCoverage attribute to every single method declaration in the interface or using an abstract class and tagging the class itself) it might be worth letting the attribute be placed directly on interfaces.

@fhnaseer fhnaseer added the enhancement New feature or request label Nov 18, 2024
@fhnaseer fhnaseer self-assigned this Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants