public DiagnosticResult(IDiagnosticResult result) { this.Code = result.Code; this.Message = result.Message; this.Project = result.Project; this.Location = result.Location; }
public DiagnosticResult(IDiagnosticResult result) { Code = result.Code; Message = result.Message; Project = result.Project; Location = result.Location; }
/// <inheritdoc /> protected override void Report(IDiagnosticResult result, LoggerReporterOptions reporterOptions) { var consoleHeader = $"{result.Code}: "; string linePadding; { var pad = new StringBuilder(consoleHeader.Length, consoleHeader.Length); pad.Append(' ', consoleHeader.Length); linePadding = pad.ToString(); } var message = result.Message.Trim(); var sourcePath = result.Location.GetSourcePath(); var sourceLine = result.Location.SourceLine; switch (sourcePath) { case string _ when sourceLine != uint.MaxValue: message = $"{sourcePath}:{sourceLine}: {message}"; break; case string _ when sourceLine == uint.MaxValue: message = $"{sourcePath}: {message}"; break; case null when sourceLine != uint.MaxValue: message = $"{sourceLine}: {message}"; break; case null when sourceLine == uint.MaxValue: default: break; } this.logger.LogInformation(consoleHeader + Environment.NewLine + message); }
public static IDiagnosticResult LoadLocationFromElement(this IDiagnosticResult self, XElement element) { if (self == null) { throw new ArgumentNullException(nameof(self)); } if (element == null) { throw new ArgumentNullException(nameof(element)); } if (self.Location.SourceLine != uint.MaxValue) { return(self); } if (element is IXmlLineInfo elementOnLine && elementOnLine.HasLineInfo()) { return(new DiagnosticResult(self) { Location = new DiagnosticLocation(self.Location) { SourceLine = (uint)elementOnLine.LineNumber } }); } return(self); }
private static void PrintResult(IDiagnosticResult result) { Debug.LogWarning($"-------- <b>{result.Name}</b> --------"); foreach (var line in result.Summary.Trim().Split('\n')) { Debug.LogWarning(line); } }
/// <inheritdoc /> protected override void Report(IDiagnosticResult result, ConsoleReporterOptions reporterOptions) { var consoleHeader = $"{result.Code}: "; string linePadding; { var pad = new StringBuilder(consoleHeader.Length, consoleHeader.Length); pad.Append(' ', consoleHeader.Length); linePadding = pad.ToString(); } Console.Write(consoleHeader); var message = result.Message.Trim(); var sourcePath = result.Location.GetSourcePath(); var sourceLine = result.Location.SourceLine; switch (sourcePath) { case string _ when sourceLine != uint.MaxValue: message = $"{sourcePath}:{sourceLine}: {message}"; break; case string _ when sourceLine == uint.MaxValue: message = $"{sourcePath}: {message}"; break; case null when sourceLine != uint.MaxValue: message = $"{sourceLine}: {message}"; break; case null when sourceLine == uint.MaxValue: default: break; } uint messageLineIndex = 0; foreach (var messageLine in message.Split('\n')) { if (messageLineIndex != 0) { Console.Write(linePadding); } Console.WriteLine(messageLine); ++messageLineIndex; } }
protected abstract void Report(IDiagnosticResult result, TOptions reporterOptions);