in src/StructuredLogViewer.Avalonia/Controls/BuildControl.xaml.cs [816:881]
private bool Invoke(BaseNode treeNode)
{
if (treeNode == null)
{
return false;
}
try
{
switch (treeNode)
{
case AbstractDiagnostic diagnostic:
var path = diagnostic.File;
if (!DisplayFile(path, diagnostic.LineNumber) &&
path != null &&
!Path.IsPathRooted(path) &&
diagnostic.ProjectFile != null)
{
// path must be relative, try to normalize:
path = Path.Combine(Path.GetDirectoryName(diagnostic.ProjectFile), path);
return DisplayFile(path, diagnostic.LineNumber, diagnostic.ColumnNumber);
}
if (diagnostic.IsTextShortened)
{
return DisplayText(diagnostic.Text, diagnostic.GetType().Name);
}
break;
case Target target:
return DisplayTarget(target.SourceFilePath, target.Name);
case Task task:
return DisplayTask(task.SourceFilePath, task.Parent, task.Name);
case IHasSourceFile hasSourceFile when hasSourceFile.SourceFilePath != null:
int line = 0;
var hasLine = hasSourceFile as IHasLineNumber;
if (hasLine != null)
{
line = hasLine.LineNumber ?? 0;
}
ProjectEvaluation evaluation = null;
if (hasSourceFile is TreeNode node)
{
// TODO: https://github.com/KirillOsenkov/MSBuildStructuredLog/issues/392
evaluation = node.GetNearestParentOrSelf<ProjectEvaluation>();
}
return DisplayFile(hasSourceFile.SourceFilePath, line, evaluation: evaluation);
case SourceFileLine sourceFileLine when sourceFileLine.Parent is SourceFile sourceFile && sourceFile.SourceFilePath != null:
return DisplayFile(sourceFile.SourceFilePath, sourceFileLine.LineNumber);
case NameValueNode nameValueNode when nameValueNode.IsValueShortened:
return DisplayText(nameValueNode.Value, nameValueNode.Name);
case TextNode textNode when textNode.IsTextShortened:
return DisplayText(textNode.Text, textNode.Name ?? textNode.GetType().Name);
default:
return false;
}
}
catch
{
// in case our guessing of file path goes awry
}
return false;
}