Using CodeDom to edit code

J

John Mark Howell

BlankCan anyone give me an idea as to how to use the CodeDom to edit code?
I would like to perform mass changes (such as putting logging messages as
the first statement in all methods with method names) to a system with
hundreds of classes and thousands of methods. I know the CodeDom can allow
you manipulate the code and spit it back out, but I cannot seem to see how
to get it to pull the code into it in the first place.
Any ideas, pointers or references would be greatly appreciated!
 
J

John Mark Howell

Thanks Shak, but I've already checked out both of those. The MSDN link
shows how to build a code model from scratch, the CodeProject link is a
developer written tool that is not yet complete. However, I may be able to
use the CodeProject tool as a base.

I verified that in .Net 1.0 and 1.1, all CodeCompiler derivatives return
null for CreateParser. It was apparently by design and supposedly because
not all types in all languages can be represented by a particular CodeParser
object. However, because the code generation for all .Net languages fits
within the CTS and CLR, I doubt that is the real reason.

At this point, the only way I can see to build a code model
(CodeCompileUnit) is to scan the source and add the elements one by one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top