From 5475606730e3ee2206e5c79b624b3606e5ca6089 Mon Sep 17 00:00:00 2001 From: Alexander Kozlenko Date: Mon, 16 Jul 2018 23:22:10 +0300 Subject: [PATCH] Make enumeration-based MSBuild properties case-insensitive --- src/coverlet.core/Reporters/ReporterFactory.cs | 3 ++- src/coverlet.msbuild.tasks/CoverageResultTask.cs | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/coverlet.core/Reporters/ReporterFactory.cs b/src/coverlet.core/Reporters/ReporterFactory.cs index 813d23970..988b1ba95 100644 --- a/src/coverlet.core/Reporters/ReporterFactory.cs +++ b/src/coverlet.core/Reporters/ReporterFactory.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using System.Collections.Generic; @@ -18,6 +19,6 @@ public ReporterFactory(string format) } public IReporter CreateReporter() - => _reporters.FirstOrDefault(r => r.Format == _format); + => _reporters.FirstOrDefault(r => string.Equals(r.Format, _format, StringComparison.OrdinalIgnoreCase)); } } \ No newline at end of file diff --git a/src/coverlet.msbuild.tasks/CoverageResultTask.cs b/src/coverlet.msbuild.tasks/CoverageResultTask.cs index e6c9ab8a6..37a3fc60f 100644 --- a/src/coverlet.msbuild.tasks/CoverageResultTask.cs +++ b/src/coverlet.msbuild.tasks/CoverageResultTask.cs @@ -90,19 +90,19 @@ public override bool Execute() if (_threshold > 0) { - if (linePercent < _threshold && thresholdTypes.Contains("line")) + if (linePercent < _threshold && thresholdTypes.Contains("line", StringComparer.OrdinalIgnoreCase)) { exceptionBuilder.AppendLine($"'{Path.GetFileNameWithoutExtension(module.Key)}' has a line coverage '{linePercent}%' below specified threshold '{_threshold}%'"); thresholdFailed = true; } - if (branchPercent < _threshold && thresholdTypes.Contains("branch")) + if (branchPercent < _threshold && thresholdTypes.Contains("branch", StringComparer.OrdinalIgnoreCase)) { exceptionBuilder.AppendLine($"'{Path.GetFileNameWithoutExtension(module.Key)}' has a branch coverage '{branchPercent}%' below specified threshold '{_threshold}%'"); thresholdFailed = true; } - if (methodPercent < _threshold && thresholdTypes.Contains("method")) + if (methodPercent < _threshold && thresholdTypes.Contains("method", StringComparer.OrdinalIgnoreCase)) { exceptionBuilder.AppendLine($"'{Path.GetFileNameWithoutExtension(module.Key)}' has a method coverage '{methodPercent}%' below specified threshold '{_threshold}%'"); thresholdFailed = true;