-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcode_coverage.cs
More file actions
56 lines (48 loc) · 1.91 KB
/
Copy pathcode_coverage.cs
File metadata and controls
56 lines (48 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.IO;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Microsoft.VisualStudio.CodeCoverage;
namespace codecoverage2xml
{
class Program
{
static void Main(string[] args)
{
// Process Command Line arguments
// No Args means we go boom
if (args.Length == 0) {
Console.WriteLine("Usage is codecoverage.exe $pathtocodecoverage [$optionalxmloutputfilename]");
return;
}
// We must end up with a code coverage file, and an xml file to write
string codecoveragefile = "";
string xmloutputfile = "";
// populate the variables from the arguments
// two variables, one is codecoveragefile, one is xmloutputfile
if (args.Length > 1) {
codecoveragefile = args[0];
xmloutputfile = args[1];
} else {
codecoveragefile = args[0];
xmloutputfile = Regex.Replace(codecoveragefile, "coverage$", "xml");
}
// bail if coverage file does not exist
if (File.Exists(codecoveragefile)) {
Console.WriteLine("Good coverage file, continue");
} else {
Console.WriteLine("{0} Does not exist", codecoveragefile);
return;
}
// Create a coverage info object from the file
CoverageInfoManager.SymPath = codecoveragefile;
CoverageInfoManager.ExePath = codecoveragefile;
CoverageInfo ci = CoverageInfoManager.CreateInfoFromFile(codecoveragefile);
// Ask for the DataSet
// The parameter must be null
CoverageDS data = ci.BuildDataSet(null);
// Write to XML
data.WriteXml(xmloutputfile);
}
}
}