Skip to content

Bug with nested types filtering #689

@SteveGilham

Description

@SteveGilham

In upgrading to collector v1.2 from v1.1 I noticed that code like

module Whatever =
...
  do AppDomain.CurrentDomain.DomainUnload.Add(FlushCounter DomainUnload)
     AppDomain.CurrentDomain.ProcessExit.Add(FlushCounter ProcessExit)

started registering as uncovered. I'm assuming that this is part of the lambda aliasing change in PR #583, and it's triggering because each line compiles to a form with 4 extra classes, and one of those has an unattributed Invoke() method that executes only when the event is actually fired.

Proceeding to exclude this not readily testable behaviour by refactoring to

module Whatever =
...
  module private Uncoverlet =
    let AddDomainHandlers() =
      AppDomain.CurrentDomain.DomainUnload.Add(FlushCounter DomainUnload)
      AppDomain.CurrentDomain.ProcessExit.Add(FlushCounter ProcessExit)
...
  do Uncoverlet.AddDomainHandlers()

and adding an exclude entry [*]*Uncoverlet resulted in the uncovered line count from ReportGenerator via OpenCover format dropping by 2, as intended.

Looking at the coverage report, however, showed that rather than being excluded from consideration, the AddDomainHandlers method was showing as covered.

There seem to be two problems here. First, exclude by type name doesn't seem to be honoured for nested types, and second, the new behaviour of detecting multiple items on a line doesn't seem to have propagated down this extra level either.

I haven't explicitly tried the C# equivalent

static class Whatever {
  static class Uncoverlet {
    ...
  }
}

but the IL in each case will be the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtenet-coverageIssue related to possible incorrect coverage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions