Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically convert coverage file to coveragexml

I am using Visual Studio to find code coverage. I have generated .coverage file and I can open it in Visual Studio. I want to convert it into .coveragexml file. I am using CoverageInfo, CoverageDS classes. Here is the code I am trying:

CoverageInfo info = CoverageInfo.CreateFromFile(coverageFilePath, binaryPath,symbolPath);
CoverageDS dataSet = info.BuildDataSet();
dataSet.WriteXml(outfile);

Since the coverage file is large, the call to info.BuildDataSet gives out of memory exception. Is there any alternate way to get the coveragexml?

I referred to the MSDN blog http://blogs.msdn.com/b/phuene/archive/2009/12/01/programmatic-coverage-analysis-in-visual-studio-2010.aspx which also mentions this case. This article mentions about using ICoverageModule interface to get module by module information from the CoverageInfo class. But how do I convert this module information into XML? The blog shows an example of how the module information can be parsed and printed. But I am looking for converting this into coveragexml file.

like image 275
nilesh Avatar asked Apr 21 '26 06:04

nilesh


1 Answers

I was running into the same System.OutOfMemoryException when calling CoverageInfo.BuildDataSet(...). To work around the problem I changed the project to build as a 64 bit application which enables the process to use much much more memory. You will also need to reference the 64 bit versions of:

  • Microsoft.VisualStudio.Coverage.Analysis.dll
  • Microsoft.VisualStudio.Coverage.Interop.dll

You can find these on a system that has TFS installed. Look in C:\Program Files\Microsoft Team Foundation Server XX.0\Application Tier\TFSJobAgent\Plugins.

like image 99
James Wulkan Avatar answered Apr 23 '26 21:04

James Wulkan