-
Notifications
You must be signed in to change notification settings - Fork 0
Getting started
Create a console application project and install this library:
PM> Install-Package Generaid
I usually call this project "Generator". Set it as a startup project so that every time you want to generate code in your solution it runs.
Add a class library project for the generated code. Let's call it "Generated".
Add a "Runtime Text Template" project item. Let's call it "MyTemplate.tt". Add the following code in it:
<#@ template language="C#" #>
public sealed class HelloWorld
{
}
Add a code file with a partial class class beside it, to make ourt template implement ITransformation interface, like this:
partial class MyTemplate : Generaid.ITransformer
{
public string Name => "fileName.cs";
}Make sure that the namespaces match between the halves of the partial class. The TransformText() method should be implement by the part generated from the *.tt file.
To your Main() add the following code:
var builder = new HierarchyBuilder("../../Generated/Generated.csproj", "Folder")
{
new NodeBuilder<MyTemplate>()
};
builder.Generate();Hit F5! If everything runs OK you will see Generated project updated