@@ -633,14 +633,18 @@ public void MetricsTable(Class @class)
633
633
throw new ArgumentNullException ( nameof ( @class ) ) ;
634
634
}
635
635
636
- var firstMethodMetric = @class . Files . SelectMany ( f => f . MethodMetrics ) . First ( ) ;
636
+ var metrics = @class . Files
637
+ . SelectMany ( f => f . MethodMetrics )
638
+ . SelectMany ( m => m . Metrics )
639
+ . Distinct ( )
640
+ . OrderBy ( m => m . Name ) ;
637
641
638
642
this . reportTextWriter . WriteLine ( "<table class=\" overview table-fixed\" >" ) ;
639
643
this . reportTextWriter . Write ( "<thead><tr>" ) ;
640
644
641
645
this . reportTextWriter . Write ( "<th>{0}</th>" , WebUtility . HtmlEncode ( ReportResources . Method ) ) ;
642
646
643
- foreach ( var met in firstMethodMetric . Metrics )
647
+ foreach ( var met in metrics )
644
648
{
645
649
if ( met . ExplanationUrl == null )
646
650
{
@@ -677,12 +681,21 @@ public void MetricsTable(Class @class)
677
681
this . reportTextWriter . Write ( "<td title=\" {0}\" >{1}</td>" , WebUtility . HtmlEncode ( methodMetric . FullName ) , WebUtility . HtmlEncode ( methodMetric . ShortName ) ) ;
678
682
}
679
683
680
- foreach ( var metricValue in methodMetric . Metrics )
684
+ foreach ( var metric in metrics )
681
685
{
682
- this . reportTextWriter . Write (
686
+ var metricValue = methodMetric . Metrics . FirstOrDefault ( m => m . Equals ( metric ) ) ;
687
+
688
+ if ( metricValue != null )
689
+ {
690
+ this . reportTextWriter . Write (
683
691
"<td>{0}{1}</td>" ,
684
692
metricValue . Value . HasValue ? metricValue . Value . Value . ToString ( "0.##" , CultureInfo . InvariantCulture ) : "-" ,
685
693
metricValue . Value . HasValue && metricValue . MetricType == MetricType . CoveragePercentual ? "%" : string . Empty ) ;
694
+ }
695
+ else
696
+ {
697
+ this . reportTextWriter . Write ( "<td>-</td>" ) ;
698
+ }
686
699
}
687
700
688
701
this . reportTextWriter . WriteLine ( "</tr>" ) ;
@@ -706,14 +719,17 @@ public void MetricsTable(IEnumerable<MethodMetric> methodMetrics)
706
719
throw new ArgumentNullException ( nameof ( methodMetrics ) ) ;
707
720
}
708
721
709
- var firstMethodMetric = methodMetrics . First ( ) ;
722
+ var metrics = methodMetrics
723
+ . SelectMany ( m => m . Metrics )
724
+ . Distinct ( )
725
+ . OrderBy ( m => m . Name ) ;
710
726
711
727
this . reportTextWriter . WriteLine ( "<table class=\" overview table-fixed\" >" ) ;
712
728
this . reportTextWriter . Write ( "<thead><tr>" ) ;
713
729
714
730
this . reportTextWriter . Write ( "<th>{0}</th>" , WebUtility . HtmlEncode ( ReportResources . Method ) ) ;
715
731
716
- foreach ( var met in firstMethodMetric . Metrics )
732
+ foreach ( var met in metrics )
717
733
{
718
734
if ( met . ExplanationUrl == null )
719
735
{
@@ -734,9 +750,20 @@ public void MetricsTable(IEnumerable<MethodMetric> methodMetrics)
734
750
735
751
this . reportTextWriter . Write ( "<td title=\" {0}\" >{1}</td>" , WebUtility . HtmlEncode ( methodMetric . FullName ) , WebUtility . HtmlEncode ( methodMetric . ShortName ) ) ;
736
752
737
- foreach ( var metricValue in methodMetric . Metrics . Select ( m => m . Value ) )
753
+ foreach ( var metric in metrics )
738
754
{
739
- this . reportTextWriter . Write ( "<td>{0}</td>" , metricValue . HasValue ? metricValue . Value . ToString ( "0.##" , CultureInfo . InvariantCulture ) : "-" ) ;
755
+ var metricValue = methodMetric . Metrics . FirstOrDefault ( m => m . Equals ( metric ) ) ;
756
+
757
+ if ( metricValue != null )
758
+ {
759
+ this . reportTextWriter . Write (
760
+ "<td>{0}</td>" ,
761
+ metricValue . Value . HasValue ? metricValue . Value . Value . ToString ( "0.##" , CultureInfo . InvariantCulture ) : "-" ) ;
762
+ }
763
+ else
764
+ {
765
+ this . reportTextWriter . Write ( "<td>-</td>" ) ;
766
+ }
740
767
}
741
768
742
769
this . reportTextWriter . WriteLine ( "</tr>" ) ;
0 commit comments