-
Notifications
You must be signed in to change notification settings - Fork 386
/
Copy pathInstrumentationTask.cs
109 lines (94 loc) · 2.83 KB
/
InstrumentationTask.cs
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using Coverlet.Core;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Coverlet.MSbuild.Tasks
{
public class InstrumentationTask : Task
{
private static Coverage _coverage;
private string _path;
private string _include;
private string _includeDirectory;
private string _exclude;
private string _excludeByFile;
private string _excludeByAttribute;
private bool _singleHit;
private string _mergeWith;
private bool _useSourceLink;
private readonly MSBuildLogger _logger;
internal static Coverage Coverage
{
get { return _coverage; }
}
[Required]
public string Path
{
get { return _path; }
set { _path = value; }
}
public string Include
{
get { return _include; }
set { _include = value; }
}
public string IncludeDirectory
{
get { return _includeDirectory; }
set { _includeDirectory = value; }
}
public string Exclude
{
get { return _exclude; }
set { _exclude = value; }
}
public string ExcludeByFile
{
get { return _excludeByFile; }
set { _excludeByFile = value; }
}
public string ExcludeByAttribute
{
get { return _excludeByAttribute; }
set { _excludeByAttribute = value; }
}
public bool SingleHit
{
get { return _singleHit; }
set { _singleHit = value; }
}
public string MergeWith
{
get { return _mergeWith; }
set { _mergeWith = value; }
}
public bool UseSourceLink
{
get { return _useSourceLink; }
set { _useSourceLink = value; }
}
public InstrumentationTask()
{
_logger = new MSBuildLogger(Log);
}
public override bool Execute()
{
try
{
var includeFilters = _include?.Split(',');
var includeDirectories = _includeDirectory?.Split(',');
var excludeFilters = _exclude?.Split(',');
var excludedSourceFiles = _excludeByFile?.Split(',');
var excludeAttributes = _excludeByAttribute?.Split(',');
_coverage = new Coverage(_path, includeFilters, includeDirectories, excludeFilters, excludedSourceFiles, excludeAttributes, _singleHit, _mergeWith, _useSourceLink, _logger);
_coverage.PrepareModules();
}
catch (Exception ex)
{
_logger.LogError(ex);
return false;
}
return true;
}
}
}