Skip to content

Commit

Permalink
[Build Tasks] Add LogErrorForXmlNode (#209)
Browse files Browse the repository at this point in the history
Adds a copy of LogWarningForXmlNode that logs an error instead of a
warning.
  • Loading branch information
pjcollins authored May 31, 2023
1 parent 3b8c467 commit 44885bc
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Microsoft.Android.Build.BaseTasks/MSBuildExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/// <summary>
/// Logs a coded error from a node in an XML document
/// </summary>
/// <param name="node">An element that implements IXmlLineInfo</param>
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
);
}

/// <summary>
/// Logs a coded warning from a node in an XML document
/// </summary>
Expand Down

0 comments on commit 44885bc

Please sign in to comment.