11using System ;
2+ using System . Diagnostics ;
23using System . IO ;
34using Newtonsoft . Json ;
45
56namespace UnityEngineAnalyzer . CLI . Reporting
67{
78 public class JsonAnalyzerExporter : IAnalyzerExporter
89 {
9- private const string ReportFileName = "report.json" ;
10+ private const string JsonReportFileName = "report.json" ;
11+ private const string HtmlReportFileName = "UnityReport.html" ;
1012 private const DiagnosticInfoSeverity MinimalSeverity = DiagnosticInfoSeverity . Warning ;
1113
1214
1315 private JsonTextWriter _jsonWriter ;
1416 private readonly JsonSerializer _jsonSerializer = new JsonSerializer ( ) ;
17+ private string _destinationReportFile ;
18+
1519
1620 public void AppendDiagnostic ( DiagnosticInfo diagnosticInfo )
1721 {
@@ -26,6 +30,12 @@ public void Finish(TimeSpan duration)
2630 _jsonWriter . WriteEndArray ( ) ;
2731 _jsonWriter . WriteEndObject ( ) ;
2832 _jsonWriter . Close ( ) ;
33+
34+
35+ File . Copy ( HtmlReportFileName , _destinationReportFile , true ) ;
36+
37+ //NOTE: This code might be temporary as it assumes that the CLI is being executed interactively
38+ //Process.Start(_destinationReportFile);
2939 }
3040
3141 public void InitializeExporter ( FileInfo projectFile )
@@ -34,8 +44,9 @@ public void InitializeExporter(FileInfo projectFile)
3444 {
3545 throw new ArgumentException ( "Project file does not exist" ) ;
3646 }
37-
38- var jsonFilePath = Path . Combine ( projectFile . DirectoryName , ReportFileName ) ;
47+
48+ _destinationReportFile = Path . Combine ( projectFile . DirectoryName , HtmlReportFileName ) ;
49+ var jsonFilePath = Path . Combine ( projectFile . DirectoryName , JsonReportFileName ) ;
3950 var jsonFile = new FileInfo ( jsonFilePath ) ;
4051
4152 if ( jsonFile . Exists )
0 commit comments