-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidationReporter.cs
More file actions
37 lines (30 loc) · 1018 Bytes
/
Copy pathValidationReporter.cs
File metadata and controls
37 lines (30 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using JulianVerdurmen.SlnxValidator.Core.ValidationResults;
namespace JulianVerdurmen.SlnxValidator;
internal static class ValidationReporter
{
public static async Task Report(IReadOnlyList<FileValidationResult> results)
{
foreach (var result in results)
{
Console.WriteLine(result.HasErrors ? $"[FAIL] {result.File}" : $"[OK] {result.File}");
}
var failedResults = results.Where(r => r.HasErrors).ToList();
if (failedResults.Count == 0)
{
return;
}
Console.WriteLine();
foreach (var result in failedResults)
{
foreach (var error in result.Errors)
{
await Console.Error.WriteLineAsync(FormatError(error));
}
}
}
private static string FormatError(ValidationError error)
{
var location = error.Line is null ? "" : $"line {error.Line}: ";
return $" - {location}[{error.Code.ToCode()}] {error.Message}";
}
}