File tree Expand file tree Collapse file tree
Philips.CodeAnalysis.Common
Philips.CodeAnalysis.Test/Common Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6565 dotnet_diagnostic.IDE0290.severity = none
6666 dotnet_diagnostic.IDE0300.severity = none
6767 dotnet_diagnostic.IDE0301.severity = none
68+ dotnet_diagnostic.IDE0303.severity = none
6869 dotnet_diagnostic.IDE0305.severity = none
6970 dotnet_diagnostic.PH2006.severity = none
7071 dotnet_diagnostic.PH2015.severity = none
@@ -113,4 +114,3 @@ jobs:
113114 ./Philips.CodeAnalysis.AnalyzerPerformance/bin/Release/net8.0/Philips.CodeAnalysis.AnalyzerPerformance msbuild.binlog Philips.CodeAnalysis >> PerformanceSummary.txt
114115 cat ./PerformanceSummary.txt
115116 cat ./PerformanceSummary.txt >> $GITHUB_STEP_SUMMARY
116-
Original file line number Diff line number Diff line change @@ -10,10 +10,29 @@ public sealed class AnalyzerPerformanceRecord : IComparable<AnalyzerPerformanceR
1010 {
1111 public static AnalyzerPerformanceRecord TryParse ( string name )
1212 {
13- var analyzerAndId = name . Split ( ' ' ) ;
14- var id = analyzerAndId [ 1 ] . Substring ( 1 , analyzerAndId [ 1 ] . Length - 2 ) ;
13+ if ( string . IsNullOrWhiteSpace ( name ) )
14+ {
15+ return null ;
16+ }
17+
18+ var analyzerAndId = name . Split ( ( char [ ] ) null , StringSplitOptions . RemoveEmptyEntries ) ;
19+ if ( analyzerAndId . Length < 4 )
20+ {
21+ return null ;
22+ }
23+
24+ var idPart = analyzerAndId [ 1 ] ;
25+ if ( idPart . Length < 2 || idPart [ 0 ] != '"' || idPart [ idPart . Length - 1 ] != '"' )
26+ {
27+ return null ;
28+ }
29+ var id = idPart . Substring ( 1 , idPart . Length - 2 ) ;
1530
1631 var analyzerParts = analyzerAndId [ 0 ] . Split ( '.' ) ;
32+ if ( analyzerParts . Length < 3 )
33+ {
34+ return null ;
35+ }
1736 var package = analyzerParts [ 2 ] ;
1837 var analyzer = analyzerParts [ analyzerParts . Length - 1 ] ;
1938
Original file line number Diff line number Diff line change @@ -47,6 +47,20 @@ public void ParsedIncorrectly()
4747 Assert . IsNull ( actual ) ;
4848 }
4949
50+ [ TestMethod ]
51+ [ TestCategory ( TestDefinitions . UnitTests ) ]
52+ public void ParsedUnexpectedFormat ( )
53+ {
54+ // Arrange
55+ const string testName = "Compiler diagnostics" ;
56+
57+ // Act
58+ var actual = AnalyzerPerformanceRecord . TryParse ( testName ) ;
59+
60+ // Assert
61+ Assert . IsNull ( actual ) ;
62+ }
63+
5064 [ TestMethod ]
5165 [ TestCategory ( TestDefinitions . UnitTests ) ]
5266 public void SortsLargestTimeFirst ( )
You can’t perform that action at this time.
0 commit comments