protected void LogEventsFromTextOutput(string singleLine, MessageImportance messageImportance, bool apptResult) { if (string.IsNullOrEmpty(singleLine)) { return; } var match = AndroidToolTask.AndroidErrorRegex.Match(singleLine.Trim()); if (match.Success) { var file = match.Groups["file"].Value; int line = 0; if (!string.IsNullOrEmpty(match.Groups["line"]?.Value)) { line = int.Parse(match.Groups["line"].Value.Trim()) + 1; } var level = match.Groups["level"].Value.ToLowerInvariant(); var message = match.Groups ["message"].Value; if (message.Contains("fakeLogOpen")) { LogMessage(singleLine, MessageImportance.Normal); return; } if (level.Contains("warning")) { LogCodedWarning("APT0000", singleLine); return; } // Try to map back to the original resource file, so when the user // double clicks the error, it won't take them to the obj/Debug copy string newfile = MonoAndroidHelper.FixUpAndroidResourcePath(file, resourceDirectory, string.Empty, resource_name_case_map); if (!string.IsNullOrEmpty(newfile)) { file = newfile; } // Strip any "Error:" text from aapt's output if (message.StartsWith("error: ", StringComparison.InvariantCultureIgnoreCase)) { message = message.Substring("error: ".Length); } if (level.Contains("error") || (line != 0 && !string.IsNullOrEmpty(file))) { LogCodedError("APT0000", message, file, line); return; } } if (!apptResult) { LogCodedError("APT0000", string.Format("{0} \"{1}\".", singleLine.Trim(), singleLine.Substring(singleLine.LastIndexOfAny(new char [] { '\\', '/' }) + 1)), ToolName); } else { LogCodedWarning("APT0000", singleLine); } }
protected bool LogAapt2EventsFromOutput(string singleLine, MessageImportance messageImportance, bool apptResult) { if (string.IsNullOrEmpty(singleLine)) { return(true); } var match = AndroidToolTask.AndroidErrorRegex.Match(singleLine.Trim()); if (match.Success) { var file = match.Groups ["file"].Value; int line = 0; if (!string.IsNullOrEmpty(match.Groups ["line"]?.Value)) { line = int.Parse(match.Groups ["line"].Value.Trim()) + 1; } var level = match.Groups ["level"].Value.ToLowerInvariant(); var message = match.Groups ["message"].Value; // Handle the following which is NOT an error :( // W/ResourceType(23681): For resource 0x0101053d, entry index(1341) is beyond type entryCount(733) // W/ResourceType( 3681): For resource 0x0101053d, entry index(1341) is beyond type entryCount(733) if (file.StartsWith("W/", StringComparison.OrdinalIgnoreCase)) { LogCodedWarning("APT0000", singleLine); return(true); } if (message.StartsWith("unknown option", StringComparison.OrdinalIgnoreCase)) { // we need to filter out the remailing help lines somehow. LogCodedError("APT0001", $"{message}. This is the result of using `aapt` command line arguments with `aapt2`. The arguments are not compatible."); return(false); } if (message.Contains("fakeLogOpen")) { LogMessage(singleLine, messageImportance); return(true); } if (message.Contains("note:")) { LogMessage(singleLine, messageImportance); return(true); } if (message.Contains("warn:")) { LogCodedWarning("APT0000", singleLine); return(true); } if (level.Contains("note")) { LogMessage(message, messageImportance); return(true); } if (level.Contains("warning")) { LogCodedWarning("APT0000", singleLine); return(true); } // Try to map back to the original resource file, so when the user // double clicks the error, it won't take them to the obj/Debug copy if (ResourceDirectories != null) { foreach (var dir in ResourceDirectories) { var resourceDirectory = dir.ItemSpec; var resourceDirectoryFullPath = ResourceDirectoryFullPath(resourceDirectory); string newfile = MonoAndroidHelper.FixUpAndroidResourcePath(file, resourceDirectory, resourceDirectoryFullPath, resource_name_case_map); if (!string.IsNullOrEmpty(newfile)) { file = newfile; break; } } } // Strip any "Error:" text from aapt's output if (message.StartsWith("error: ", StringComparison.InvariantCultureIgnoreCase)) { message = message.Substring("error: ".Length); } if (level.Contains("error") || (line != 0 && !string.IsNullOrEmpty(file))) { LogCodedError("APT0000", message, file, line); return(true); } } if (!apptResult) { LogCodedError("APT0000", string.Format("{0} \"{1}\".", singleLine.Trim(), singleLine.Substring(singleLine.LastIndexOfAny(new char [] { '\\', '/' }) + 1)), ToolName); } else { LogCodedWarning("APT0000", singleLine); } return(true); }
protected override void LogEventsFromTextOutput(string singleLine, MessageImportance messageImportance) { var match = codeErrorRegEx.Match(singleLine); if (!match.Success) { match = noFileWarningOrErrorRegEx.Match(singleLine); } if (match.Success) { if (matched) { // we are already in a warning/error ... // dont loose it GenerateErrorOrWarning(); } matched = true; file = match.Groups ["file"].Value; if (!string.IsNullOrEmpty(file)) { file = Path.Combine(TargetDirectory, file); // Try to map back to the original resource file, so when the user // double clicks the error, it won't take them to the obj/Debug copy if (ResourceDirectories != null) { foreach (var dir in ResourceDirectories) { var resourceDirectory = Path.Combine(TargetDirectory, dir.ItemSpec); string newfile = MonoAndroidHelper.FixUpAndroidResourcePath(file, resourceDirectory, string.Empty, resource_name_case_map); if (!string.IsNullOrEmpty(newfile)) { file = newfile; break; } } } } line = 0; int.TryParse(match.Groups ["line"].Value, out line); text = match.Groups ["text"].Value.Trim(); type = match.Groups ["type"].Value; if (string.IsNullOrEmpty(type)) { type = text.Contains("Error") ? "Error" : "Warning"; } column = 0; } if (matched) { if (singleLine.Trim() == "^") { column = singleLine.IndexOf("^"); GenerateErrorOrWarning(); } if (singleLine.Trim().Contains("~")) { column = singleLine.IndexOf("~"); GenerateErrorOrWarning(); } } else { base.LogEventsFromTextOutput(singleLine, messageImportance); } }