What You’ll Build
A module that generates a simple C# class with a constructor and readonly field. This demonstrates:- Template creation and registration
- Code generation using the C# File Builder API
- Module packaging and installation
This quickstart focuses on getting you productive quickly. For deeper architectural understanding, see the Architecture Overview.
Prerequisites
Before starting, ensure you have:- Intent Architect (version 4.6.0 or later)
- .NET SDK 8.0 or later
- Visual Studio 2022, VS Code, or Rider
Step-by-Step Guide
Create a Module Builder Application
In Intent Architect, create a new application using the Module Builder template.
- Open Intent Architect
- Click Create New Application
- Select Module Builder template
- Name it
MyFirstModule - Click Create
The Module Builder application type is specifically designed for creating Intent modules. It includes the necessary designers and module building infrastructure.
Define Your Template in the Designer
Open the Module Builder designer and create a new C# template:
- Right-click on the Templates folder
- Select New C# Template
- Set the name to
SimpleClass - Configure the template:
- Role:
Domain.Entity(or create a custom role) - Templating Method: Select C# File Builder
- Role:
Run the Software Factory
Generate the template scaffolding:
- Click the Software Factory Execution button (play icon)
- Wait for execution to complete
- Open the generated solution in your IDE
Implement the Template Logic
Open What’s happening here:
SimpleClassTemplate.cs and implement the template:CSharpFile- The File Builder API for generating C# codeAddClass()- Creates a new class definitionAddConstructor()- Adds a constructorIntroduceReadonlyField()- Creates a readonly field and assigns the parameter to itAddMethod()- Adds a method to the class
Build and Package the Module
Build your module to create the The built module will be in:
.imodspec package:The
.imodspec file is a NuGet package with a different extension. It contains your compiled module DLL and metadata.Install the Module Locally
Install your module for testing:
- In Intent Architect, open any application
- Right-click on Modules
- Select Install Module from File
- Browse to your
.imodspecfile - Click Install
Understanding the Template Structure
Let’s break down the key components:Template ID
Template ID
YourModule.TemplateName.Constructor
Constructor
outputTarget: Determines where the generated file is placedmodel: Optional metadata model from designers (not used in this example)
C# File Builder
C# File Builder
TransformText()
TransformText()
Next Steps
Congratulations! You’ve created your first Intent Architect module. Here’s what to explore next:Architecture Overview
Understand the module system architecture in depth
Working with Models
Bind templates to designer metadata models
Template Registration
Control when and how templates are instantiated
C# File Builder
Master the C# code generation API
Common Issues
Template not appearing in Software Factory
Template not appearing in Software Factory
Ensure your template registration is correct and the module is installed. Check the Software Factory logs for errors.
Build errors in generated code
Build errors in generated code
Verify you’re using the correct namespace and type references. Use
UseType() for proper type imports.Module won't install
Module won't install
Check that:
- The
.imodspecfile was built successfully - The
supportedClientVersionsin your.imodspecmatches your Intent Architect version - There are no conflicting module IDs
Need Help?
Visit the Intent Architect support repository to ask questions or report issues