Can I use T4 template features to generate C# classes from javascript class definitions?
I have a javascript based librar开发者_StackOverflowy 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!
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.
Well, with T4 templates you can generate pretty much anything.
But you'll need to parse those JavaScript files somehow by yourself within T4.
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.
精彩评论