in src/StructuredLogViewer/Controls/BuildControl.xaml.cs [1586:1646]
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);
}
break;
case Target target:
return DisplayTarget(target.SourceFilePath, target.Name);
case Task task:
return DisplayTask(task);
case AddItem addItem:
return DisplayAddRemoveItem(addItem.Parent, addItem.LineNumber ?? 0);
case RemoveItem removeItem:
return DisplayAddRemoveItem(removeItem.Parent, removeItem.LineNumber ?? 0);
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);
default:
return false;
}
}
catch
{
// in case our guessing of file path goes awry
}
return false;
}