From 9ed086489eb17f2309eb3ae431ee2a821735ebd7 Mon Sep 17 00:00:00 2001 From: Oluwatoni Solarin-Sodara Date: Sun, 13 May 2018 18:50:31 +0100 Subject: [PATCH] change Filter property to Exclude --- src/coverlet.core/Coverage.cs | 10 +++++----- src/coverlet.core/Helpers/InstrumentationHelper.cs | 6 +++--- src/coverlet.msbuild.tasks/InstrumentationTask.cs | 14 +++++++------- src/coverlet.msbuild/coverlet.msbuild.props | 2 +- src/coverlet.msbuild/coverlet.msbuild.targets | 3 ++- .../Helpers/InstrumentationHelperTests.cs | 8 ++++---- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/coverlet.core/Coverage.cs b/src/coverlet.core/Coverage.cs index bbdd95535..b058eead8 100644 --- a/src/coverlet.core/Coverage.cs +++ b/src/coverlet.core/Coverage.cs @@ -14,22 +14,22 @@ public class Coverage private string _module; private string _identifier; private string[] _filters; - private string[] _excludes; + private string[] _rules; private List _results; - public Coverage(string module, string identifier, string[] filters, string[] excludes) + public Coverage(string module, string identifier, string[] filters, string[] rules) { _module = module; _identifier = identifier; _filters = filters; - _excludes = excludes; + _rules = rules; _results = new List(); } public void PrepareModules() { string[] modules = InstrumentationHelper.GetCoverableModules(_module); - string[] excludedFiles = InstrumentationHelper.GetExcludedFiles(_excludes); + string[] excludedFiles = InstrumentationHelper.GetExcludedFiles(_rules); foreach (var module in modules) { @@ -211,4 +211,4 @@ private void CalculateCoverage() } } } -} \ No newline at end of file +} diff --git a/src/coverlet.core/Helpers/InstrumentationHelper.cs b/src/coverlet.core/Helpers/InstrumentationHelper.cs index 2989fb0f7..a6c9d7c5e 100644 --- a/src/coverlet.core/Helpers/InstrumentationHelper.cs +++ b/src/coverlet.core/Helpers/InstrumentationHelper.cs @@ -131,15 +131,15 @@ public static bool IsTypeExcluded(string module, string type, string[] filters) return isMatch; } - public static string[] GetExcludedFiles(string[] excludes) + public static string[] GetExcludedFiles(string[] rules) { const string RELATIVE_KEY = nameof(RELATIVE_KEY); string parentDir = Directory.GetCurrentDirectory(); - if (excludes == null || !excludes.Any()) return Array.Empty(); + if (rules == null || !rules.Any()) return Array.Empty(); var matcherDict = new Dictionary() { { RELATIVE_KEY, new Matcher() } }; - foreach (var excludeRule in excludes) + foreach (var excludeRule in rules) { if (Path.IsPathRooted(excludeRule)) { diff --git a/src/coverlet.msbuild.tasks/InstrumentationTask.cs b/src/coverlet.msbuild.tasks/InstrumentationTask.cs index 87df68731..12c641ce0 100644 --- a/src/coverlet.msbuild.tasks/InstrumentationTask.cs +++ b/src/coverlet.msbuild.tasks/InstrumentationTask.cs @@ -9,7 +9,7 @@ public class InstrumentationTask : Task { private static Coverage _coverage; private string _path; - private string _filter; + private string _exclude; private string _excludeByFile; internal static Coverage Coverage @@ -24,10 +24,10 @@ public string Path set { _path = value; } } - public string Filter + public string Exclude { - get { return _filter; } - set { _filter = value; } + get { return _exclude; } + set { _exclude = value; } } public string ExcludeByFile @@ -40,10 +40,10 @@ public override bool Execute() { try { - var excludes = _excludeByFile?.Split(','); - var filters = _filter?.Split(','); + var rules = _excludeByFile?.Split(','); + var filters = _exclude?.Split(','); - _coverage = new Coverage(_path, Guid.NewGuid().ToString(), filters, excludes); + _coverage = new Coverage(_path, Guid.NewGuid().ToString(), filters, rules); _coverage.PrepareModules(); } catch (Exception ex) diff --git a/src/coverlet.msbuild/coverlet.msbuild.props b/src/coverlet.msbuild/coverlet.msbuild.props index 53fea8e8c..dafc8382a 100644 --- a/src/coverlet.msbuild/coverlet.msbuild.props +++ b/src/coverlet.msbuild/coverlet.msbuild.props @@ -5,7 +5,7 @@ $(MSBuildProjectDirectory) coverage $([MSBuild]::EnsureTrailingSlash('$(CoverletOutputDirectory)'))$(CoverletOutputName) - + 0 line,branch,method diff --git a/src/coverlet.msbuild/coverlet.msbuild.targets b/src/coverlet.msbuild/coverlet.msbuild.targets index 8324ee7b1..e77b7a0c8 100644 --- a/src/coverlet.msbuild/coverlet.msbuild.targets +++ b/src/coverlet.msbuild/coverlet.msbuild.targets @@ -6,6 +6,7 @@ @@ -13,7 +14,7 @@ diff --git a/test/coverlet.core.tests/Helpers/InstrumentationHelperTests.cs b/test/coverlet.core.tests/Helpers/InstrumentationHelperTests.cs index 558ce2bbd..0bbaf3245 100644 --- a/test/coverlet.core.tests/Helpers/InstrumentationHelperTests.cs +++ b/test/coverlet.core.tests/Helpers/InstrumentationHelperTests.cs @@ -95,11 +95,11 @@ public void TestGetExcludedFilesUsingAbsFile() { var file = Path.GetRandomFileName(); File.Create(file).Dispose(); - var excludeFiles = InstrumentationHelper.GetExcludedFiles( + var excludedFiles = InstrumentationHelper.GetExcludedFiles( new string[] { Path.Combine(Directory.GetCurrentDirectory(), file) } ); File.Delete(file); - Assert.Single(excludeFiles); + Assert.Single(excludedFiles); } [Fact] @@ -116,7 +116,7 @@ public void TestGetExcludedFilesUsingGlobbing() File.Create(path).Dispose(); } - var excludeFiles = InstrumentationHelper.GetExcludedFiles( + var excludedFiles = InstrumentationHelper.GetExcludedFiles( new string[] { $"*.{fileExtension}" }); foreach (var path in paths) @@ -124,7 +124,7 @@ public void TestGetExcludedFilesUsingGlobbing() File.Delete(path); } - Assert.Equal(paths.Length, excludeFiles.Count()); + Assert.Equal(paths.Length, excludedFiles.Count()); } } }