CodeDom Utilities is a project that brings functionality and extensions to ease the coding activities related to CodeDom
Writing CodeDom, although not complicated, can be very cumbersome since it involves creating trees of expressions, statements, type declarations and other artifacts. This practice leads to code that can be very hard to read (or write).
Most of the CodeDom coding is repetitive and there are a lot of patterns that can be adopted to improve the code quality.
How is it organized?
- CodeDom Extensions: These are extensions methods that are meant to provide syntax that is more terse and confortable to read and write. These extensions
are also meant to provide workarounds for some missing unary operators.
- CodeDom Patterns: These are common coding patterns that you find in .NET like readonly properties and INotifyPropertyChanged classes.
How can this help you?
Take for instance the following fragment of Code, written with nothing but what is provided in System.CodeDom namespace.
var variableDeclaration =
var assignment = new CodeAssignStatement(
if you where to write this using
you would be doing something like this.
var variableDeclaration = "System.Collections.ArrayList".TypeReference().ForVariable("someVar");
var assignment = variableDeclaration.Assign((null as object).Literal());
How can you use this in your projects?
Simple. Just get the CodeDom Utilities and include it in your project.
Then include a reference to the namespaces in the files you wish to use and you are set. Consult the documentation of the utility you are trying to use for a list of namespaces to include.
If you are looking for a particular build, you can get it here
. Just check out the build you need.
How to get it?
You can get CodeDom utitlities from the downloads section. Utitlities is also available on NuGet Gallery.