diff --git a/src/Microsoft.Android.Build.BaseTasks/MSBuildExtensions.cs b/src/Microsoft.Android.Build.BaseTasks/MSBuildExtensions.cs index b467e83..fd0909d 100644 --- a/src/Microsoft.Android.Build.BaseTasks/MSBuildExtensions.cs +++ b/src/Microsoft.Android.Build.BaseTasks/MSBuildExtensions.cs @@ -135,6 +135,33 @@ public static void LogCodedWarning (this TaskLoggingHelper log, string code, str log.LogWarning (string.Empty, code, string.Empty, file, lineNumber, 0, 0, 0, message, messageArgs); } + /// + /// Logs a coded error from a node in an XML document + /// + /// An element that implements IXmlLineInfo + public static void LogErrorForXmlNode (this TaskLoggingHelper log, string code, string file, object node, string message, params object [] messageArgs) + { + int lineNumber = 0; + int columnNumber = 0; + var lineInfo = node as IXmlLineInfo; + if (lineInfo != null && lineInfo.HasLineInfo ()) { + lineNumber = lineInfo.LineNumber; + columnNumber = lineInfo.LinePosition; + } + log.LogError ( + subcategory: string.Empty, + errorCode: code, + helpKeyword: string.Empty, + file: file, + lineNumber: lineNumber, + columnNumber: columnNumber, + endLineNumber: 0, + endColumnNumber: 0, + message: message, + messageArgs: messageArgs + ); + } + /// /// Logs a coded warning from a node in an XML document ///