Extensions
Extensions serve the purpose of doing anything that the C# compiler can do. FlexCompiler provides many such extensions out of the box.
List of built-in extensions
ID | Name | Scope | Hook(s) | Description |
---|---|---|---|---|
com.flexframework.flexcompiler.assemblyinfo | Assembly Info | Local | Compilation creation | Write assembly info (e.g version) to output assembly file |
com.flexframework.flexcompiler.visibility | Visibility Changer | Local | Compilation creation | Quickly modify visibility of types (e.g. public to private) |
com.flexframework.flexcompiler.dependency | Dependency | Local | Task creation | Streamline multiple projects building process (make one project dependency of others) |
com.flexframework.flexcompiler.obfuscator | Obfuscator | Local | Assembly creation | Simple yet powerful obfuscation support (with default strategy or full control mode) |
com.flexframework.flexcompiler.symbols | Custom Symbols | Local | Task creation | Modify default symbols |
com.flexframework.flexcompiler.references | Custom References | Local | Task creation | Modify default references |
com.flexframework.flexcompiler.logging | Build Log | Local | Reporting | Write build log to file |
com.flexframework.flexcompiler.legacyimporter | Legacy Project Importer | Global | - | Allow reading legacy (v1) project files |
Extension hooks
An extension may subscribe to one or more job hooks. In each hook, it may update associated context.
There are four major hooks in each job:
Hook | Description |
---|---|
Task creation | Create a task, assigning sources, build settings |
Compilation creation | Create a compilation from task, parsing settings and sources to syntax trees, resolving references |
Assembly creation | Create writable streams for assembly, xml and pdb output, then emit compilation results |
Reporting | Parsing compilation result logs |
Extension scope
There are two type of extension scopes: Local and Global.
Local extension
Local extensions are bound to a specific project. They're loaded only when their associated projects are loaded. Their configs are saved into project files.
Global extension
Global extensions are loaded regardless of projects, as soon as FlexCompiler being initialized. They provides editor level functionalities like supporting a new format, modifying editor GUI, etc. Usually they do not affect compilitions. Their configs are saved in editor application settings.
Extension activation
An extension can be disabled or enabled. A disabled extension does not take effect in any hooks. To enable or disable an extension, simply check or uncheck its toggle in extensions panel.
Extension order
More than one extension can take effect within the same build hook, like replacing source files, overriding compilation settings, etc. To avoid conflicts, you can set execution orders for them. Simply drag to reorder them in extensions list. They will execute in the given order from top to bottom (in the same hook).
Extension GUI
An extension can have graphical interface, usually for configuration tweaking (like Obfuscator extension allowing you to set obfuscation rules). However, some extension does not provide GUI since it has only one simple job (like Legacy Project Importer which adds file type support when importing a project).
Extension settings
A local extension write its settings in project file. The content can be anything serialized as string. Built-in extensions all write settings as JSON string, which allows you to read and modify them even without opening the editor, also friedly for version control.
<Extension id="com.flexframework.flexcompiler.assemblyinfo">
<Config><![CDATA[{"assemblyInfo":{"title":"FlexCompiler.Extensions","company":"FlexFramework","copyright":"Copyright © FlexFramework 2022","version":"2.0.0.0","fileVersion":"","informationalVersion":"","description":""}}]]></Config>
</Extension>
Extension settings are wrapped in XML CDATA
to avoid character escaping issues.