|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Extending source files by parsing themclass and produces another source file that contains code that depends on some properties of the first file. For example, the original file might contain: Public Class MyClass Public Sub MySub ' blah End Sub End Class Then I want to produce a second source file that might contain: Public Class MyGeneratedClass Public Sub DoWhateverOnMyClass(arg as MyClass) End Sub End Class Of course this example is very simplified. In reality I want to do a lot of processing on the first class. What I want is something like CodeDom for the first class, but VB.NET has no CodeDom parser. I tried using CodeProvider.CompileAssemblyFromFile, but this requires me to compile a complex set of assemblies (and parsing VS project files, which might or might not be easy depending on the VS API, I have not looked into this). The problem is, I want only the basic parsing to be done, I don't need an executable assembly. Is there some way that lets me go through the VB.NET code without requiring a full compile of the project? (And of course, short of writing my own VB parser which is probably a little overkill...) Is there some way of intercepting the compilation process before it fails with "Type <whatever> is not defined", or in any way access the work it did so far? I am thankful for all input on this subject. Regards / Rickard Hi Rickard,
There's no VB .NET parser available in .NET Framework. You can try 3rd party products such as GoldParser (it's free AFAIR). Show quote "Rickard" <rniocskpaa***@enfofsspyasm.se> wrote in message news:%23E1b6jceGHA.3996@TK2MSFTNGP04.phx.gbl... >I am trying to write a tool that takes a VB.NET source file containing a >class and produces another source file that contains code that depends on >some properties of the first file. > > For example, the original file might contain: > Public Class MyClass > Public Sub MySub > ' blah > End Sub > End Class > > Then I want to produce a second source file that might contain: > Public Class MyGeneratedClass > Public Sub DoWhateverOnMyClass(arg as MyClass) > End Sub > End Class > > Of course this example is very simplified. In reality I want to do a lot > of processing on the first class. > > What I want is something like CodeDom for the first class, but VB.NET has > no CodeDom parser. I tried using CodeProvider.CompileAssemblyFromFile, but > this requires me to compile a complex set of assemblies (and parsing VS > project files, which might or might not be easy depending on the VS API, I > have not looked into this). > > The problem is, I want only the basic parsing to be done, I don't need an > executable assembly. > > Is there some way that lets me go through the VB.NET code without > requiring a full compile of the project? (And of course, short of writing > my own VB parser which is probably a little overkill...) > > Is there some way of intercepting the compilation process before it fails > with "Type <whatever> is not defined", or in any way access the work it > did so far? > > I am thankful for all input on this subject. > > Regards > / Rickard |
|||||||||||||||||||||||