I want to know if there is any good way of programmatically producing C# code without actually manipulating strings or StringBuilders. Additionally it should check if the code compiles, but I guess this can be done using CSharpCodeProvider.
I'm looking for something like the following:
CodeUnit unit = new CodeUnit();
unit.AddDefaultUsings();
unit.AddUsing("MyApi.CoolNameSpace", "MyApi.Yay");
var clazz = unit.AddClass("GeneratedClass", Access.Public);
clazz.AddConstructor("....");
if(unit.Compile() != true)
//oh dang, somethings wrong!
else unit.WriteUTF8To("GeneratedClass.cs");
This might be part of the core library (Don't think CSharpCodeProvider can do this?) or an external library, but this is not my forte at all (dynamically producing code using c#), so if this seems clueless it's because I am!