Generating Sitecore code without TDS

Posted by Robin Hermanussen on April 20, 2015 · 2 mins read

In the past, I’ve used my own Compiled Domain Model module on projects. It generates wrapper classes based on your Sitecore templates (among other things). But recently, I’ve been working with Glass Mapper.

Glass Mapper doesn’t wrap Sitecore items, but rather maps Sitecore items to objects. The result is somewhat similar; you can work with strong-typed classes/interfaces and extend them if you want.

There are several ways you can configure Glass Mapper. One of the ways is by using attributes. The attributes map the classes/interfaces and their properties to Sitecore templates and fields. This works very well and is very flexible, but it can be a bit tedious to do manually.

That’s why generating the code is a good option. If you’re using TDS, then you can easily generate code.

But if you can’t use TDS (e.g. because of the costs), then here’s a good alternative. Kern Herskind Nightingale did something similar before. But my implementation supports:

  1. Generate individual files for each template
  2. Configure which paths to generate classes/interfaces for
  3. Generate interfaces for Glass Mapper (but it is easily adaptable to other frameworks)

For more information, look at the documentation here, and you can clone/fork the project on GitHub here.

IDog interface example generated using Sitecore.CodeGenerator

IDog interface example generated using Sitecore.CodeGenerator