11using System ;
22using System . Collections . Generic ;
3+ using System . Globalization ;
34using System . IO ;
45using System . Linq ;
56using System . Text ;
@@ -76,8 +77,8 @@ public string Report(CoverageResult result)
7677
7778 method . Add ( new XAttribute ( "cyclomaticComplexity" , methCyclomaticComplexity . ToString ( ) ) ) ;
7879 method . Add ( new XAttribute ( "nPathComplexity" , "0" ) ) ;
79- method . Add ( new XAttribute ( "sequenceCoverage" , methLineCoverage . Percent . ToString ( ) ) ) ;
80- method . Add ( new XAttribute ( "branchCoverage" , methBranchCoverage . Percent . ToString ( ) ) ) ;
80+ method . Add ( new XAttribute ( "sequenceCoverage" , Math . Round ( methLineCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
81+ method . Add ( new XAttribute ( "branchCoverage" , Math . Round ( methBranchCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
8182 method . Add ( new XAttribute ( "isConstructor" , meth . Key . Contains ( "ctor" ) . ToString ( ) ) ) ;
8283 method . Add ( new XAttribute ( "isGetter" , meth . Key . Contains ( "get_" ) . ToString ( ) ) ) ;
8384 method . Add ( new XAttribute ( "isSetter" , meth . Key . Contains ( "set_" ) . ToString ( ) ) ) ;
@@ -157,8 +158,8 @@ public string Report(CoverageResult result)
157158 methodSummary . Add ( new XAttribute ( "visitedSequencePoints" , methLineCoverage . Covered . ToString ( ) ) ) ;
158159 methodSummary . Add ( new XAttribute ( "numBranchPoints" , methBranchCoverage . Total . ToString ( ) ) ) ;
159160 methodSummary . Add ( new XAttribute ( "visitedBranchPoints" , methBranchCoverage . Covered . ToString ( ) ) ) ;
160- methodSummary . Add ( new XAttribute ( "sequenceCoverage" , methLineCoverage . Percent . ToString ( ) ) ) ;
161- methodSummary . Add ( new XAttribute ( "branchCoverage" , methBranchCoverage . Percent . ToString ( ) ) ) ;
161+ methodSummary . Add ( new XAttribute ( "sequenceCoverage" , Math . Round ( methLineCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
162+ methodSummary . Add ( new XAttribute ( "branchCoverage" , Math . Round ( methBranchCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
162163 methodSummary . Add ( new XAttribute ( "maxCyclomaticComplexity" , methCyclomaticComplexity . ToString ( ) ) ) ;
163164 methodSummary . Add ( new XAttribute ( "minCyclomaticComplexity" , methCyclomaticComplexity . ToString ( ) ) ) ;
164165 methodSummary . Add ( new XAttribute ( "visitedClasses" , "0" ) ) ;
@@ -191,8 +192,8 @@ public string Report(CoverageResult result)
191192 classSummary . Add ( new XAttribute ( "visitedSequencePoints" , classLineCoverage . Covered . ToString ( ) ) ) ;
192193 classSummary . Add ( new XAttribute ( "numBranchPoints" , classBranchCoverage . Total . ToString ( ) ) ) ;
193194 classSummary . Add ( new XAttribute ( "visitedBranchPoints" , classBranchCoverage . Covered . ToString ( ) ) ) ;
194- classSummary . Add ( new XAttribute ( "sequenceCoverage" , classLineCoverage . Percent . ToString ( ) ) ) ;
195- classSummary . Add ( new XAttribute ( "branchCoverage" , classBranchCoverage . Percent . ToString ( ) ) ) ;
195+ classSummary . Add ( new XAttribute ( "sequenceCoverage" , Math . Round ( classLineCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
196+ classSummary . Add ( new XAttribute ( "branchCoverage" , Math . Round ( classBranchCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
196197 classSummary . Add ( new XAttribute ( "maxCyclomaticComplexity" , classMaxCyclomaticComplexity . ToString ( ) ) ) ;
197198 classSummary . Add ( new XAttribute ( "minCyclomaticComplexity" , classMinCyclomaticComplexity . ToString ( ) ) ) ;
198199 classSummary . Add ( new XAttribute ( "visitedClasses" , classVisited ? "1" : "0" ) ) ;
@@ -214,16 +215,16 @@ public string Report(CoverageResult result)
214215 }
215216
216217 var moduleLineCoverage = summary . CalculateLineCoverage ( result . Modules ) ;
217- var moduleBranchCoverage = summary . CalculateLineCoverage ( result . Modules ) ;
218+ var moduleBranchCoverage = summary . CalculateBranchCoverage ( result . Modules ) ;
218219 var moduleMaxCyclomaticComplexity = summary . CalculateMaxCyclomaticComplexity ( result . Modules ) ;
219220 var moduleMinCyclomaticComplexity = summary . CalculateMinCyclomaticComplexity ( result . Modules ) ;
220221
221222 coverageSummary . Add ( new XAttribute ( "numSequencePoints" , moduleLineCoverage . Total . ToString ( ) ) ) ;
222223 coverageSummary . Add ( new XAttribute ( "visitedSequencePoints" , moduleLineCoverage . Covered . ToString ( ) ) ) ;
223224 coverageSummary . Add ( new XAttribute ( "numBranchPoints" , moduleBranchCoverage . Total . ToString ( ) ) ) ;
224225 coverageSummary . Add ( new XAttribute ( "visitedBranchPoints" , moduleBranchCoverage . Covered . ToString ( ) ) ) ;
225- coverageSummary . Add ( new XAttribute ( "sequenceCoverage" , moduleLineCoverage . Percent . ToString ( ) ) ) ;
226- coverageSummary . Add ( new XAttribute ( "branchCoverage" , moduleBranchCoverage . Percent . ToString ( ) ) ) ;
226+ coverageSummary . Add ( new XAttribute ( "sequenceCoverage" , Math . Round ( moduleLineCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
227+ coverageSummary . Add ( new XAttribute ( "branchCoverage" , Math . Round ( moduleBranchCoverage . Percent * 100 , 2 ) . ToString ( "G" , CultureInfo . InvariantCulture ) ) ) ;
227228 coverageSummary . Add ( new XAttribute ( "maxCyclomaticComplexity" , moduleMaxCyclomaticComplexity . ToString ( ) ) ) ;
228229 coverageSummary . Add ( new XAttribute ( "minCyclomaticComplexity" , moduleMinCyclomaticComplexity . ToString ( ) ) ) ;
229230 coverageSummary . Add ( new XAttribute ( "visitedClasses" , visitedClasses . ToString ( ) ) ) ;
0 commit comments