Skip to content

Commit fd2d099

Browse files
committed
Copying HTML file to Analyzed Project folder
1 parent 7a89bb7 commit fd2d099

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

UnityEngineAnalyzer.CLI/Reporting/JsonAnalyzerExporter.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
using System;
2+
using System.Diagnostics;
23
using System.IO;
34
using Newtonsoft.Json;
45

56
namespace 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)

UnityEngineAnalyzer.CLI/UnityEngineAnalyzer.CLI.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@
127127
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
128128
</ItemGroup>
129129
<ItemGroup>
130-
<Content Include="UnityReport.html" />
130+
<Content Include="UnityReport.html">
131+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
132+
</Content>
131133
</ItemGroup>
132134
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
133135
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

0 commit comments

Comments
 (0)