77using System . Text ;
88using System . Text . RegularExpressions ;
99using UnityPerformanceBenchmarkReporter . Entities ;
10+ using System . Runtime . InteropServices ;
1011
1112namespace UnityPerformanceBenchmarkReporter . Report
1213{
@@ -20,7 +21,8 @@ public class ReportWriter
2021 "styles.css" ,
2122 "UnityLogo.png" ,
2223 "warning.png" ,
23- "help.png"
24+ "help.png" ,
25+ "help-hover.png"
2426 } ;
2527
2628 private readonly Dictionary < string , string [ ] > excludedConfigFieldNames = new Dictionary < string , string [ ] > ( ) ;
@@ -32,6 +34,8 @@ public class ReportWriter
3234 private uint thisSigFig ;
3335 private bool thisHasBenchmarkResults ;
3436 private MetadataValidator metadataValidator ;
37+ private bool vrSupported = false ;
38+ private char pathSeperator = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? '\\ ' : '/' ;
3539
3640 public ReportWriter ( Dictionary < string , string [ ] > excludedTestConfigs = null )
3741 {
@@ -99,7 +103,8 @@ private static FileStream TryCreateHtmlFile(string htmlFileName)
99103
100104 private void WriteEmbeddedResourceFiles ( DirectoryInfo benchmarkDirectory )
101105 {
102- var assemblyNameParts = Assembly . GetExecutingAssembly ( ) . Location . Split ( '\\ ' ) ;
106+ var assemblyNameParts = Assembly . GetExecutingAssembly ( ) . Location . Split ( pathSeperator ) ;
107+
103108 var assemblyName = assemblyNameParts [ assemblyNameParts . Length - 1 ] . Split ( '.' ) [ 0 ] ;
104109
105110 foreach ( var embeddedResourceName in embeddedResourceNames )
@@ -466,6 +471,7 @@ private void WriteToggleCanvasWithNoFailures(StreamWriter rw)
466471 private void WriteHeader ( StreamWriter rw )
467472 {
468473 rw . WriteLine ( "<head>" ) ;
474+ rw . WriteLine ( "<meta charset=\" utf-8\" />" ) ;
469475 rw . WriteLine ( "<title>Unity Performance Benchmark Report</title>" ) ;
470476 rw . WriteLine ( "<script src=\" Chart.bundle.js\" ></script>" ) ;
471477 rw . WriteLine ( "<link rel=\" stylesheet\" href=\" styles.css\" >" ) ;
@@ -726,9 +732,15 @@ private void WriteClassNameWithFields<T>(StreamWriter rw, object instance, strin
726732
727733 var sb = new StringBuilder ( ) ;
728734
729- foreach ( var field in thisObject . GetType ( ) . GetFields ( ) )
735+ if ( thisObject . GetType ( ) . GetFields ( ) . Any ( f => f . Name . Equals ( "VrSupported" ) ) )
730736 {
737+ vrSupported = ( bool ) thisObject . GetType ( ) . GetFields ( ) . First ( f => f . Name . Equals ( "VrSupported" ) ) . GetValue ( thisObject ) ;
738+ }
739+
740+
731741
742+ foreach ( var field in thisObject . GetType ( ) . GetFields ( ) )
743+ {
732744 if ( excludedFieldNames != null && excludedFieldNames . Contains ( field . Name ) )
733745 {
734746 continue ;
@@ -758,8 +770,8 @@ private void WriteClassNameWithFields<T>(StreamWriter rw, object instance, strin
758770 ? mismatchedValue . First ( kv => kv . Key . Equals ( resultFile ) ) . Value
759771 : baselineValue ;
760772
761- var pathParts = resultFile . Split ( ' \\ ' ) ;
762- 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 ) ) ;
763775
764776
765777 sb . Append ( string . Format (
@@ -812,26 +824,42 @@ private static bool TypeHasValidMismatches<T>(Dictionary<string, Dictionary<stri
812824
813825 private object GetFieldValues < T > ( FieldInfo field , T thisObject )
814826 {
815- return IsIEnumerableFieldType ( field ) ? ConvertIEnumberableToString ( field , thisObject ) : field . GetValue ( thisObject ) ;
827+ return IsIEnumerableFieldType ( field ) ? ConvertIEnumberableToString ( field , thisObject ) : GetValue ( field , thisObject ) ;
828+ }
829+
830+ private object GetValue < T > ( FieldInfo field , T thisObject )
831+ {
832+ return
833+ ( field . Name . Equals ( "StereoRenderingPath" ) || field . Name . Equals ( "XrModel" ) || field . Name . Equals ( "XrDevice" ) ) && ! vrSupported ?
834+ "None" :
835+ field . GetValue ( thisObject ) ;
816836 }
817837
818- private static bool IsIEnumerableFieldType ( FieldInfo field )
838+ private bool IsIEnumerableFieldType ( FieldInfo field )
819839 {
820840 return typeof ( IEnumerable ) . IsAssignableFrom ( field . FieldType ) && field . FieldType != typeof ( string ) ;
821841 }
822842
823843 private string ConvertIEnumberableToString < T > ( FieldInfo field , T thisObject )
824844 {
825845 var sb = new StringBuilder ( ) ;
826- foreach ( var enumerable in ( IEnumerable ) field . GetValue ( thisObject ) )
846+ var fieldValues = ( ( IEnumerable ) field . GetValue ( thisObject ) ) as List < string > ;
847+ if ( fieldValues != null && fieldValues . Any ( ) )
827848 {
828- sb . Append ( enumerable + "," ) ;
829- }
849+ foreach ( var enumerable in fieldValues )
850+ {
851+ sb . Append ( enumerable + "," ) ;
852+ }
830853
831- if ( sb . ToString ( ) . EndsWith ( ',' ) )
854+ if ( sb . ToString ( ) . EndsWith ( ',' ) )
855+ {
856+ // trim trailing comma
857+ sb . Length -- ;
858+ }
859+ }
860+ else
832861 {
833- // trim trailing comma
834- sb . Length -- ;
862+ sb . Append ( "None" ) ;
835863 }
836864
837865 return sb . ToString ( ) ;
0 commit comments