Skip to content

Commit 7f8c08c

Browse files
Testing on OSX. Update path handling to be more cross-platform.
1 parent 30a1090 commit 7f8c08c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

UnityPerformanceBenchmarkReporter/Report/ReportWriter.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Text;
88
using System.Text.RegularExpressions;
99
using UnityPerformanceBenchmarkReporter.Entities;
10+
using System.Runtime.InteropServices;
1011

1112
namespace UnityPerformanceBenchmarkReporter.Report
1213
{
@@ -34,6 +35,7 @@ public class ReportWriter
3435
private bool thisHasBenchmarkResults;
3536
private MetadataValidator metadataValidator;
3637
private bool vrSupported = false;
38+
private char pathSeperator = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? '\\' : '/';
3739

3840
public ReportWriter(Dictionary<string, string[]> excludedTestConfigs = null)
3941
{
@@ -101,7 +103,8 @@ private static FileStream TryCreateHtmlFile(string htmlFileName)
101103

102104
private void WriteEmbeddedResourceFiles(DirectoryInfo benchmarkDirectory)
103105
{
104-
var assemblyNameParts = Assembly.GetExecutingAssembly().Location.Split('\\');
106+
var assemblyNameParts = Assembly.GetExecutingAssembly().Location.Split(pathSeperator);
107+
105108
var assemblyName = assemblyNameParts[assemblyNameParts.Length - 1].Split('.')[0];
106109

107110
foreach (var embeddedResourceName in embeddedResourceNames)
@@ -468,6 +471,7 @@ private void WriteToggleCanvasWithNoFailures(StreamWriter rw)
468471
private void WriteHeader(StreamWriter rw)
469472
{
470473
rw.WriteLine("<head>");
474+
rw.WriteLine("<meta charset=\"utf-8\"/>");
471475
rw.WriteLine("<title>Unity Performance Benchmark Report</title>");
472476
rw.WriteLine("<script src=\"Chart.bundle.js\"></script>");
473477
rw.WriteLine("<link rel=\"stylesheet\" href=\"styles.css\">");
@@ -766,8 +770,8 @@ private void WriteClassNameWithFields<T>(StreamWriter rw, object instance, strin
766770
? mismatchedValue.First(kv => kv.Key.Equals(resultFile)).Value
767771
: baselineValue;
768772

769-
var pathParts = resultFile.Split('\\');
770-
var path = string.Join('\\', pathParts.Take(pathParts.Length - 1));
773+
var pathParts = resultFile.Split(pathSeperator);
774+
var path = string.Join(pathSeperator, pathParts.Take(pathParts.Length - 1));
771775

772776

773777
sb.Append(string.Format(

0 commit comments

Comments
 (0)