0

I was impressed with MVC Scaffolding. I understand its limitation but I think it's a great attempt using t4 and powershell to automate repeated coding.

I wonder if there is anything like that for MFC or C++. I guess I can still use MVC Scaffolding with custom template or something like that. But I don't want to reinvent the wheel and that led to this question.

Tae-Sung Shin
  • 20,215
  • 33
  • 138
  • 240

1 Answers1

1

I'm not aware about something already existing, but is not so difficult to create one. You can host T4 templating engine in your own project: Have a look at Processing Text Templates by using a Custom Host, and also the Walkthrough: Creating a Custom Text Template Host, always from MSDN. The tricky part could be providing the DataSource for scaffolding, this is a little tricky if you expect to simple pass some objects to the templating engine: actually is different, you are extending a class by creating your custom host, and you can use that class to expose objects to the text transformation part. This would be clear as soon you start to create your custom host. Well, of course the plumbing part would be managed code ( probably C# ), but done the plumbing you can have a console application taking a template as a parameter and generating almost everything you want. If you are interested in something more "raw" I did something in the past for c# classes autogeneration from C#, here the code of my custom host. A really useful reference you should read about T4 templating in general is the Oleg Sych blog who wrote a lot and deep about T4 templating in general.

Felice Pollano
  • 32,832
  • 9
  • 75
  • 115