@@ -927,6 +927,8 @@ public string ProcessUnifiedHtml(string htmlForProcessing, string reportOutputFo
927927
928928 var outerHtml = doc.DocumentNode.OuterHtml;
929929 var htmlSb = new StringBuilder(outerHtml);
930+ FixGroupingMax(htmlSb);
931+ FixCollapse(htmlSb);
930932
931933 var assembliesSearch = "var assemblies = [";
932934 var startIndex = outerHtml.IndexOf(assembliesSearch) + assembliesSearch.Length - 1;
@@ -1377,7 +1379,7 @@ function clearFCCWindowLogs(){{
13771379 coverageLogElement.textContent = '';
13781380 window.external.{nameof(ScriptManager.ClearFCCWindowLogs)}();
13791381 }}
1380-
1382+
13811383 function addCoverageLogElements(){{
13821384 var container = document.getElementsByClassName('container')[0];
13831385 var coverageLogContainer = document.createElement('div');
@@ -1547,6 +1549,94 @@ Risk Hotspots
15471549 } ) ;
15481550 }
15491551
1552+ private void PreventBrowserHistory( StringBuilder documentStringBuilder )
1553+ {
1554+ documentStringBuilder. Replace (
1555+ @"{key:""onDonBeforeUnlodad"",value:function(){if(this.saveCollapseState(),void 0!==this.window.history&&void 0!==this.window.history.replaceState){console.log(""Coverage info: Updating history"",this.settings);var e=null;(e=null!==window.history.state?JSON.parse(JSON.stringify(this.window.history.state)):new Gc).coverageInfoSettings=JSON.parse(JSON.stringify(this.settings)),window.history.replaceState(e,null)}}}," ,
1556+ @"{key:""onDonBeforeUnlodad"",value: function(){}}," ) ;
1557+ }
1558+
1559+ private void FixCollapse( StringBuilder documentStringBuilder )
1560+ {
1561+ documentStringBuilder. Replace (
1562+ @"{key:""saveCollapseState"",value:function(){var e=this;this.settings.collapseStates=[],function t(n){for(var r=0;r<n.length;r++)e.settings.collapseStates.push(n[r].collapsed),t(n[r].subElements)}(this.codeElements)}},{key:""restoreCollapseState"",value:function(){var e=this,t=0;!function n(r){for(var i=0;i<r.length;i++)e.settings.collapseStates.length>t&&(r[i].collapsed=e.settings.collapseStates[t]),t++,n(r[i].subElements)}(this.codeElements)}}" ,
1563+ @"{
1564+ key:""saveCollapseState"",
1565+ value:function(){
1566+ var e=this;
1567+ this.settings.collapseStates=[];
1568+ function t(level,n){
1569+ for(var r=0;r<n.length;r++){
1570+ console.log(n[r].name);
1571+
1572+ e.settings.collapseStates.push(n[r].name + ':' + level.toString() + ':' + n[r].collapsed.toString())
1573+ t(level+1,n[r].subElements)
1574+ }
1575+ }
1576+ t(0,this.codeElements);
1577+ }
1578+ },{
1579+ key:""restoreCollapseState"",
1580+ value:function(){
1581+ var e=this;
1582+ var collapsedStates = e.settings.collapseStates;
1583+ function n(level,r){
1584+ for(var i=0;i<r.length;i++){
1585+ var codeElement = r[i];
1586+ for(var j=0;j<collapsedStates.length;j++){
1587+ var collapsedState = collapsedStates[j];
1588+ var parts = collapsedState.split(':');
1589+ var name = parts[0];
1590+ var stateLevel = parts[1];
1591+ var isCollapsed = (parts[2] === 'true');
1592+ if(name == codeElement.name && stateLevel == level.toString()){
1593+ codeElement.collapsed = isCollapsed;
1594+ break;
1595+ }
1596+ }
1597+ n(level + 1, r[i].subElements);// conditional on collapsed ?
1598+
1599+ }
1600+ }
1601+ n(0,this.codeElements);
1602+ }
1603+ }" ) ;
1604+ }
1605+
1606+ private void FixGroupingMax( StringBuilder documentStringBuilder )
1607+ {
1608+ documentStringBuilder. Replace (
1609+ @"{key:""ngOnInit"",value:function(){this.historicCoverageExecutionTimes=this.window.historicCoverageExecutionTimes,this.branchCoverageAvailable=this.window.branchCoverageAvailable,this.translations=this.window.translations;var e=!1;if(void 0!==this.window.history&&void 0!==this.window.history.replaceState&&null!==this.window.history.state&&null!=this.window.history.state.coverageInfoSettings)console.log(""Coverage info: Restoring from history"",this.window.history.state.coverageInfoSettings),e=!0,this.settings=JSON.parse(JSON.stringify(this.window.history.state.coverageInfoSettings));else{for(var t=0,n=this.window.assemblies,r=0;r<n.length;r++)for(var i=0;i<n[r].classes.length;i++)t=Math.max(t,(n[r].classes[i].name.match(/\./g)||[]).length);this.settings.groupingMaximum=t,console.log(""Grouping maximum: ""+t)}var o=window.location.href.indexOf(""?"");o>-1&&(this.queryString=window.location.href.substr(o)),this.updateCoverageInfo(),e&&this.restoreCollapseState()}}" ,
1610+ @"{key:""ngOnInit"",value:function(){
1611+ this.historicCoverageExecutionTimes=this.window.historicCoverageExecutionTimes;
1612+ this.branchCoverageAvailable=this.window.branchCoverageAvailable;
1613+ this.translations=this.window.translations;
1614+ var restoredFromHistory = false;
1615+ if(void 0!==this.window.history&&void 0!==this.window.history.replaceState&&null!==this.window.history.state&&null!=this.window.history.state.coverageInfoSettings){
1616+ restoredFromHistory = true;
1617+ this.settings=JSON.parse(JSON.stringify(this.window.history.state.coverageInfoSettings));
1618+
1619+ }
1620+
1621+ for(var t=0,n=this.window.assemblies,r=0;r<n.length;r++){
1622+ for(var i=0;i<n[r].classes.length;i++){
1623+ t=Math.max(t,(n[r].classes[i].name.match(/\./g)||[]).length);
1624+ }
1625+ }
1626+ this.settings.groupingMaximum=t;
1627+ if(this.settings.grouping > this.settings.groupingMaximum){
1628+ this.settings.grouping = this.settings.groupingMaximum;
1629+ }
1630+
1631+ this.updateCoverageInfo();
1632+ if(restoredFromHistory){
1633+ this.restoreCollapseState()
1634+ }
1635+
1636+ }}" ) ;
1637+
1638+ }
1639+
15501640 private void HideRowsFromOverviewTable( HtmlDocument doc )
15511641 {
15521642 var table = doc. DocumentNode . QuerySelectorAll ( "table.overview" ) . First ( ) ;
0 commit comments