in

Dé specialist in .NET trainingen en consultancy

Thomas Huijer - Compiler says no....

Modifying the generated code from RIA Services

Today at a client I had the need to modify the code that RIA Services generates. It is certainly possible, but not as easy as modifying a T4 template. It turns out you have to derive a class from System.ServiceModel.DomainServices.Server.CodeProcessor. If you put the DomainIdentifierAttribute on your DomainService class, you can specify your own CodeProcessor.

The CodeProcessor gets an tree with the CodeDOM of the code that is going to be generated. The MSBuild task responsible for generating the code, hands that to your CodeProcessor so you can add, remove or change anything you want. See an example of a CodeProcessor here.

I’ve read somewhere that the next version of RIA Services is going to support T4 Templates, but for now I can live with it.

Comments

No Comments

About Thomas

Thomas is a senior consultant and trainer. He's interested in anything related to improving software quality like clean code, testability, process optimalization, architectures and developer tools. Thomas can be reached at thomas@oosterkamp.nl.