Skip to content

Default Code Generator Plugins

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

The default installation of Entitas comes with these plugins, sorted by assembly.

All listed plugins are executed in dry runs unless otherwise stated.

DesperateDevs.CodeGeneration.Plugins

Pre-Processors

TargetFrameworkProfilePreProcessor

Priority: 0

Ensures that your project does not use Unity's .NET 3.5 equivalent profile, which is deprecated. If your project still needs to support it, disable this plugin.

This plugin is executed in dry runs, even though it modifies your project file where applicable.

ValidateProjectPathPreProcessor

Priority: -10

Ensures that the configured target directory exists, halting Jenny if not.

Post-Processors

AddFileHeaderPostProcessor

Priority: 0

Adds a comment to each generated source file similar to this:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by <name of ICodeGenerator plugin>.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

Not essential, but a useful reminder not to edit generated source code. This plugin only supports comment syntax for C# (and compatible languages like C++ or C); if you want to generate code in any other language (e.g. a link.xml file), you will need to either disable this plugin or replace it with a custom one whose output changes depending on the file extension.

CleanTargetDirectoryPostProcessor

Priority: 0

Deletes every .cs file (and only .cs files) in the configured target directory to avoid conflicts with newly-generated code.

If you're generating non-C# files, you will need to provide a custom plugin similar to this one. When doing so, you can safely keep this plugin enabled.

Not executed in dry runs.

Unity .meta Files

This plugin will not delete Unity-created .meta files that correspond to generated code, but Unity itself will, invalidating any references to the corresponding source files in the process. If you need to preserve .meta files (e.g. when creating MonoBehaviours), you should create a custom IPostProcessor plugin that backs them up before this plugin is run, and restores them immediately after.

ConsoleWriteLinePostProcessor

Priority: 200

Logs to stdout a list of all files that were generated, and the plugins that generated them. If multiple files with the same name were merged, all relevant plugins will be listed.

Example Output

Ai/Components/AiAgentComponent.cs - Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator
Ai/Components/AiFindSafeCellComponent.cs - Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator
Ai/Components/AiNextDirectionComponent.cs - Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator
Ai/Components/AiPathFinderServiceComponent.cs - Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator
Ai/Components/AiTargetCellComponent.cs - Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator
Ai/Components/AiTargetCellPathComponent.cs - Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator
Game/Components/GameBlockComboComponent.cs - Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator
Game/Components/GameBlockComboFinishedComponent.cs - Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator
Game/Components/GameBlockComponent.cs - Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator
Game/Components/GameBlockFallingComponent.cs - Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator
Game/Components/GameBlockGridAlmostOverflowingComponent.cs - Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator, Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator

MergeFilesPostProcessor

Priority: 90

Merges generated files with the same filename into one, like so:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by Entitas.CodeGeneration.Plugins.ComponentEntityApiGenerator.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public partial class EngineInputEntity {
    // Omitted for brevity
}

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by Entitas.CodeGeneration.Plugins.ComponentMatcherApiGenerator.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public sealed partial class EngineInputMatcher {
    // Omitted for brevity
}

Do not disable this plugin without a suitable replacement, or else large swathes of generated code will be missing.

NewLinePostProcessor

Priority: 95

Replaces the line endings in all generated files with your operating system's native representation, regardless of what the code generator actually outputs.

UpdateCSProjPostProcessor

Priority: 96

Adds all generated code files to the configured project file, and removes from it all generated code files that no longer exist.

This plugin adds generated files to your .csproj indiscriminately, even if they're not .cs files. If you are generating files that are not C# code, you will need to disable this plugin and replace it with a custom variant that ignores non-C# files.

Not executed in dry runs.

WriteToDiskPostProcessor

Priority: 100

Writes all generated files to disk. Any changes to generated code made by IPostProcessors run after this one will not be saved.

Not executed in dry runs.

DesperateDevs.CodeGeneration.Unity.Plugins

Pre-Processors

WarnIfCompilationErrorsPreProcessor

Priority: -5

Post-Processors

DebugLogPostProcessor

Priority: 200

Doctors

DebugLogDoctor

Priority: 0

WarnIfCompilationErrorsDoctor

Priority: 0

Entitas.CodeGeneration.Plugins

All plugins listed in this assembly are available in the free version of Entitas.

Data Providers

These plugins compile and load your project's assemblies, then use run-time reflection to extract data from them. This means that if any part of your project doesn't compile, these data providers (and all code generators that depend on them) will fail.

ComponentDataProvider

Priority: 0

Extracts data from any component class or struct that implements IComponent, for use by almost every other code generator. Emits ComponentData instances.

If you're using Entitas.Roslyn.CodeGeneration.Plugins.ComponentDataProvider, you can safely disable this plugin. Otherwise, disabling this plugin will prevent almost every code generator from working.

ContextDataProvider

Priority: 0

Extracts data from the configured list of contexts. Emits ContextData instances. Do not disable this plugin without a suitable alternative.

EntityIndexDataProvider

Priority: 0

Code Generators

ComponentContextApiGenerator

Priority: 0

Uses ComponentData.

ComponentEntityApiGenerator

Priority: 0

ComponentEntityApiInterfaceGenerator

Priority: 0

ComponentGenerator

Priority: 0

ComponentLookupGenerator

Priority: 0

ComponentMatcherApiGenerator

Priority: 0

ContextAttributeGenerator

Priority: 0

ContextGenerator

Priority: 0

ContextMatcherGenerator

Priority: 0

ContextsGenerator

Priority: 0

EntityGenerator

Priority: 0

EntityIndexGenerator

Priority: 0

EventEntityApiGenerator

Priority: 0

EventListenerComponentGenerator

Priority: 0

EventListenertInterfaceGenerator

Priority: 0

Note: This name of this plugin has a typo.

EventSystemGenerator

Priority: 0

EventSystemsGenerator

Priority: 0

Entitas.VisualDebugging.CodeGeneration.Plugins

Code Generators

ContextObserverGenerator

Priority: 0

FeatureClassGenerator

Priority: 0

Entitas.Roslyn.CodeGeneration.Plugins

The plugins in this assembly are only available in the paid version of Entitas.

Data Providers

These plugins scan your project with Roslyn's code analysis APIs and extract information from it statically (i.e. without compilation). This means these plugins will work properly even if your code doesn't fully compile.

If you're using these plugins, you can safely disable the data providers listed in Entitas.CodeGeneration.Plugins, as the ones in Entitas.Roslyn.CodeGeneration.Plugins supersede them.

CleanupDataProvider

Priority: 0

ComponentDataProvider

Priority: 0

Uses ComponentData.

EntityIndexDataProvider

Priority: 0

Code Generators

CleanupSystemGenerator

Priority: 0

CleanupSystemsGenerator

Priority: 0

Clone this wiki locally