using ScadaLink.Commons.Entities.Templates; namespace ScadaLink.TemplateEngine; /// /// Detects cycles in template inheritance and composition graphs. /// Covers: self-inheritance, circular inheritance chains, self-composition, /// circular composition chains, and cross-graph (inheritance + composition) cycles. /// public static class CycleDetector { /// /// Builds an Id-keyed lookup that tolerates duplicate Ids in the input list /// (e.g. multiple not-yet-saved templates all carrying Id 0). On a duplicate /// the first occurrence wins — graph walks only need one representative node /// per Id, and a real cycle through any duplicate would still be reachable. /// A plain ToDictionary(t => t.Id) would instead throw ArgumentException. /// internal static Dictionary BuildLookup(IReadOnlyList