Reuse Code with Auxillary Templates

November 1, 2023
Metalama 2023.3 allows T# templates to call upon other T# templates, enabling developers to reduce duplication and benefit from abstraction.

Metalama is a modern, Roslyn-based meta-programming framework that helps C# developers write cleaner, more maintainable code, faster. By dynamically generating boilerplate code, verifying code against architecture, patterns, and conventions in real time, and providing coding assistance with customized feedback and suggestions, Metalama empowers developers to focus on delivering high-quality software.

Metalama 2023.3 introduces auxiliary templates, which allow T# templates to call other T# templates and integrate directly with the Roslyn object model. T# is Metalama's template language, which is 100% syntax-compatible with C#. When an auxiliary template is called from another template, the code generated by the auxiliary template is inserted at the point where it is called.

Auxiliary templates improve code reuse by allowing developers to move repetitive code logic into a template, thereby reducing duplication. They also provide abstraction, since template methods can be virtual, enabling users of pre-built code aspects to modify the templates.

To see a full list of what's new in version 2023.3, see our release notes.

For more information, visit our Metalama product page.