|  | 
| 1 |  | -using System; | 
| 2 |  | -using Coverlet.Core; | 
| 3 |  | -using Microsoft.Build.Framework; | 
| 4 |  | -using Microsoft.Build.Utilities; | 
| 5 |  | - | 
| 6 |  | -namespace Coverlet.MSbuild.Tasks | 
| 7 |  | -{ | 
| 8 |  | -    public class InstrumentationTask : Task | 
| 9 |  | -    { | 
| 10 |  | -        private static Coverage _coverage; | 
| 11 |  | -        private string _path; | 
| 12 |  | -        private string _filter; | 
| 13 |  | -        private string _exclude; | 
| 14 |  | - | 
| 15 |  | -        internal static Coverage Coverage | 
| 16 |  | -        { | 
| 17 |  | -            get { return _coverage; } | 
| 18 |  | -        } | 
| 19 |  | - | 
| 20 |  | -        [Required] | 
| 21 |  | -        public string Path | 
| 22 |  | -        { | 
| 23 |  | -            get { return _path; } | 
| 24 |  | -            set { _path = value; } | 
| 25 |  | -        } | 
| 26 |  | -         | 
| 27 |  | -        public string Filter | 
| 28 |  | -        { | 
| 29 |  | -            get { return _filter; } | 
| 30 |  | -            set { _filter = value; } | 
| 31 |  | -        } | 
| 32 |  | - | 
| 33 |  | -        public string Exclude | 
| 34 |  | -        { | 
| 35 |  | -            get { return _exclude; } | 
| 36 |  | -            set { _exclude = value; } | 
| 37 |  | -        } | 
| 38 |  | - | 
| 39 |  | -        public override bool Execute() | 
| 40 |  | -        { | 
| 41 |  | -            try | 
| 42 |  | -            { | 
| 43 |  | -                var excludes = _exclude?.Split(','); | 
| 44 |  | -                var filters = _filter?.Split(','); | 
| 45 |  | - | 
| 46 |  | -                _coverage = new Coverage(_path, Guid.NewGuid().ToString(), filters, excludes); | 
| 47 |  | -                _coverage.PrepareModules(); | 
| 48 |  | -            } | 
| 49 |  | -            catch (Exception ex) | 
| 50 |  | -            { | 
| 51 |  | -                Log.LogErrorFromException(ex); | 
| 52 |  | -                return false; | 
| 53 |  | -            } | 
| 54 |  | - | 
| 55 |  | -            return true; | 
| 56 |  | -        } | 
| 57 |  | -    } | 
| 58 |  | -} | 
|  | 1 | +using System; | 
|  | 2 | +using Coverlet.Core; | 
|  | 3 | +using Microsoft.Build.Framework; | 
|  | 4 | +using Microsoft.Build.Utilities; | 
|  | 5 | + | 
|  | 6 | +namespace Coverlet.MSbuild.Tasks | 
|  | 7 | +{ | 
|  | 8 | +    public class InstrumentationTask : Task | 
|  | 9 | +    { | 
|  | 10 | +        private static Coverage _coverage; | 
|  | 11 | +        private string _path; | 
|  | 12 | +        private string _filter; | 
|  | 13 | +        private string _excludeByFile; | 
|  | 14 | + | 
|  | 15 | +        internal static Coverage Coverage | 
|  | 16 | +        { | 
|  | 17 | +            get { return _coverage; } | 
|  | 18 | +        } | 
|  | 19 | + | 
|  | 20 | +        [Required] | 
|  | 21 | +        public string Path | 
|  | 22 | +        { | 
|  | 23 | +            get { return _path; } | 
|  | 24 | +            set { _path = value; } | 
|  | 25 | +        } | 
|  | 26 | +         | 
|  | 27 | +        public string Filter | 
|  | 28 | +        { | 
|  | 29 | +            get { return _filter; } | 
|  | 30 | +            set { _filter = value; } | 
|  | 31 | +        } | 
|  | 32 | + | 
|  | 33 | +        public string ExcludeByFile | 
|  | 34 | +        { | 
|  | 35 | +            get { return _excludeByFile; } | 
|  | 36 | +            set { _excludeByFile = value; } | 
|  | 37 | +        } | 
|  | 38 | + | 
|  | 39 | +        public override bool Execute() | 
|  | 40 | +        { | 
|  | 41 | +            try | 
|  | 42 | +            { | 
|  | 43 | +                var excludes = _excludeByFile?.Split(','); | 
|  | 44 | +                var filters = _filter?.Split(','); | 
|  | 45 | + | 
|  | 46 | +                _coverage = new Coverage(_path, Guid.NewGuid().ToString(), filters, excludes); | 
|  | 47 | +                _coverage.PrepareModules(); | 
|  | 48 | +            } | 
|  | 49 | +            catch (Exception ex) | 
|  | 50 | +            { | 
|  | 51 | +                Log.LogErrorFromException(ex); | 
|  | 52 | +                return false; | 
|  | 53 | +            } | 
|  | 54 | + | 
|  | 55 | +            return true; | 
|  | 56 | +        } | 
|  | 57 | +    } | 
|  | 58 | +} | 
0 commit comments