public static ScanningReport ScanManifestFile(string filePath) { if (!File.Exists(filePath)) { new FileNotFoundException(filePath); } var scanningReport = new ScanningReport(); int counter = 0; using var reader = new StreamReader(filePath); var fileReport = new FileReport(); try { var fileContent = reader.ReadToEnd(); fileReport.FilePath = filePath; AssertCgManifestContent(fileContent, fileReport); } catch (Exception ex) { fileReport.UnexpectedExceptionMessage = ex.Message; } scanningReport.FilesReport.Add(fileReport); counter++; scanningReport.NumberFilesScanned = 1; return(scanningReport); }
private static IList <FileReport> FailedFilesReport(ScanningReport report) { var filesFailed = new List <FileReport>(); foreach (var fileReport in report.FilesReport) { if (!string.IsNullOrWhiteSpace(fileReport.UnexpectedExceptionMessage) || fileReport.ComponentReport.Any(cr => !cr.ValidationPassed)) { filesFailed.Add(fileReport); } } return(filesFailed); }
public static void Print(ScanningReport report) { Console.WriteLine($"Number of files scanned: {report.NumberFilesScanned}"); var failedFilesReport = FailedFilesReport(report); Console.WriteLine($"Number of files succeeded: {report.NumberFilesScanned - failedFilesReport.Count}"); Console.WriteLine($"Number of files failed: {failedFilesReport.Count}"); Console.WriteLine(); if (failedFilesReport.Any()) { PrintFailedFiles(failedFilesReport); } else { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Succeeded!!!"); Console.ForegroundColor = ConsoleColor.White; } }