Skip to content

Commit

Permalink
#629 Visual Studio Coverage: Added support for partial line coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpalme committed Oct 9, 2023
1 parent a6d5177 commit fc1de1c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ For further details take a look at LICENSE.txt.

CHANGELOG

5.1.27.0

* New: #629 Visual Studio Coverage: Added support for partial line coverage

5.1.26.0

* New: #595 Added new report type 'Html_BlueRed_Summary' to improve red-green colorblind accessibility
Expand Down
21 changes: 20 additions & 1 deletion src/ReportGenerator.Core/Parser/VisualStudioParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,26 @@ private static CodeFile ProcessFile(XElement[] modules, string fileId, Class @cl
{
int visits = seqpnt.Coverage < 2 ? 1 : 0;
coverage[lineNumber] = coverage[lineNumber] == -1 ? visits : Math.Min(coverage[lineNumber] + visits, 1);
lineVisitStatus[lineNumber] = lineVisitStatus[lineNumber] == LineVisitStatus.Covered || visits > 0 ? LineVisitStatus.Covered : LineVisitStatus.NotCovered;

if (seqpnt.Coverage == 2)
{
if (lineVisitStatus[lineNumber] == LineVisitStatus.NotCoverable)
{
lineVisitStatus[lineNumber] = LineVisitStatus.NotCovered;
}
}
else if (seqpnt.Coverage == 1)
{
if (lineVisitStatus[lineNumber] == LineVisitStatus.NotCoverable
|| lineVisitStatus[lineNumber] == LineVisitStatus.NotCovered)
{
lineVisitStatus[lineNumber] = LineVisitStatus.PartiallyCovered;
}
}
else if (seqpnt.Coverage == 0)
{
lineVisitStatus[lineNumber] = LineVisitStatus.Covered;
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/ReportGenerator.sln
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Reports", "Reports", "{7925
Testprojects\CSharp\Reports\VisualStudio2010.coveragexml = Testprojects\CSharp\Reports\VisualStudio2010.coveragexml
Testprojects\CSharp\Reports\VisualStudio2012.coveragexml = Testprojects\CSharp\Reports\VisualStudio2012.coveragexml
Testprojects\CSharp\Reports\VisualStudio2013.coveragexml = Testprojects\CSharp\Reports\VisualStudio2013.coveragexml
Testprojects\CSharp\Reports\VisualStudio2022.coveragexml = Testprojects\CSharp\Reports\VisualStudio2022.coveragexml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FSharp", "FSharp", "{9223804A-D678-4EE8-BD89-19A6114DB86F}"
Expand Down

0 comments on commit fc1de1c

Please sign in to comment.