Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# code generator [closed]

Can someone recommend a simple c# code generator. I just looking something with methods like:

GenClass = CreateNewClass(AccessModifier,Name......)

GenClass.Add(new Method(AccessModifier,RetType,Name....){code=@"....."}

GenClass.Add(new Property(AccessModifier,Type, Name....)

........... etc

and after creating all classes\methods and other members we call Code Generation function(where we can specific some parametrs)

Is there such opensource code generator?

like image 931
Neir0 Avatar asked Mar 29 '10 05:03

Neir0


2 Answers

Check out Using CodeDOM to generate CSharp (C#) and VB code.

like image 174
Sam Harwell Avatar answered Oct 16 '22 17:10

Sam Harwell


You may want to have a look csscript that relies on CodeDOM.

It allows you to write things like:

var PrintSum = CSScript.LoadMethod(
        @"public static void PrintSum(int a, int b)
          {
              Console.WriteLine((a+b));
          }")
          .GetStaticMethod();
PrintSum(1, 2);

Be sure to read the doc, it's pretty detailed and you'll find you can do a lot more than what I just copied before.

like image 8
Romain Verdier Avatar answered Oct 16 '22 17:10

Romain Verdier