Exclude AnonymousType Classes and Private Methods

Exclude AnonymousType Classes and Private Methods

The goal of the project is to show coverage for classes & methods related to only my project. No external dlls cover. For example, there is a class A and methodA(), then if the methodA() is unit tested, then coverage should show 100% coverage.

However, we are struggling to get 100% coverage to show. Can you please help ?

1 The NCover includes AnonymousType class and this highly impacts the coverage report.

"-.<>fAnonymousType03" "-.&lt;&gt;f__AnonymousType13" "-.<>fAnonymousType2`2"

So, we tried to use filters a) Exclude Types b) Exclude Methods

//et "-;-.;"

It does not exlude these classes at all.

2 The NCover includes Private methods into coverage report and private methods are generally not unit testable.

But we found, we can exclude with some attribute like this, in .NET 4.0

using System.Diagnostics.CodeAnalysis; [ExcludeFromCodeCoverage] private class MyClass { ...

However, is there a way in NCover filter or reporting options to exclude PRIVATE methods


RE: Exclude AnonymousType Classes and Private Methods

You can exclude anonymous types if you decode the naming convention and build rules accordingly. Svenkatesh1 found a regex that worked for him, so I'm posting here as an example:

//et ".AnonymousType."

Unfortunately, the NCover profiler sees no difference between public and private methods when they are compiled, so there's no way to filter them automatically.

NCover Support