Table of contents


Go to and download the Genuilder visual studio extension.


Run it.


Restart Visual Studio, you should then see the new project item.


Upgrading Genuilder

You have to uninstall the previous version of Genuilder in the Extension Manager. (In visual studio "Tools/Extension manager")


Common Features

Common features are accessible through the CommonFeature enumeration in your Genuilder project.


You need to run your Genuilder project each time you modify it to install or remove features from your projects.


The AppConfigVerifier is an integration in Genuilder of this project.
It scans all 'type=".*"' in the config file, and check if the type is referenced in the project.
The documentation can be found on CodeProject
Here is a quick example, where in the config file you misspelled the MembershipProvider type:


Genuilder will find the error at compile time:


You can exclude types or assemblies from the verification, just check this article


This feature comes from one of my articles on CodeProject.
With it you can access to your AppSettings and ConnectionStrings in a strongly typed way.
Example, the appconfig :
Auto completion on AppSettings :
Auto completion on ConnectionStrings :


The EnvironmentFile is just a pre-processor for your config file. For example you
have this app.config with a token:

You have also this EnvironmentFile.env file which is just a key=value pair list
delimited by line breaks:


After compilation, the output config file (for example MyProject.exe.config) will


This is particulary useful when developpers in a team have not the same development environment,
they doesn't need to checkout their own version of the app.config. (The EnvironmentFile should be unique for each developer and should not be in your source control.)

If one of your fellow developer changes the config file like that:

After the next Get latest version, the project will not compile because the new
token is not set in the EnvironmentFile.env:


Note : this feature doesn't work for web.config files. (Don't worry .NET 4.0 is coming with a new feature for web.config files)


Interface extractor is a code generator which extract an interface from public members of classes and structs.
This feature is really useful when you want to create static or dynamic proxies around a service or a controller for authentication or logging for example.
I'll create an article on codeproject on a nice use case with ASP.NET MVC to control authorized access of a controller. (I have not done and I've not eat my own dog food yet... so be really careful with this feature ! ;))

For example this class :


Will create extract this interface :


Note that the parameter of the ExtractInterface is optional, the default interface name is IClassName.
Also, you don't have to implement the interface on your class.

Warning : [ExtractInterface(typeof(SomeNamespace.Interface))] is currently not allowed, you cannot specify the namespace of the extracted interface... not a big deal to add though


As InterfaceExtractor, PropertiesExtractor is a class generator which generate a static class to access properties name in a strongly typed way.
For example this class implement INotifyPropertyChanged and do not hard code the property name with a string :


Because PropertiesExtractor will generate this other class


This way if you refactor the property name, the code will break at compile time instead of during runtime.

As with InterfaceExtractor, the parameter of the ExtractProperties is optional, the default class name is ClassNameProperties.
Warning : [ExtractProperties(typeof(SomeNamespace.MyClassProperties))] is currently not allowed, you cannot specify the namespace of the extracted class properties... not a big deal to add though


This feature generate a class to access to your configuration file in a strongly typed way.
If you remove a section whereas your code somewhere has a dependency on it, it will break the code at compile time instead of during the runtime.

For example for this config file :


You will be able to access to sections like this :



Installing an extension in your project

An article have been written on codeproject to introduce the Extensibility framework of Genuilder.
To install an extension, you need to use an Extensibility Feature, add extensions and install it on the project.


Built-in Extensions


This extension creates a ServiceContract given a synchronous ServiceContract, useful for Silverlight projects.
Given :
Will generate :
An example is given here


It generate classes to access to type's member in a strongly typed way.
Given :
It will generate a class to access PropertyInfo, MehtodInfo, EventInfo this way :


The goal and usage of this Extension is explained on this codeproject's article.


Shown on codeproject.


Shown on codeproject.

Custom Extension

Object Model

To create your own extension, you have to implement IExtension, here is the object model of Genuilder.Extensibility

GenItems represents code files of your project, you can use ExecutionContext.CreateChild(string name) and GenItem.CreateChild(string name) to create new ones.
When you use GenItem.CreateChild, the child will be deleted when the parent is deleted.

MSBuild logging

You can easily send warning, error and info message to visual studio by using ExecutionContext.Logger and GenItem.Logger.
For example, in this example I output an error on Program.cs line 5 column 6 in Visual Studio.


Once installed on my project here is what happen at compile time :


Debugging an Extension

You can easily debug your extensions by calling the .Build() method on your project
In this case you will be able to break in the MyExtension class to see what is going on during the build.

Easy code parsing and generation

Genuilder has a built-in object extension to easily parse CodeItems with NRefactory.


You can use the CompilationUnit property to walk through the Abstract Syntax Tree (AST).
Or, more easily, use the Visitor pattern by implementing AbstractASTVisitor, overriding methods called during the visit of the tree, then calling CompilationUnit.Visit(visitor,null);
Take a look at the code source of ProxyGeneratorExtension.

In this example, you'll see how to use the CodeWriter class to generate readable code.


Currently, the intellisense of Resharper doesn't work on generated classes. But the code will compile.

Last edited Jan 20, 2012 at 9:17 AM by Slashene, version 93


No comments yet.