Using CodeDOM

J

Jeff Gaines

I have written a utility to write a C# class file enabling access to a
database. It makes extensive use of a Text Writer to write the file.
Somebody who down-loaded it asked if it was worth looking at CodeDOM to
write the file. I spent yesterday experimenting but although it's quite
useful for writing a simple class file as soon as I needed something more
complex I had to fall back on code snippets (CodeSnippetExpression and
CodeSnippetStatement). There may be advantages I'm not aware of but it's
proving more complicated than using a Text Writer.
Can anybody point me to a news group that specialises in CodeDOM, I'm not
sure what category it falls in?
If anybody knows of any up to date examples/tutorials I would appreciate
being pointed to them. Those I found are quite old and CodeDOM seems to
have been updated quite extensively in VS 2008.
Many thanks.
 
A

Arne Vajhøj

I have written a utility to write a C# class file enabling access to a
database. It makes extensive use of a Text Writer to write the file.
Somebody who down-loaded it asked if it was worth looking at CodeDOM to
write the file. I spent yesterday experimenting but although it's quite
useful for writing a simple class file as soon as I needed something
more complex I had to fall back on code snippets (CodeSnippetExpression
and CodeSnippetStatement). There may be advantages I'm not aware of but
it's proving more complicated than using a Text Writer.
Can anybody point me to a news group that specialises in CodeDOM, I'm
not sure what category it falls in?
If anybody knows of any up to date examples/tutorials I would appreciate
being pointed to them. Those I found are quite old and CodeDOM seems to
have been updated quite extensively in VS 2008.

It is my understand that CodeDom does not fully support
all newer language and .NET features.

Which could be a problem.

Furthermore: do you really need it?

If you only want to generate C#, then I can't see the
big difference from using that and your current approach.

Your current approach would probably be simpler (at least
if you use String Format) and it is pretty easy to verify
that it compiles (because String source can also be compiled).

If you need to be able to generate both C# and VB.NET
at request, then using CodeDom to construct the source
code makes sense.

Arne
 

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

Top