coverlet icon indicating copy to clipboard operation
coverlet copied to clipboard

[F#]ExcludeFromCodeCoverage Attributes on nested types may not be honoured

Open SteveGilham opened this issue 7 years ago • 2 comments

In F# code like this (which itself is an attempt to work around issue #76)

namespace MyNamespace

module MyModule =
 [<System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage>]
 type internal AlgebraicType =
  | First
  | Second
  | Third

the attribute has no effect, as the type is nested inside a module (= static class ).

There is a work-around in the form of moving the annotated type outside the module. This lets the attribute have effect at the cost of polluting the containing namespace with the intended-to-be-module-local type.

SteveGilham avatar Jul 19 '18 17:07 SteveGilham

Having the same issue with private nested classes in C#. For example we have some DebuggerTypeProxy related classes that we annotate with ExcludeFromCodeCoverage, but it is not actually excluded. Moving to a non-nested class (and polluting the namespace) does correct the issue.

pinkfloydx33 avatar Feb 13 '20 11:02 pinkfloydx33

Having the same issue with private nested classes in C#. For example we have some DebuggerTypeProxy related classes that we annotate with ExcludeFromCodeCoverage, but it is not actually excluded. Moving to a non-nested class (and polluting the namespace) does correct the issue.

This should be fixed on master dup of https://github.com/tonerdo/coverlet/issues/724 Can you try with nightly https://github.com/tonerdo/coverlet/blob/master/Documentation/ConsumeNightlyBuild.md?

MarcoRossignoli avatar Feb 13 '20 11:02 MarcoRossignoli

The issue might be out-dated because new releases are available.

Please reopen the issue if the bug still exists and can be reproduced with latest preview from coverlet nightly build.

see Consume nightly build

Bertk avatar Jan 22 '24 08:01 Bertk