Greenator Features: Visual Studio .Net integration
VS .NET has a built in interface for integrating Code Generation called custom tool. Two Custom Tools (also called Generators) come with VS.NET, MSDataSetGenerator for strongly-typed DataSets, and MSDiscoCodeGenerator for WebService proxy classes.
Once you have set the property custom tool the generator starts and generates a subordinate project item with the generated source. Every time you change and save your base definition file, the source file is generated again.
I like the transparent way how the generation works. In fact, at first sight it is a miracle how the strongly typed dataset is generated from a Schema.
It is possible to write your own custom tools. All you need is to implement one function:
public override byte[] GenerateCode(string file, string contents)
{
string code = "<<generated code>>";
return System.Text.Encoding.ASCII.GetBytes(code);
}
On a second sight, this approach limits the scope for active code generation. Code generation should be under your control, you should e.g. set the templates to be used for the code generation. It is not possible to set a further argument inside the properties of the definition file.
Some code generators that implement custom tool cheat; they add the reference of the template inside the model definition. That is not orthogonal.
Furthermore it is not possible to generate two code files out of one model.
Greenator is written as Visual Studio Add-In and for this reason Greenator is not limited by the design of custom tool. But Greenator supplements custom tools behaviour, it watches all templates and models and generates the code file or even files transparent on the fly every time it must.