UnioGame / UniGame.CodeWriter

Helper class for generating code concisely.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CodeWriter

NuGet Status Build status Coverage Status Coverity Status

CodeWriter is a small helper class for generating code concisely. It helps writing neat code which generates code dynamically.

Following code generates C# code on the fly:

var w = new CodeWriter.CodeWriter(CodeWriterSettings.CSharpDefault);
using (w.B("class Test"))
{
    using (w.B("public static int Sum(int a, int b)"))
    {
        w._("var r = a + b;",
            "return r;");
    }
}
Console.Write(w.ToString());

Output:

class Test
{
    public static int Sum(int a, int b)
    {
        var r = a + b;
        return r;
    }
}

Where can I get it?

PM> Install-Package CodeWriter

About

Helper class for generating code concisely.

License:MIT License


Languages

Language:C# 100.0%