Skip to content

Codegen Common Plugin Properties

Jesse Talavera-Greenberg edited this page May 6, 2019 · 5 revisions

Anatomy of a Jenny Plugin

Jenny plugins are implemented as classes that implement at least one of the following interfaces (all of which are available in DesperateDevs.CodeGeneration):

These interfaces all extend the ICodeGenerationPlugin interface, which means that all plugins effectively implement it.

Most likely, plugins will also implement one or both of:

  • IConfigurable (available in DesperateDevs.Serialization)
  • ICachable (available in DesperateDevs.CodeGeneration)

ICodeGenerationPlugin

All of the interfaces previously listed except for IConfigurable and ICachable implement ICodeGenerationPlugin, which is declared like so:

using System;

namespace DesperateDevs.CodeGeneration
{
    public interface ICodeGenerationPlugin
    {
        string name { get; }

        int priority { get; }

        bool runInDryMode { get; }
    }
}

This means that all Jenny plugins must provide these properties. While you can technically compute these values any way you want, they will almost certainly be constant values in practice.

ICodeGenerationPlugin.name

A short, human-readable name to identify this plugin in log files or console output. You can use whatever characters you'd like (including whitespace).

ICodeGenerationPlugin.priority

An integer used to determine the execution order plugins of a given type, with lower priorities (including negative values) being executed first.

Use this if you need to ensure that one plugin finishes before another starts. If two plugins have the same priority, their relative execution order is unspecified (i.e. either one of them could be run first). If in doubt, you can return zero. To ensure that your plugin is among the first or last to execute, return int.MinValue or int.MaxValue, respectively. Generally, this is more useful for IPreProcessors, IPostProcessors, and IDoctors than it is for IDataProvider or ICodeGenerators.

Note that regardless of the value of this property, all plugins in one stage will execute before the next stage is started (e.g. all IDataProviders are guaranteed to have finished before any ICodeGenerator is executed).

ICodeGenerationPlugin.runInDryMode

Return true to allow this plugin to execute in dry runs of Jenny. If your plugin modifies the file system or other external resources in any way, you should return false. Otherwise, you can return true.

IDataProviders and ICodeGenerators generally don't modify the file system, so they can more than likely return true.

Clone this wiki locally