Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build Tasks] Add LogErrorForXmlNode #209

Merged
merged 1 commit into from
May 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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