Back in December 2017, I wrote about starting to use NDepend for static analysis. It’s a fantastic tool and I’ve been using it for the ConTabs project pretty religiously. One of the few detractors when I originally wrote about NDepend was the fact that it could only consume coverage data from non-free tools. Well, I’m very pleased to write that this is no longer the case!

The problem

Knowing how much of your code is covered by automated tests is a really useful metric if you’re interested in stability and maintainability. I’ve written before about how I use OpenCover and Coveralls to continuously monitor the test coverage of the ConTabs project.

Given the focus of NDepend on understanding technical debt, it is only natural that it can incorporate test coverage data into its analyses. The problem I had was that it could only consume coverage files from NCover, DotCover, or Visual Studio Enterprise – all commercial, non-free products. As a cheapskate open-source developer, I couldn’t justify shelling out for any of these, so had to accept that my coverage data was going to exist outside of NDepend.

My search for a solution

Regular readers of this blog will know that I’m not the type to roll over and accept defeat without a bit of a fight.

My next port of call was Stackoverflow, where I asked if there was any way to convert OpenCover files to one of the supported formats. The only answer I got at the time suggested using an XSLT transform to convert it into something compatible with the NCover format. Sadly, this was a dead end.

My next move was to try to write a console utility that would do the same job in a slightly more sophisticated manner. Reverse engineering a tool is really difficult without access to samples of its output, so I managed to beg and borrow a couple of NCover files from projects I was also able to run through OpenCover. I spend a few evenings working on this back in January 2018 before I realised how tricky it was going to be.

Having eventually conceded defeat, I was delighted to hear from Patrick at NDepend in October. He told me that OpenCover support was coming and sent me a beta version to test. I’ve been itching to talk about it ever since but had to keep it under wraps until the official release.

It’s official!

As of version 2019.1, NDepend officially supports OpenCover files as a source of coverage data.

NDepend v2019.1 has been released with support for VisualStudio solution analysis, support for OpenCover and VS coverage binary format, 9 new security rule and more https://t.co/5cjhEHJgqz #ndepend #opencover #visualstudio #2019 pic.twitter.com/SEiPmza2Ha — ndepend (@ndepend) January 31, 2019

It’s super easy to configure too. Really just a case of pointing NDepend at the correct file. The only gotcha I encountered was around my use of OpenCover’s -excludebyattribute option, but this was easy enough to resolve.

I have to say, the addition of coverage data in NDepend makes a big difference. It’s great to see the overall estimate of technical debt take testing into account. I’m sure this addition will prove invaluable to people who aren’t paying for their coverage tooling. Maybe it would even tip the economic balance for people evaluating NDepend too?

Through all of this, credit has to be given to Patrick at NDepend for being so engaged with the community. It’s great that the NDepend roadmap puts such an emphasis on feedback from users. Thanks Patrick!

Finally, I guess I throw this over to you, dear reader… Do you use OpenCover for your coverage analysis? Have you given NDepend a shot? If not, now might be a great time to take advantage of the 14-day free trial.

If you do try OpenCover and NDepend (or perhaps you already have), please let me know how you get on in the comments below!