diff --git a/Shared Files/Resources/reportparts.xml b/Shared Files/Resources/reportparts.xml index f1079016..3354387a 100644 --- a/Shared Files/Resources/reportparts.xml +++ b/Shared Files/Resources/reportparts.xml @@ -1,12 +1,15 @@  + + + - + diff --git a/SharedProject/Core/ReportGenerator/IReportColours.cs b/SharedProject/Core/ReportGenerator/IReportColours.cs index 6a074b76..d18aa6f2 100644 --- a/SharedProject/Core/ReportGenerator/IReportColours.cs +++ b/SharedProject/Core/ReportGenerator/IReportColours.cs @@ -29,7 +29,7 @@ internal interface IReportColours Color FontColour { get; } - Color GrayCoverage { get; } + Color GrayCoverageColour { get; } Color HeaderBorderColour { get; } @@ -52,6 +52,12 @@ internal interface IReportColours Color TextBoxColour { get; } Color TextBoxTextColour { get; } + + Color SliderLeftColour { get; } + + Color SliderRightColour { get; } + + Color SliderThumbColour { get; } } } diff --git a/SharedProject/Core/ReportGenerator/JsThemeStyling.cs b/SharedProject/Core/ReportGenerator/JsThemeStyling.cs index e83f3651..71ff2cee 100644 --- a/SharedProject/Core/ReportGenerator/JsThemeStyling.cs +++ b/SharedProject/Core/ReportGenerator/JsThemeStyling.cs @@ -29,14 +29,17 @@ public class JsThemeStyling public string DownActiveBase64; public string DownInactiveBase64; public string UpActiveBase64; - public string GrayCoverage; - public string ComboBox; - public string ComboBoxBorder; - public string ComboBoxText; - public string ScrollBarArrow; - public string ScrollBarTrack; - public string ScrollBarThumb; -//#pragma warning restore SA1401 // Fields should be private -//#pragma warning restore IDE0079 // Remove unnecessary suppression + public string GrayCoverageColour; + public string ComboBoxColour; + public string ComboBoxBorderColour; + public string ComboBoxTextColour; + public string ScrollBarArrowColour; + public string ScrollBarTrackColour; + public string ScrollBarThumbColour; + public string SliderLeftColour; + public string SliderRightColour; + public string SliderThumbColour; + //#pragma warning restore SA1401 // Fields should be private + //#pragma warning restore IDE0079 // Remove unnecessary suppression } } diff --git a/SharedProject/Core/ReportGenerator/ReportColours.cs b/SharedProject/Core/ReportGenerator/ReportColours.cs index db881826..6a7710ce 100644 --- a/SharedProject/Core/ReportGenerator/ReportColours.cs +++ b/SharedProject/Core/ReportGenerator/ReportColours.cs @@ -29,7 +29,7 @@ internal class ReportColours : IReportColours public Color FontColour { get; set; } - public Color GrayCoverage { get; set; } + public Color GrayCoverageColour { get; set; } public Color HeaderBorderColour { get; set; } @@ -52,6 +52,12 @@ internal class ReportColours : IReportColours public Color TextBoxColour { get; set; } public Color TextBoxTextColour { get; set; } + + public Color SliderLeftColour { get; set; } + + public Color SliderRightColour { get; set; } + + public Color SliderThumbColour { get; set; } } } diff --git a/SharedProject/Core/ReportGenerator/ReportColoursExtensions.cs b/SharedProject/Core/ReportGenerator/ReportColoursExtensions.cs new file mode 100644 index 00000000..c1f96aca --- /dev/null +++ b/SharedProject/Core/ReportGenerator/ReportColoursExtensions.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace FineCodeCoverage.Engine.ReportGenerator +{ + internal static class ReportColoursExtensions + { + private class ColourReflection + { + public PropertyInfo ReportColoursPropertyInfo { get; set; } + public FieldInfo JsThemeStylingFieldInfo { get; set; } + } + private static List colourReflections; + private static List ColourReflections + { + get + { + if (colourReflections == null) + { + var reportColourPropertyInfos = typeof(IReportColours).GetProperties(); + var jsThemeStylingFieldInfos = typeof(JsThemeStyling).GetFields(); + colourReflections = reportColourPropertyInfos.Select(prop => + { + var field = jsThemeStylingFieldInfos.FirstOrDefault(f => f.Name == prop.Name); + if (field == null) + { + return null; + } + else + { + return new ColourReflection { ReportColoursPropertyInfo = prop, JsThemeStylingFieldInfo = field }; + } + }).Where(cr => cr != null).ToList(); + } + return colourReflections; + } + } + public static JsThemeStyling Convert(this IReportColours reportColours) + { + var jsThemeStyling = new JsThemeStyling(); + ColourReflections.ForEach(cr => + { + cr.JsThemeStylingFieldInfo.SetValue(jsThemeStyling, ((System.Drawing.Color)cr.ReportColoursPropertyInfo.GetValue(reportColours)).ToJsColour()); + }); + return jsThemeStyling; + } + + public static string ToJsColour(this System.Drawing.Color colour) + { + return $"rgba({colour.R},{colour.G},{colour.B},{colour.A})"; + } + } +} diff --git a/SharedProject/Core/ReportGenerator/ReportColoursProvider.cs b/SharedProject/Core/ReportGenerator/ReportColoursProvider.cs index 96cc6aaa..95dd7512 100644 --- a/SharedProject/Core/ReportGenerator/ReportColoursProvider.cs +++ b/SharedProject/Core/ReportGenerator/ReportColoursProvider.cs @@ -13,7 +13,7 @@ internal class ReportColoursProvider : IReportColoursProvider public event EventHandler ColoursChanged; - private static PropertyInfo[] propertyInfos; + private static readonly PropertyInfo[] propertyInfos; static ReportColoursProvider() { propertyInfos = typeof(ReportColours).GetProperties(); diff --git a/SharedProject/Core/ReportGenerator/ReportGeneratorUtil.cs b/SharedProject/Core/ReportGenerator/ReportGeneratorUtil.cs index 3ce3c8de..6d218c2e 100644 --- a/SharedProject/Core/ReportGenerator/ReportGeneratorUtil.cs +++ b/SharedProject/Core/ReportGenerator/ReportGeneratorUtil.cs @@ -54,10 +54,26 @@ internal partial class ReportGeneratorUtil : IReportGeneratorUtil private readonly Base64ReportImage upActiveBase64ReportImage = new Base64ReportImage(".icon-up-dir_active", "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxzdmcgd2lkdGg9IjE3OTIiIGhlaWdodD0iMTc5MiIgdmlld0JveD0iMCAwIDE3OTIgMTc5MiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBmaWxsPSIjMDA3OEQ0IiBkPSJNMTQwOCAxMjE2cTAgMjYtMTkgNDV0LTQ1IDE5aC04OTZxLTI2IDAtNDUtMTl0LTE5LTQ1IDE5LTQ1bDQ0OC00NDhxMTktMTkgNDUtMTl0NDUgMTlsNDQ4IDQ0OHExOSAxOSAxOSA0NXoiLz48L3N2Zz4="); private readonly IScriptInvoker scriptInvoker; private IReportColours reportColours; + private JsThemeStyling jsReportColours; + private IReportColours ReportColours + { + get => reportColours; + set + { + reportColours = value; + jsReportColours = reportColours.Convert(); + } + } private readonly bool showBranchCoverage = true; public string ReportGeneratorExePath { get; private set; } + + static ReportGeneratorUtil() + { + + + } [ImportingConstructor] public ReportGeneratorUtil( IAssemblyUtil assemblyUtil, @@ -182,10 +198,9 @@ async Task run(string outputReportType, string inputReports) private void SetInitialTheme(HtmlAgilityPack.HtmlDocument document) { - - var backgroundColor = ToJsColour(reportColours.BackgroundColour); - var fontColour = ToJsColour(reportColours.FontColour); - var overviewTableBorderColor = ToJsColour(reportColours.TableBorderColour); + var backgroundColor = jsReportColours.BackgroundColour; + var fontColour = jsReportColours.FontColour; + var overviewTableBorderColor = jsReportColours.TableBorderColour; var style = document.DocumentNode.Descendants("style").First(); @@ -203,7 +218,7 @@ Other option be *dynamic* and be lighten / darken %age of the background color */ var grayRule = styleRules.First(r => r.SelectorText == ".gray"); - grayRule.Style.BackgroundColor = ToJsColour(reportColours.GrayCoverage); + grayRule.Style.BackgroundColor = jsReportColours.GrayCoverageColour; var htmlRule = styleRules.First(r => r.Selector.Text == "html"); var htmlStyle = htmlRule.Style; @@ -224,22 +239,22 @@ Other option overviewRule.Style.Border = overviewTableBorder; var overviewHeaderLinks = styleRules.First(r => r.SelectorText == ".overview th a"); - overviewHeaderLinks.Style.Color = ToJsColour(reportColours.CoverageTableHeaderFontColour); + overviewHeaderLinks.Style.Color = jsReportColours.CoverageTableHeaderFontColour; var overviewTrHoverRule = styleRules.First(r => r.SelectorText == ".overview tr:hover"); - overviewTrHoverRule.Style.Background = ToJsColour(reportColours.CoverageTableRowHoverBackgroundColour); + overviewTrHoverRule.Style.Background = jsReportColours.CoverageTableRowHoverBackgroundColour; - var expandCollapseIconColor = reportColours.CoverageTableExpandCollapseIconColour; - plusBase64ReportImage.FillSvg(styleRules, ToJsColour(expandCollapseIconColor)); - minusBase64ReportImage.FillSvg(styleRules, ToJsColour(expandCollapseIconColor)); + var expandCollapseIconColor = ReportColours.CoverageTableExpandCollapseIconColour; + plusBase64ReportImage.FillSvg(styleRules, expandCollapseIconColor.ToJsColour()); + minusBase64ReportImage.FillSvg(styleRules, expandCollapseIconColor.ToJsColour()); - var coverageTableActiveSortColor = ToJsColour(reportColours.CoverageTableActiveSortColour); - var coverageTableInactiveSortColor = ToJsColour(reportColours.CoverageTableInactiveSortColour); + var coverageTableActiveSortColor = ReportColours.CoverageTableActiveSortColour.ToJsColour(); + var coverageTableInactiveSortColor = ReportColours.CoverageTableInactiveSortColour.ToJsColour(); downActiveBase64ReportImage.FillSvg(styleRules, coverageTableActiveSortColor); upActiveBase64ReportImage.FillSvg(styleRules, coverageTableActiveSortColor); downInactiveBase64ReportImage.FillSvg(styleRules, coverageTableInactiveSortColor); - var linkColor = ToJsColour(reportColours.LinkColour); + var linkColor = jsReportColours.LinkColour; var linkRule = styleRules.First(r => r.SelectorText == "a"); var linkHoverRule = styleRules.First(r => r.SelectorText == "a:hover"); @@ -750,12 +765,12 @@ private string HideGroupingCss() "; } - private string HackGroupingToAllowAll() + private string HackGroupingToAllowAll(int groupingLevel) { - return @" + return $@" var customizeBox = document.getElementsByClassName('customizebox')[0]; var groupingInput = customizeBox.querySelector('input'); - groupingInput.max = 1; + groupingInput.max = {groupingLevel}; "; } @@ -764,7 +779,7 @@ public string ProcessUnifiedHtml(string htmlForProcessing, string reportOutputFo { var appOptions = appOptionsProvider.Get(); var namespacedClasses = appOptions.NamespacedClasses; - reportColours = reportColoursProvider.GetColours(); + ReportColours = reportColoursProvider.GetColours(); return assemblyUtil.RunInAssemblyResolvingContext(() => { var (cyclomaticThreshold, crapScoreThreshold, nPathThreshold) = HotspotThresholds(); @@ -807,6 +822,7 @@ public string ProcessUnifiedHtml(string htmlForProcessing, string reportOutputFo assembliesToReplace = assembliesToReplace.Substring(0, endIndex + 1); var assemblies = JArray.Parse(assembliesToReplace); + var groupingLevel = 0; foreach (JObject assembly in assemblies) { var assemblyName = assembly["name"]; @@ -822,6 +838,11 @@ public string ProcessUnifiedHtml(string htmlForProcessing, string reportOutputFo } else { + var namespaces = className.Split('.').Length - 1; + if (namespaces > groupingLevel) + { + groupingLevel = namespaces; + } if (!namespacedClasses) { // simplify name @@ -871,8 +892,9 @@ public string ProcessUnifiedHtml(string htmlForProcessing, string reportOutputFo htmlSb.Replace(".table-fixed", ".table-fixed-ignore-me"); - var fontColour = ToJsColour(reportColours.FontColour); - var scrollbarThumbColour = ToJsColour(reportColours.ScrollBarThumbColour); + var fontColour = jsReportColours.FontColour; + var scrollbarThumbColour = jsReportColours.ScrollBarThumbColour; + var sliderThumbColour = jsReportColours.SliderThumbColour; htmlSb.Replace("", $@" @@ -910,7 +932,7 @@ public string ProcessUnifiedHtml(string htmlForProcessing, string reportOutputFo htmlSb.Replace("", $@"