From db5b759768f38495b29f77b2cbd2c18522e3e7b7 Mon Sep 17 00:00:00 2001 From: Andrew Stanton Date: Sat, 3 Feb 2018 18:19:20 -0500 Subject: [PATCH 1/2] added -ReportSummary switch to emit an additional single line count of error, warning, and info results --- .../Commands/InvokeScriptAnalyzerCommand.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Engine/Commands/InvokeScriptAnalyzerCommand.cs b/Engine/Commands/InvokeScriptAnalyzerCommand.cs index 4719a51a1..7bbc8d2a6 100644 --- a/Engine/Commands/InvokeScriptAnalyzerCommand.cs +++ b/Engine/Commands/InvokeScriptAnalyzerCommand.cs @@ -243,7 +243,19 @@ public SwitchParameter AttachAndDebug set { attachAndDebug = value; } } private bool attachAndDebug = false; + #endif + /// + /// If true, reports an additional single line summary of issue counts. + /// + [Parameter(Mandatory = false)] + public SwitchParameter ReportSummary + { + get { return reportSummary; } + set { reportSummary = value; } + } + private SwitchParameter reportSummary; + #endregion Parameters #region Overrides @@ -424,9 +436,32 @@ private void WriteToOutput(IEnumerable diagnosticRecords) { foreach (ILogger logger in ScriptAnalyzer.Instance.Loggers) { + var errorCount = 0; + var warningCount = 0; + var infoCount = 0; + foreach (DiagnosticRecord diagnostic in diagnosticRecords) { logger.LogObject(diagnostic, this); + switch (diagnostic.Severity) + { + case DiagnosticSeverity.Information: + infoCount++; + break; + case DiagnosticSeverity.Warning: + warningCount++; + break; + case DiagnosticSeverity.Error: + errorCount++; + break; + default: + throw new ArgumentOutOfRangeException(nameof(diagnostic.Severity), $"Severity '{diagnostic.Severity}' is unknown"); + } + } + + if (ReportSummary.IsPresent) + { + logger.LogObject($"{DiagnosticSeverity.Error} : {errorCount} \t {DiagnosticSeverity.Warning} : {warningCount} \t {DiagnosticSeverity.Information} : {infoCount}", this); } } From a8dbb1f10f0dfb4e7daf98f5d507efe64b33a2e3 Mon Sep 17 00:00:00 2001 From: Andrew Stanton Date: Sun, 4 Feb 2018 00:45:45 -0500 Subject: [PATCH 2/2] changing ReportSummary to write-host --- Engine/Commands/InvokeScriptAnalyzerCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/Commands/InvokeScriptAnalyzerCommand.cs b/Engine/Commands/InvokeScriptAnalyzerCommand.cs index 7bbc8d2a6..03fe965bc 100644 --- a/Engine/Commands/InvokeScriptAnalyzerCommand.cs +++ b/Engine/Commands/InvokeScriptAnalyzerCommand.cs @@ -461,7 +461,7 @@ private void WriteToOutput(IEnumerable diagnosticRecords) if (ReportSummary.IsPresent) { - logger.LogObject($"{DiagnosticSeverity.Error} : {errorCount} \t {DiagnosticSeverity.Warning} : {warningCount} \t {DiagnosticSeverity.Information} : {infoCount}", this); + Host.UI.WriteLine($"{DiagnosticSeverity.Error} : {errorCount} \t {DiagnosticSeverity.Warning} : {warningCount} \t {DiagnosticSeverity.Information} : {infoCount}"); } }