I have a javascript based library and would like to generate some C# classes for it. Unfortunately, I do not know T4 at all, so I may not have included information you need to answer this question. please comment, and I will edit as needed.
Thanks!
I have a javascript based library and would like to generate some C# classes for it. Unfortunately, I do not know T4 at all, so I may not have included information you need to answer this question. please comment, and I will edit as needed.
Thanks!
Yes, you can write a T4 template that creates C# classes from JavaScript class definitions. But there is nothing in T4 that helps you with doing so. A T4 template is essentially just a C# script that is executed by Visual Studio whenever the template file is modified.
Well, with T4 templates you can generate pretty much anything.
But you'll need to parse those JavaScript files somehow by yourself within T4.
Three Routes to try in order of niceness
a) Use CodeModel in Visual Studio 2008 or later to parse the javascript source code
b) Jscript.NET compiler to parse your code / or Eval() objects from it then walk over that code
c) Use RegEx to parse on your own
Please Drop me a line at tfischer AT tangible . DE. I am doing this for C# anyways right now an can add js for sure.