// SPDX-FileCopyrightText: 2026 Progmasoft // SPDX-License-Identifier: MIT using System; using Progmasoft.Tazel.Dsl.Common; namespace Progmasoft.Tazel.PluginApi; /// /// A Tazel plugin: the one public class of its entry assembly that implements this interface and has a public /// constructor without parameters. Tazel creates it and calls before the BUILD.csx files of the /// module run; the public types of the plugin's assemblies are then there for those files to use. /// public interface ITazelPlugin { /// Prepares the plugin for one build of a module. void Apply(IPluginContext context); } /// What a plugin learns about the build, and what it can ask of Tazel when it is applied. public interface IPluginContext { /// The group of the plugin, as in com.example.plugins. string Group { get; } /// The name of the plugin. string Name { get; } /// The version of the plugin. string Version { get; } /// The platform the build is for. Platform Platform { get; } /// Whether the build is a debug or a release build. BuildMode Mode { get; } /// The root of the module that uses the plugin. string ModuleRoot { get; } /// /// Lets every BUILD.csx of the module use the types of without a using. /// void Import(string @namespace); /// Says something to the user, as a status line of the build. void Status(string message); } /// The group, name and version of a plugin; Progmasoft.Tazel.PluginSdk writes it into the assembly. /// The group, as in com.example.plugins. /// The name. /// The SemVer version. [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] public sealed class TazelPluginAttribute(string group, string name, string version) : Attribute { /// The group. public string Group { get; } = group; /// The name. public string Name { get; } = name; /// The version. public string Version { get; } = version; } /// What a plugin or one of its steps reports as a failure, with a message for the user. public sealed class PluginException : Exception { /// A failure and what to say about it. public PluginException(string message) : base(message) { } /// Nothing to say. public PluginException() { } /// A failure and its cause. public PluginException(string message, Exception inner) : base(message, inner) { } }