// SPDX-FileCopyrightText: 2026 Progmasoft // SPDX-License-Identifier: MIT using System; using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; namespace Progmasoft.Tazel.Dsl.Common; /// Which targets may depend on a target. public enum Visibility { /// Only the targets of the same project file. Private, /// Every package of the module. Module, /// Every package of the module and the modules that depend on it. Public, } /// How much a test may take; it sets the default timeout. public enum TestSize { /// One minute. Small, /// Five minutes. Medium, /// Fifteen minutes. Large, /// Sixty minutes. Enormous, } /// A target a project file declared. Depends takes its label, not this value. public sealed class Target { internal Target(string label) => Label = label; /// The label of the target, such as //core:math. public string Label { get; } /// public override string ToString() => Label; } /// A target that another depends on, by its label. public sealed class TargetReference { private TargetReference(string label) => Label = label; /// The label as written, such as //:math, :math or @dep//:x. public string Label { get; } /// A label. public static implicit operator TargetReference(string label) => FromLabel(label); /// A label. public static TargetReference FromLabel(string label) { ArgumentNullException.ThrowIfNull(label); return new TargetReference(label); } /// public override string ToString() => Label; } /// The targets a target depends on, by their labels: ["//:math", ":util", "@dep//:x"]. [CollectionBuilder(typeof(TargetReferences), nameof(Create))] public sealed class TargetReferences : IEnumerable { private readonly TargetReference[] _items; private TargetReferences(TargetReference[] items) => _items = items; /// No targets. public static TargetReferences None { get; } = new([]); /// The references, in their order. public IReadOnlyList Items => _items; /// Builds the references of a collection expression. public static TargetReferences Create(ReadOnlySpan items) => new(items.ToArray()); /// public IEnumerator GetEnumerator() => ((IEnumerable)_items).GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); }