/*************************************************************************************************** Copyright (C) 2025 The Qt Company Ltd. SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only ***************************************************************************************************/ global using System.Threading.Tasks; global using Microsoft.Build.Logging.StructuredLogger; global using BuildTask = Microsoft.Build.Logging.StructuredLogger.Task; global using Task = System.Threading.Tasks.Task; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Test_Qt.DotNet.Project { public static class BinLogExtensions { public static bool TryFindTarget(this TreeNode node, string name, out Target target) { target = node?.FindFirstDescendant(t => t.Name == name && !t.Skipped); return target != null; } public static IEnumerable GetMessages(this Target target) { return target .Children.OfType() .SelectMany(t => t.GetMessages()).Select(m => m.Text); } public static bool HasMessage(this Target target, Regex pattern) { return target.GetMessages().Any(msg => pattern.Match(msg).Success); } public static IEnumerable GetTasks(this Target target, string taskName) { return target.FindChildrenRecursive(t => t.Name == taskName); } public static IEnumerable GetParamItems(this BuildTask task, string paramName) { return task.FindChildrenRecursive(p => p.Name == paramName) .SelectMany(p => p.FindChildrenRecursive()); } } }