danielpalme / ReportGenerator

ReportGenerator converts coverage reports generated by coverlet, OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.
https://reportgenerator.io
Apache License 2.0
2.61k stars 283 forks source link

How to exclude certain namespaces? #23

Closed Tdue21 closed 9 years ago

Tdue21 commented 9 years ago

I have read through the document of both OpenCover and ReportGenerator, and no matter what I do I cannot get ReportGenerator to exclude a certain namespace from the reports.

I am using ReSharper and one of the things this excellent tool offers, is to add a file called Annotations.cs which helps with code analysis and so on. However, there are a lot of micro classes in this namespace, and I would really like to to exclude this namespace. How do I do that?

danielpalme commented 9 years ago

Sorry that's not possible with ReportGenerator. You can only ignore complete assemblies. You could create a custom attribute (see this sample: https://github.com/danielpalme/ReportGenerator/blob/master/ReportGenerator.Testprojects/CSharp/Project/CoverageExcludeAttribute.cs) and use the "-excludebyattribute:*.CoverageExclude*" switch of OpenCover

tctrivedi commented 4 years ago

Sorry that's not possible with ReportGenerator. You can only ignore complete assemblies. You could create a custom attribute (see this sample: https://github.com/danielpalme/ReportGenerator/blob/master/ReportGenerator.Testprojects/CSharp/Project/CoverageExcludeAttribute.cs) and use the "-excludebyattribute:*.CoverageExclude*" switch of OpenCover

Hello Daniel,

Since this reply is old, I would like to check if this is still not possible or there is any solution/workaround to include/exclude specific namespace

danielpalme commented 4 years ago

I'm sorry, there is not filter option for namespaces.

gpeipman commented 1 year ago

For ASP.NET Core it would be very useful as views are compiled to same assembly with web project code. Example on image below. Check the first lines starting with AspNetCoreGeneratedDocument.

aspnet-core-coverage
danielpalme commented 1 year ago

@gpeipman The following command line argument should help in your case to exclude the views: -classfilters:-AspNetCoreGeneratedDocument.Views__*