Automated Refactoring w/ CodeDom and VBCodeProvider...

  • Thread starter Thread starter jack
  • Start date Start date
J

jack

Trying to make a utility that

- Reads a VB.Net source file
- Parses it into it's constuent parts
- Evaluates and modifies as required
- Saves the source

I thought that the CodeDom and the VBCodeProvider would be the way to
go.

I can gen code and compile it, but I can not figure out how to parse a
VB.Net file into a CodeCompileUnit. (Neither CreateParser or Parse
seems to work)

How to I read a VB.Net source file into theee code dom so that I can
progaramatically inspect it.

Am I going down the wrong path?

Jack Stephenson
 
Hi Jack,

I'm not sure about the CodeDom and VBCodeProvider, but using the
extensibility model of Visual Studio you can create either:

- A macro
- An add-in
- A Visual Studio package (VSIP / VS 2005 SDK).

The extensibility model offers ProjectItem.FileCodeModel, which in turn
offers FileCodeModel.CodeElements, etc. See for example my article:

HOWTO: Navigate the code elements of a file from a Visual Studio .NET macro
or add-in
http://www.mztools.com/articles/2006/MZ008.htm

You have lots of resources to get you started on my web site ("For add-in
developers").

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
 
jack said:
Trying to make a utility that

- Reads a VB.Net source file
- Parses it into it's constuent parts
- Evaluates and modifies as required
- Saves the source

I thought that the CodeDom and the VBCodeProvider would be the way to
go.

I can gen code and compile it, but I can not figure out how to parse a
VB.Net file into a CodeCompileUnit. (Neither CreateParser or Parse
seems to work)

How to I read a VB.Net source file into theee code dom so that I can
progaramatically inspect it.

Am I going down the wrong path?

Jack Stephenson

There is currently no VB.NET or C# code parser => CodeCompileUnit
function in the BCL. You would have to write your own CodeParser -
which I've considered myself :)
 
Back
Top