Opencover exclude by attibute syntax

Hi.

In my OpenCover Action I added a filter like this
ExcludeFromCodeCoverage
which - to my knowledge properly excludes parts of code where this attribute
[ExcludeFromCodeCoverage]
has been set.

Now we also use CodeContracts, which adds an attribute like this
[ContractClassFor(typeof(IToneTest))]

but if I add this line
ContractClassFor

to the filter dialog, I do not see the expected change in coverage.

So my question is; if “ContractClassFor” is the correct syntax for excluding attributes like “[ContractClassFor(typeof(IToneTest))]” ?

Best regards





Hi Jens,

The syntax seems to be correct according to the OpenCover documentation. Continua CI just sends the parameters you supply to OpenCover.Console.exe - you can see the full command line in the build log.

I created a dummy project to test this and although I can get OpenCover to skip several different attributes, I cannot get it to skip the ContractClassFor attribute.

I’m not sure why this is. There seems to be a bug or oddity with the way that OpenCover excludes attributes. You will need to open an issue with OpenCover providing them with the command line parameters from the build log and your class details.