Skip to content

Commit ded212c

Browse files
Copilotbcollamore
andauthored
ci: Fix performance workflow dogfood build failures and harden analyzer summary parsing (#1120)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bcollamore <57269455+bcollamore@users.noreply.github.com>
1 parent 6f94db7 commit ded212c

3 files changed

Lines changed: 36 additions & 3 deletions

File tree

.github/workflows/performance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ jobs:
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-

Philips.CodeAnalysis.Common/AnalyzerPerformanceRecord.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff 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

Philips.CodeAnalysis.Test/Common/AnalyzerPerformanceRecordTest.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff 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()

0 commit comments

Comments
 (0)