Skip to content

Commit fac267d

Browse files
Merge pull request #78 from atc-net/feature/Improve-ParseBuildOutput
Feature/improve parse build output
2 parents 22ada59 + 498edd6 commit fac267d

File tree

6 files changed

+59
-36
lines changed

6 files changed

+59
-36
lines changed

src/Atc.CodingRules.AnalyzerProviders/Atc.CodingRules.AnalyzerProviders.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Atc" Version="2.0.67" />
12+
<PackageReference Include="Atc" Version="2.0.69" />
1313
<PackageReference Include="HtmlAgilityPack" Version="1.11.42" />
1414
</ItemGroup>
1515

src/Atc.CodingRules.Updater.CLI/Atc.CodingRules.Updater.CLI.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Atc" Version="2.0.67" />
17-
<PackageReference Include="Atc.Console.Spectre" Version="2.0.67" />
16+
<PackageReference Include="Atc" Version="2.0.69" />
17+
<PackageReference Include="Atc.Console.Spectre" Version="2.0.69" />
1818
<PackageReference Include="EPPlus" Version="5.8.6" />
1919
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
2020
</ItemGroup>

src/Atc.CodingRules.Updater.CLI/ProjectHelper.cs

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Atc.CodingRules.Updater.CLI.Models.Options;
21
using Atc.DotNet;
32
using OfficeOpenXml;
43
using OfficeOpenXml.Style;
@@ -198,40 +197,64 @@ private static async Task HandleTemporarySuppressions(
198197
return;
199198
}
200199

201-
var suppressionLinesPrAnalyzer = GetSuppressionLines(analyzerProviderBaseRules, buildResult);
202-
if (!suppressionLinesPrAnalyzer.Any())
200+
if (buildResult.Any(x => x.Key.StartsWith("MSB", StringComparison.Ordinal)))
203201
{
204-
logger.LogTrace(" No suppressions to add.");
205-
return;
206-
}
207-
208-
await EditorConfigHelper.UpdateRootFileAddCustomAtcAutogeneratedRuleSuppressions(projectPath, suppressionLinesPrAnalyzer);
209-
for (var i = 0; i < MaxNumberOfTimesToBuild; i++)
210-
{
211-
var runAgain = await BuildAndCollectErrorsAgainAndUpdateFile(
212-
logger,
213-
projectPath,
214-
2 + i,
215-
buildFile,
216-
buildResult,
217-
analyzerProviderBaseRules);
202+
var errorTypes = buildResult
203+
.Where(x => x.Key.StartsWith("MSB", StringComparison.Ordinal))
204+
.Select(x => x.Key)
205+
.OrderBy(x => x)
206+
.ToList();
218207

219-
if (!runAgain)
220-
{
221-
break;
222-
}
208+
logger.LogWarning($" MSB-errors ({string.Join(',', errorTypes)}) was found, please correct them manually first and try again.");
223209
}
224-
225-
suppressionLinesPrAnalyzer = GetSuppressionLines(analyzerProviderBaseRules, buildResult);
226-
if (temporarySuppressionsPath is not null)
210+
else if (buildResult.Any(x => x.Key.StartsWith("NU", StringComparison.Ordinal)))
227211
{
228-
await EditorConfigHelper.WriteAllText(projectPath, rootEditorConfigContent);
229-
await CreateSuppressionsFileInTempPath(logger, temporarySuppressionsPath, temporarySuppressionAsExcel, suppressionLinesPrAnalyzer);
212+
var errorTypes = buildResult
213+
.Where(x => x.Key.StartsWith("NU", StringComparison.Ordinal))
214+
.Select(x => x.Key)
215+
.OrderBy(x => x)
216+
.ToList();
217+
218+
logger.LogWarning($" NU-errors ({string.Join(',', errorTypes)}) was found, please correct them manually first and try again.");
230219
}
231220
else
232221
{
233-
var totalSuppressions = suppressionLinesPrAnalyzer.Sum(x => x.Item2.Count);
234-
logger.LogInformation($"{EmojisConstants.FileUpdated} [yellow]/[/]{EditorConfigHelper.FileName} is updated with {totalSuppressions} suppressions");
222+
var suppressionLinesPrAnalyzer = GetSuppressionLines(analyzerProviderBaseRules, buildResult);
223+
if (suppressionLinesPrAnalyzer.Any())
224+
{
225+
await EditorConfigHelper.UpdateRootFileAddCustomAtcAutogeneratedRuleSuppressions(projectPath, suppressionLinesPrAnalyzer);
226+
for (var i = 0; i < MaxNumberOfTimesToBuild; i++)
227+
{
228+
var runAgain = await BuildAndCollectErrorsAgainAndUpdateFile(
229+
logger,
230+
projectPath,
231+
2 + i,
232+
buildFile,
233+
buildResult,
234+
analyzerProviderBaseRules);
235+
236+
if (!runAgain)
237+
{
238+
break;
239+
}
240+
}
241+
242+
suppressionLinesPrAnalyzer = GetSuppressionLines(analyzerProviderBaseRules, buildResult);
243+
if (temporarySuppressionsPath is not null)
244+
{
245+
await EditorConfigHelper.WriteAllText(projectPath, rootEditorConfigContent);
246+
await CreateSuppressionsFileInTempPath(logger, temporarySuppressionsPath, temporarySuppressionAsExcel, suppressionLinesPrAnalyzer);
247+
}
248+
else
249+
{
250+
var totalSuppressions = suppressionLinesPrAnalyzer.Sum(x => x.Item2.Count);
251+
logger.LogInformation($"{EmojisConstants.FileUpdated} [yellow]/[/]{EditorConfigHelper.FileName} is updated with {totalSuppressions} suppressions");
252+
}
253+
}
254+
else
255+
{
256+
logger.LogTrace(" No suppressions to add.");
257+
}
235258
}
236259

237260
stopwatch.Stop();

src/Atc.CodingRules.Updater/Atc.CodingRules.Updater.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Atc" Version="2.0.67" />
9-
<PackageReference Include="Atc.DotNet" Version="2.0.67" />
10-
<PackageReference Include="Atc.Console.Spectre" Version="2.0.67" />
8+
<PackageReference Include="Atc" Version="2.0.69" />
9+
<PackageReference Include="Atc.DotNet" Version="2.0.69" />
10+
<PackageReference Include="Atc.Console.Spectre" Version="2.0.69" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

src/Atc.CodingRules/Atc.CodingRules.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Atc" Version="2.0.67" />
10+
<PackageReference Include="Atc" Version="2.0.69" />
1111
</ItemGroup>
1212

1313
</Project>

test/Atc.CodingRules.AnalyzerProviders.Tests/Atc.CodingRules.AnalyzerProviders.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Atc.XUnit" Version="2.0.67" />
9+
<PackageReference Include="Atc.XUnit" Version="2.0.69" />
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
1111
<PackageReference Include="xunit" Version="2.4.1" />
1212
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">

0 commit comments

Comments
 (0)