in src/StructuredLogViewer/Controls/TracingControl.xaml.cs [770:873]
private List<Block> ComputeVisibleBlocks(IEnumerable<Block> enumBlocks)
{
double pixelDuration = ConvertPixelToTime(1);
bool showCppBlocks = ShowCpp && this.numberOfCpp > 0;
var blocks = enumBlocks.Where(b =>
{
if (b.Duration.Ticks < pixelDuration)
{
return false;
}
switch (b.Node)
{
case ProjectEvaluation:
return ShowEvaluation;
case Project:
return ShowProject;
case Target:
return ShowTarget && !ignoreCommonP2PTargets.Contains((b.Node as Target).Name);
case Microsoft.Build.Logging.StructuredLogger.Task node:
// When ShowCpp is enabled, hide the task and show the messages so that only one of them will appear.
if (showCppBlocks && node is CppAnalyzer.CppTask cppNode && cppNode.HasTimedBlocks)
{
return false;
}
return ShowTask;
case Message:
return ShowCpp && ShowTask;
default:
return false;
}
}).ToList();
if (blocks.Count == 0)
{
return null;
}
var endpoints = new List<BlockEndpoint>();
foreach (var block in blocks)
{
block.StartPoint = new BlockEndpoint()
{
Block = block,
Timestamp = block.StartTime.Ticks,
IsStart = true
};
block.EndPoint = new BlockEndpoint()
{
Block = block,
Timestamp = block.EndTime.Ticks
};
endpoints.Add(block.StartPoint);
endpoints.Add(block.EndPoint);
}
endpoints.Sort();
List<long> indentList = new List<long>(5);
foreach (var endpoint in endpoints)
{
if (endpoint.IsStart)
{
int i = 0;
while (i < indentList.Count)
{
if (indentList[i] <= endpoint.Timestamp)
{
endpoint.Block.Indent = i;
indentList[i] = endpoint.Block.EndTime.Ticks;
break;
}
i++;
}
if (i == indentList.Count)
{
endpoint.Block.Indent = i;
indentList.Add(endpoint.Block.EndTime.Ticks);
}
}
}
blocks.Sort((l, r) =>
{
var startDifference = l.StartTime.Ticks.CompareTo(r.StartTime.Ticks);
if (startDifference != 0)
{
return startDifference;
}
return l.Length.CompareTo(r.Length);
});
foreach (var block in blocks)
{
block.Start = block.StartTime.Ticks;
block.End = block.EndTime.Ticks;
}
return blocks;
}