Skip to content

Commit

Permalink
#247: Added new overloads to GenerateReports
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpalme committed May 27, 2019
1 parent 5cff1e6 commit 861bc08
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/AzureDevopsTask/ReportGenerator/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 4,
"Minor": 1,
"Patch": 8
"Patch": 9
},
"instanceNameFormat": "ReportGenerator",
"groups": [
Expand Down
2 changes: 1 addition & 1 deletion src/AzureDevopsTask/vss-extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifestVersion": 1,
"id": "reportgenerator",
"name": "ReportGenerator",
"version": "4.1.8",
"version": "4.1.9",
"publisher": "Palmmedia",
"public": true,
"targets": [
Expand Down
4 changes: 4 additions & 0 deletions src/Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ For further details take a look at LICENSE.txt.

CHANGELOG

4.1.9.0

* New: Issue #247: Added new overloads to GenerateReports

4.1.8.0

* Fix: Issue #239: Improved link back to the summary page for Azure DevOps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<AssemblyName>ReportGenerator</AssemblyName>
<RootNamespace>Palmmedia.ReportGenerator</RootNamespace>
<StartupObject>Palmmedia.ReportGenerator.Console.NetCore.Program</StartupObject>
<AssemblyVersion>4.1.8.0</AssemblyVersion>
<FileVersion>4.1.8.0</FileVersion>
<AssemblyVersion>4.1.9.0</AssemblyVersion>
<FileVersion>4.1.9.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/ReportGenerator.Console/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.1.8.0")]
[assembly: AssemblyFileVersion("4.1.8.0")]
[assembly: AssemblyVersion("4.1.9.0")]
[assembly: AssemblyFileVersion("4.1.9.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<TargetFramework>netcoreapp2.0</TargetFramework>
<IsPackable>false</IsPackable>
<RootNamespace>Palmmedia.ReportGenerator.Core.Test</RootNamespace>
<AssemblyVersion>4.1.8.0</AssemblyVersion>
<FileVersion>4.1.8.0</FileVersion>
<AssemblyVersion>4.1.9.0</AssemblyVersion>
<FileVersion>4.1.9.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
96 changes: 60 additions & 36 deletions src/ReportGenerator.Core/Generator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.Configuration;
using Palmmedia.ReportGenerator.Core.CodeAnalysis;
Expand Down Expand Up @@ -93,16 +94,13 @@ public bool GenerateReport(IReportConfiguration reportConfiguration)

try
{
var reportContext = new ReportContext(reportConfiguration, settings);

var pluginLoader = new ReflectionPluginLoader(reportConfiguration.Plugins);

IReportBuilderFactory reportBuilderFactory = new ReportBuilderFactory(pluginLoader);

// Set log level before validation is performed
LoggerFactory.VerbosityLevel = reportContext.ReportConfiguration.VerbosityLevel;
LoggerFactory.VerbosityLevel = reportConfiguration.VerbosityLevel;

if (!new ReportConfigurationValidator(reportBuilderFactory).Validate(reportContext.ReportConfiguration))
if (!new ReportConfigurationValidator(reportBuilderFactory).Validate(reportConfiguration))
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
Expand All @@ -116,43 +114,22 @@ public bool GenerateReport(IReportConfiguration reportConfiguration)

var stopWatch = new System.Diagnostics.Stopwatch();
stopWatch.Start();
DateTime executionTime = DateTime.Now;

var parserResult = new CoverageReportParser(
reportContext.Settings.NumberOfReportsParsedInParallel,
settings.NumberOfReportsParsedInParallel,
reportConfiguration.SourceDirectories,
new DefaultFilter(reportContext.ReportConfiguration.AssemblyFilters),
new DefaultFilter(reportContext.ReportConfiguration.ClassFilters),
new DefaultFilter(reportContext.ReportConfiguration.FileFilters))
.ParseFiles(reportContext.ReportConfiguration.ReportFiles);
new DefaultFilter(reportConfiguration.AssemblyFilters),
new DefaultFilter(reportConfiguration.ClassFilters),
new DefaultFilter(reportConfiguration.FileFilters))
.ParseFiles(reportConfiguration.ReportFiles);

Logger.DebugFormat(Resources.ReportParsingTook, stopWatch.ElapsedMilliseconds / 1000d);

reportContext.RiskHotspotAnalysisResult = new RiskHotspotsAnalyzer(riskHotspotsAnalysisThresholds, reportContext.Settings.DisableRiskHotspots)
.PerformRiskHotspotAnalysis(parserResult.Assemblies);

var overallHistoricCoverages = new System.Collections.Generic.List<Parser.Analysis.HistoricCoverage>();
var historyStorage = new HistoryStorageFactory(pluginLoader).GetHistoryStorage(reportContext.ReportConfiguration);

if (historyStorage != null)
{
new HistoryParser(historyStorage, reportContext.Settings.MaximumNumberOfHistoricCoverageFiles)
.ApplyHistoricCoverage(parserResult.Assemblies, overallHistoricCoverages);

reportContext.OverallHistoricCoverages = overallHistoricCoverages;
}

new Reporting.ReportGenerator(
new CachingFileReader(reportContext.Settings.CachingDuringOfRemoteFilesInMinutes),
parserResult,
reportBuilderFactory.GetReportBuilders(reportContext))
.CreateReport(reportContext.ReportConfiguration.HistoryDirectory != null, overallHistoricCoverages, executionTime, reportContext.ReportConfiguration.Tag);

if (historyStorage != null)
{
new HistoryReportGenerator(historyStorage)
.CreateReport(parserResult.Assemblies, executionTime, reportContext.ReportConfiguration.Tag);
}
this.GenerateReport(
reportConfiguration,
settings,
riskHotspotsAnalysisThresholds,
parserResult);

stopWatch.Stop();
Logger.InfoFormat(Resources.ReportGenerationTook, stopWatch.ElapsedMilliseconds / 1000d);
Expand All @@ -175,6 +152,53 @@ public bool GenerateReport(IReportConfiguration reportConfiguration)
}
}

/// <summary>
/// Executes the report generation.
/// </summary>
/// <param name="reportConfiguration">The report configuration.</param>
/// <param name="settings">The settings.</param>
/// <param name="riskHotspotsAnalysisThresholds">The risk hotspots analysis thresholds.</param>
/// <param name="parserResult">The parser result generated by <see cref="CoverageReportParser"/>.</param>
public void GenerateReport(
IReportConfiguration reportConfiguration,
Settings settings,
RiskHotspotsAnalysisThresholds riskHotspotsAnalysisThresholds,
ParserResult parserResult)
{
var reportContext = new ReportContext(reportConfiguration, settings);

var pluginLoader = new ReflectionPluginLoader(reportConfiguration.Plugins);
IReportBuilderFactory reportBuilderFactory = new ReportBuilderFactory(pluginLoader);

reportContext.RiskHotspotAnalysisResult = new RiskHotspotsAnalyzer(riskHotspotsAnalysisThresholds, settings.DisableRiskHotspots)
.PerformRiskHotspotAnalysis(parserResult.Assemblies);

var overallHistoricCoverages = new List<Parser.Analysis.HistoricCoverage>();
var historyStorage = new HistoryStorageFactory(pluginLoader).GetHistoryStorage(reportConfiguration);

if (historyStorage != null)
{
new HistoryParser(historyStorage, settings.MaximumNumberOfHistoricCoverageFiles)
.ApplyHistoricCoverage(parserResult.Assemblies, overallHistoricCoverages);

reportContext.OverallHistoricCoverages = overallHistoricCoverages;
}

DateTime executionTime = DateTime.Now;

new Reporting.ReportGenerator(
new CachingFileReader(settings.CachingDuringOfRemoteFilesInMinutes),
parserResult,
reportBuilderFactory.GetReportBuilders(reportContext))
.CreateReport(reportConfiguration.HistoryDirectory != null, overallHistoricCoverages, executionTime, reportConfiguration.Tag);

if (historyStorage != null)
{
new HistoryReportGenerator(historyStorage)
.CreateReport(parserResult.Assemblies, executionTime, reportConfiguration.Tag);
}
}

/// <summary>
/// Get the <see cref="IConfigurationRoot"/>.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/ReportGenerator.Core/ReportGenerator.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AssemblyName>ReportGenerator.Core</AssemblyName>
<AssemblyVersion>4.1.8.0</AssemblyVersion>
<FileVersion>4.1.8.0</FileVersion>
<AssemblyVersion>4.1.9.0</AssemblyVersion>
<FileVersion>4.1.9.0</FileVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<AssemblyName>dotnet-reportgenerator</AssemblyName>
<RootNamespace>Palmmedia.ReportGenerator</RootNamespace>
<StartupObject>Palmmedia.ReportGenerator.DotnetCliTool.Program</StartupObject>
<AssemblyVersion>4.1.8.0</AssemblyVersion>
<FileVersion>4.1.8.0</FileVersion>
<AssemblyVersion>4.1.9.0</AssemblyVersion>
<FileVersion>4.1.9.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RootNamespace>ReportGenerator.DotnetCorePluginLoader</RootNamespace>
<AssemblyVersion>4.1.8.0</AssemblyVersion>
<FileVersion>4.1.8.0</FileVersion>
<AssemblyVersion>4.1.9.0</AssemblyVersion>
<FileVersion>4.1.9.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<AssemblyName>ReportGenerator</AssemblyName>
<RootNamespace>Palmmedia.ReportGenerator</RootNamespace>
<StartupObject>Palmmedia.ReportGenerator.DotnetGlobalTool.Program</StartupObject>
<AssemblyVersion>4.1.8.0</AssemblyVersion>
<FileVersion>4.1.8.0</FileVersion>
<AssemblyVersion>4.1.9.0</AssemblyVersion>
<FileVersion>4.1.9.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/ReportGenerator.MSBuild/ReportGenerator.MSBuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<RootNamespace>Palmmedia.ReportGenerator.MSBuild</RootNamespace>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AssemblyVersion>4.1.8.0</AssemblyVersion>
<FileVersion>4.1.8.0</FileVersion>
<AssemblyVersion>4.1.9.0</AssemblyVersion>
<FileVersion>4.1.9.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<!-- Version, adjust before build -->
<PropertyGroup>
<Version>4.1.8</Version>
<Version>4.1.9</Version>
</PropertyGroup>

<!-- Tools -->
Expand Down

0 comments on commit 861bc08

Please sign in to comment.