views:

65

answers:

2

I need a code generator that:

  1. is open source
  2. will run in medium trust
  3. where templates are either compilable or can be embeded as resource files.

Webforms will not work because of 2 and 3. If I use virtual path provider then it runs only in full trust; if I run them as regular webforms, then I have to provide .ascx files witch is not acceptable.

Update: I want to generate C# or VB.Net code as well as ASP.NET markup, although that should not matter.

A: 

Check out the T4 Toolbox.

jamesaharvey
T4 from what I know is only from VS studio. I need it to generate code at runtime
epitka
You should add that to your question.
jamesaharvey
A: 

Take a look at the template support added in .NET 3.5 SP1 for dynamic data for ASP.NET. Microsoft has expanded this in .NET 4 to make templating available in web forms as well as in ASP.NET MVC, and supports both page and field templates. The data annotation support introduced for dynamic data is becoming the foundation for automated validation support. Data annotation is an important aspect for Silverlight and WCF RIA services as well.

These features can reduce the work that needs to be done for code generation, as well as make code generators more powerful.

Starting right now, any viable code generation solution needs to take advantage of these features, regardless of whether the code generator is commercial, open source, or a custom application.

UPDATE:

By the way, if you're looking for runtime code generation, you may be more interested in LINQ expression support; you can use LINQ to build expression trees, and compile those into code at runtime.

Cylon Cat
Could you provide a link for this?
epitka
Links added as update to my answer. These are just starting points, but you should be able to find lots of interesting stuff from there.
Cylon Cat