-
-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easy report generation #247
Conversation
@@ -237,32 +237,35 @@ public virtual void CreateSummaryReport(IReportRenderer reportRenderer, SummaryR | |||
reportRenderer.MetricsTable(new[] { methodMetric }); | |||
} | |||
|
|||
if (reportRenderer.SupportsRiskHotsSpots | |||
&& this.ReportContext.RiskHotspotAnalysisResult.CodeCodeQualityMetricsAvailable) | |||
if (this.ReportContext.RiskHotspotAnalysisResult != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can achieve the same result, with much less code and fewer changes in ReportGenerator. The following sample demonstrates how to use the higher level APIs: using ...
namespace htmlreport
{
class Program
{
static void Main(string[] args)
{
CreateHTMLReport(new List<string>() { @"D:\CodeCoverageReport_8440364\coverage.xml" });
}
private static void CreateHTMLReport(IEnumerable<string> coverageFiles)
{
var folder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(folder);
var reportConfigurationBuilder = new ReportConfigurationBuilder();
ReportConfiguration configuration = reportConfigurationBuilder.Create(new Dictionary<string, string>() {
{ "reports", string.Join(";", coverageFiles) }
{ "targetdir", folder },
{ "reporttypes", "HtmlInline_AzurePipelines" }
});
new Generator().GenerateReport(configuration);
}
}
} What do you think? |
My original idea was to modify Generator.cs itself. I wanted to separate parsing and report creation for scenarios where only parsing is required. |
My recommendation is to:
Don't use the (currently internal classes). If they become public and you start using them, it would become very hard for me to change the internal behavior without breaking your code. |
@danielpalme, is there a way to generate HTML reports based on the My ask here is to decouple these two operations. I can think of two ways of doing this without exposing internal classes,
It's possible in my scenario that first we parse the files and decide later on in time whether to create HTML reports or not, hence decoupling the two operations would make doing that simpler. Let me know if this makes sense and I can raise a PR. |
I will have a look at this tomorrow. |
I added a two new overloads of
This (pre-)release contains the new methods: |
ReportConfigurationBuilder
ReportConfiguration
from a dictionaryRiskHotspotAnalysisResult
inReportBuilderBase
ReportContext
ReportGenerator
CachingFileReader
IFileReader
Creating reports using the SDK becomes as simple as: