0
votes

I am doing some modifications on OpenCover and NUnit to suit my needs.

Briefly, I want to get coverage information even when shadow-copy is enabled in Nunit. However, OpenCover is unable to track an assembly when the pdb file is absent. When shadow-copy is enabled in NUnit, the assembly under test is copied to a shadow directory and OpenCover fails to find the corresponding pdf file.

At first, I thought that .Net Runtime just didn't copy pdb files to shadow directory. But After I investigated this problem further, I found out Runtime will copy pdb files but not the same time when assemblies are copied.

My understanding now is that Runtime will first copy assemblies to shadow directories. And then those assemblies will be loaded and Opencover is notified. OpenCover find out that there are no pdb files, so these assemblies are ignored. Sometime later, pdb files are copied, but OpenCover failed to notice this fact thus failed to track these assemblies.

So my question is what is the exact time that .Net Runtime copies pdb files to shadow directories? And is it possible that I modify OpenCover so that it will be able to track these shadow-copied assemblies?

1

1 Answers

0
votes

However, OpenCover is unable to track an assembly when the pdb file is absent.

This is by design as instrumenting every assembly that is loaded without a PDB means instrumenting every IL operation rather than each sequence point, the information of which is in the PDB.

Sometime later, pdb files are copied, but OpenCover failed to notice this fact thus failed to track these assemblies.

If the PDB is copied later then its too late for OpenCover as the runtime has already loaded the assembly so OpenCover made its instrumentation decisions.

Now, OpenCover uses various locations to look for PDBs

  1. it looks in the same folder as the assembly was loaded from
  2. it looks in the folder set by -workingdir
  3. it looks in its current directory

However, to support /noshadow I usually find the -mergebyhash option resolves this if not then I use #2 from the list above the easiest to use