public static void ParseMessages(List <ToolMessage> messages, string [] lines, string messageToolName) { foreach (var l in lines) { var line = l; var msg = new ToolMessage(); var origin = string.Empty; if (IndexOfAny(line, out var idxError, out var endError, ": error ", ": error ")) { msg.IsError = true; origin = line.Substring(0, idxError); line = line.Substring(endError); line = RemovePathAtEnd(line); }
public void ParseMessages() { messages.Clear(); foreach (var l in output.ToString().Split('\n')) { var line = l; var msg = new ToolMessage(); var origin = string.Empty; if (IndexOfAny(line, out var idxError, out var endError, ": error ", ": error ")) { msg.IsError = true; origin = line.Substring(0, idxError); line = line.Substring(endError); }
void ParseMessages() { messages.Clear(); foreach (var l in output.ToString().Split('\n')) { var line = l; var msg = new ToolMessage(); if (line.StartsWith("error ", StringComparison.Ordinal)) { msg.IsError = true; line = line.Substring(6); } else if (line.StartsWith("warning ", StringComparison.Ordinal)) { msg.IsError = false; line = line.Substring(8); } else { // something else continue; } if (line.Length < 7) { continue; // something else } msg.Prefix = line.Substring(0, 2); if (!int.TryParse(line.Substring(2, 4), out msg.Number)) { continue; // something else } msg.Message = line.Substring(8); messages.Add(msg); } }
void ParseMessages() { messages.Clear(); foreach (var l in output.ToString().Split('\n')) { var line = l; var msg = new ToolMessage(); var origin = string.Empty; if (line.Contains(": error ")) { msg.IsError = true; var idx = line.IndexOf(": error ", StringComparison.Ordinal); origin = line.Substring(0, idx); line = line.Substring(idx + ": error ".Length); } else if (line.Contains(": warning ")) { var idx = line.IndexOf(": warning ", StringComparison.Ordinal); origin = line.Substring(0, idx); line = line.Substring(idx + ": warning ".Length); } else if (line.StartsWith("error ", StringComparison.Ordinal)) { msg.IsError = true; line = line.Substring(6); } else if (line.StartsWith("warning ", StringComparison.Ordinal)) { msg.IsError = false; line = line.Substring(8); } else { // something else continue; } if (line.Length < 7) { continue; // something else } msg.Prefix = line.Substring(0, 2); if (!int.TryParse(line.Substring(2, 4), out msg.Number)) { continue; // something else } line = line.Substring(8); var toolName = MessageToolName; if (toolName != null && line.StartsWith(toolName + ": ", StringComparison.Ordinal)) { line = line.Substring(toolName.Length + 2); } msg.Message = line; if (!string.IsNullOrEmpty(origin)) { var idx = origin.IndexOf('('); if (idx > 0) { var closing = origin.IndexOf(')'); var number = 0; if (!int.TryParse(origin.Substring(idx + 1, closing - idx - 1), out number)) { continue; } msg.LineNumber = number; msg.FileName = origin.Substring(0, idx); } else { msg.FileName = origin; } } messages.Add(msg); } }