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;
}
}
PM> Install-Package CodeWriter