coverlet: InstrumentationHelper.HasPdb always returns false for deterministic source paths

When /p:DeterministicSourcePaths=true is set, InstrumentationHelper.HasPdb looks for PDB files in the wrong location. These files are never found, so instrumentation is not performed.

https://github.com/tonerdo/coverlet/blob/062b907735901bdf3ad9d4d40953f53a4fe3f364/src/coverlet.core/Helpers/InstrumentationHelper.cs#L74

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 43 (17 by maintainers)

Commits related to this issue

Most upvoted comments

I’m not sure about it…at the moment we have 3 drivers(.net tool,msbuild,collectors) and not all version supports all features, have single version could confuse users.

FWIW, I think it could be okay to keep drivers at the same version long as what’s in each is documented somewhere. If they all tend to rely on an underlying core library, then that could be what drives the main version. Totally up to you though of course.

Plan

Proposal:

  1. Short term: Only coverlet.collector or coverlet.msbuild will support DeterministicSourcePaths. It can do so by adding a target that writes the PathMap’s to the output directory alongside the target dll’s. This target may need to be added at the Directory Props level to work, next to the Source Link reference.
  2. Better: SourceLink / the SDK writes this out built-in.

In both cases, build tools that need to read this data can open the PathMap file and do the translation needed.

Thoughts?

@MarcoRossignoli Here’s a repro case:

  1. Check out dotnet/roslyn-analyzers#3028
  2. Build with .\Build.cmd -rebuild /p:DeterministicSourcePaths=true
  3. Test with .\Test.cmd /p:Coverage=True

Expected results:

Coverage files in artifacts\coverage have coverage information.

Actual results:

Coverage files are empty.

Additionally, it should have a try … catch block, because peReader.ReadDebugDirectory() can fail.

Part of this fixed in https://github.com/tonerdo/coverlet/pull/367/files