Skip to content

Commit 302886a

Browse files
authored
Fix filename update for activated UseSourceFile option (#1681)
1 parent 973200c commit 302886a

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

eng/azure-pipelines-nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ steps:
1010
- task: UseDotNet@2
1111
inputs:
1212
useGlobalJson: true
13-
displayName: Install .NET Core SDK 8.0.100
13+
displayName: Install .NET Core SDK 8.0.111
1414

1515
- task: NuGetAuthenticate@1
1616
displayName: Authenticate with NuGet feeds

src/coverlet.console/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static int Main(string[] args)
3434
var verbosity = new Option<LogLevel>(new[] { "--verbosity", "-v" }, () => LogLevel.Normal, "Sets the verbosity level of the command. Allowed values are quiet, minimal, normal, detailed.") { Arity = ArgumentArity.ZeroOrOne };
3535
var formats = new Option<string[]>(new[] { "--format", "-f" }, () => new[] { "json" }, "Format of the generated coverage report.") { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
3636
var threshold = new Option<string>("--threshold", "Exits with error if the coverage % is below value.") { Arity = ArgumentArity.ZeroOrOne };
37-
var thresholdTypes = new Option<List<string>>("--threshold-type", () => new List<string>(new string[] { "line", "branch", "method" }), "Coverage type to apply the threshold to.").FromAmong("line", "branch", "method");
37+
Option<List<string>> thresholdTypes = new Option<List<string>>("--threshold-type", () => new List<string>(new string[] { "line", "branch", "method" }), "Coverage type to apply the threshold to.").FromAmong("line", "branch", "method");
3838
var thresholdStat = new Option<ThresholdStatistic>("--threshold-stat", () => ThresholdStatistic.Minimum, "Coverage statistic used to enforce the threshold value.") { Arity = ArgumentArity.ZeroOrOne };
3939
var excludeFilters = new Option<string[]>("--exclude", "Filter expressions to exclude specific modules and types.") { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
4040
var includeFilters = new Option<string[]>("--include", "Filter expressions to include only specific modules and types.") { Arity = ArgumentArity.ZeroOrMore, AllowMultipleArgumentsPerToken = true };
@@ -106,7 +106,7 @@ static int Main(string[] args)
106106
if (string.IsNullOrEmpty(moduleOrAppDirectoryValue) || string.IsNullOrWhiteSpace(moduleOrAppDirectoryValue))
107107
throw new ArgumentException("No test assembly or application directory specified.");
108108

109-
var taskStatus = await HandleCommand(moduleOrAppDirectoryValue,
109+
int taskStatus = await HandleCommand(moduleOrAppDirectoryValue,
110110
targetValue,
111111
targsValue,
112112
outputValue,
@@ -385,7 +385,6 @@ string sourceMappingFile
385385

386386
return Task.FromResult(exitCode);
387387

388-
389388
}
390389

391390
catch (Win32Exception we) when (we.Source == "System.Diagnostics.Process")

src/coverlet.core/Coverage.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public CoveragePrepareResult PrepareModules()
108108
_parameters.IncludeFilters = _parameters.IncludeFilters?.Where(f => _instrumentationHelper.IsValidFilterExpression(f)).ToArray();
109109

110110
IReadOnlyList<string> validModules = _instrumentationHelper.SelectModules(modules, _parameters.IncludeFilters, _parameters.ExcludeFilters).ToList();
111-
foreach (var excludedModule in modules.Except(validModules))
111+
foreach (string excludedModule in modules.Except(validModules))
112112
{
113113
_logger.LogVerbose($"Excluded module: '{excludedModule}'");
114114
}
@@ -365,16 +365,6 @@ private void CalculateCoverage()
365365
{
366366
foreach (InstrumenterResult result in _results)
367367
{
368-
if (!_fileSystem.Exists(result.HitsFilePath))
369-
{
370-
// Hits file could be missed mainly for two reason
371-
// 1) Issue during module Unload()
372-
// 2) Instrumented module is never loaded or used so we don't have any hit to register and
373-
// module tracker is never used
374-
_logger.LogVerbose($"Hits file:'{result.HitsFilePath}' not found for module: '{result.Module}'");
375-
continue;
376-
}
377-
378368
var documents = result.Documents.Values.ToList();
379369
if (_parameters.UseSourceLink && result.SourceLink != null)
380370
{
@@ -386,6 +376,16 @@ private void CalculateCoverage()
386376
}
387377
}
388378

379+
if (!_fileSystem.Exists(result.HitsFilePath))
380+
{
381+
// Hits file could be missed mainly for two reason
382+
// 1) Issue during module Unload()
383+
// 2) Instrumented module is never loaded or used so we don't have any hit to register and
384+
// module tracker is never used
385+
_logger.LogVerbose($"Hits file:'{result.HitsFilePath}' not found for module: '{result.Module}'");
386+
continue;
387+
}
388+
389389
// Calculate lines to skip for every hits start/end candidate
390390
// Nested ranges win on outermost one
391391
foreach (HitCandidate hitCandidate in result.HitCandidates)

test/coverlet.tests.projectsample.aspmvcrazor/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Copyright (c) Toni Solarin-Sodara
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
var builder = WebApplication.CreateBuilder(args);
4+
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
55

66
// Add services to the container.
77
builder.Services.AddRazorPages();
88

9-
var app = builder.Build();
9+
WebApplication app = builder.Build();
1010

1111
// Configure the HTTP request pipeline.
1212
if (!app.Environment.IsDevelopment())

0 commit comments

Comments
 (0)