Codesmith 4.0 Feedback and Feature Requests

Codesmith is a product that I have considered purchasing multiple times in the past. It seems to be the code generations suite that has the best community built around it and I think that is a very import aspect of any software I purchase. Every time I download the trial of Codesmith, my trial expires before I find a compelling reason to purchase the product.

Well, the other day I received a free licence for Codesmith 4.0 professional so I decided to use it on a project I am working on. After spending a couple of days with the product there are many features which I feel are missing or need some improvement. Some of them seem so glaring that I plan on following up with support to make sure I understand the functionality and the documentation correctly. It is also possible that the scenarios that Codesmith is meant to target are just not what I am trying to use it for. It seems that Codesmith is very well suited for walking through database structures and generating stored procedures or some sort of custom data layer, but that is not really what I want to use it for.


First I want to explain what I am attempting to use code generation for. Basically, I am generating an website based on configuration in a database. I already have a separate app that is used to input the configuration parameters and now I am trying to use Codesmith templates to generate the website. So here is the basic structure of my project:

I have created a base class for all the templates which includes some properties and functionality that will be common to all the code templates in this project. I created this class in Visual Studio and so it is in a re-usable dll. I also have other classes in this assembly which are used to hold common configuration parameters and such.

I plan on making three template files (.cst) for each aspx page I am generating. One for the code behind(.cs), one for the markup (.aspx), and one “master” template that will call the other two templates.

In the end, I will be writing my own client which will use the Codesmith API to run the templates and generate the website.

Visual Studio Integration

With visual studio integration being a feature, I assumed that this would allow you to view, edit, and run your code templates inside of Visual Studio. I was expecting an experience where I can open Visual Studio, choose “New Codesmith Project” or “Add Codesmith template” to an existing project and then begin editing both the .cst file as well as the .cs code behind file. Well, the only visual studio template that is provided is a “Add Codesmith project” which simply adds a Codesmith project (.csp) to your project. This features helps you manage code generation as part of your build process. And when it comes to editing and running your code templates, they still open up in Codesmith Studio which is external to Visual Studio. This wouldn’t be so bad except the development experience in Codesmith Studio is nowhere near as nice as Visual Studio. The intellisense only seems to work part of the time, the code formatting is not very configurable, and it just feels a lot more like editing in notepad than it does a development IDE.

Reading through the feature request at the Codesmith forums lead me to believe that I am not alone in my frustrations with the Visual Studio integration. I have seen other products do a much better job of leveraging the fact that I am comfortable and much more productive in Visual Studio. Codesmith Studio should only be for developers who do not have Visual Studio.

Assembly References

As I mentioned earlier, I want to use a common assembly to hold some base and utility classes for my templates. There is one problem though, if you want to use any external assemblies, they must be in one of three places:

  • The GAC
  • The Visual Studio PublicAssemblies Folder
  • The Codesmith Addins folder

So this basically means that I have to finish developing my external assemblies BEFORE I begin developing my code templates or I can just copy my assembly manually over to one of the folders above every time I make a new build of it. Well, that may not be so bad except for the fact that the Codesmith Studio holds on to the assembly once you use it in a template so I can’t replace it in the file system until I completely close Codesmith Studio. This is annoying to say the least.

I do not know how the Codesmith engine works under the hood, but I assume it is doing some sort of build which results in a .Net assembly or something very similar. I think it would be ideal if you could just have a Codesmith visual studio project type which would result in an assembly which could be referenced in other visual studio projects. This would really open up tons of new scenarios for sharing templates across applications as well as with the community. Having the templates in a assembly package would also make using the Codesmith API much easier. Instead of having to point the CodeTemplateCompiler to a .cst file, I would like to be able pass it an instance of a CodeTemplate class which it can then operate on.

Code Behind

I realize intellisense is probably a very hard feature to implement but whenever I use a product has it implemented but it only works sometimes, this almost makes me wish it weren’t there at all. If you can’t count on a feature, then it is more of an annoyance than a help. The code behind model seems like it is something that was just tacked on to Codesmith and is not really supported all that well. For starters, I can’t figure out how to add a .cs code behind file to the Codesmith Explorer window. If I right click, there is not “new C# file” option and if I try to rename another file to a .cs extension it complains that it is not a valid extension. The only way I have been able to add my own code behind files into the Codesmith explorer is to create a blank cs file and move it into the same folder as my template using windows explorer. Then it shows up in the Codesmith explorer. Maybe my experience as an Asp.Net developer pushes me towards the code behind model because it seems that Codesmith templates are more geared towards the inline classic asp type model of coding.


I hope all of this ranting makes you think I hate Codesmith. On the contrary, I think it is a pretty cool product that has a very wide variety of applications. I guess I am just spoiled by Visual Studio. I am a big believer that when you create tools for a development platform like .Net or Visual Studio, you should make things work just like they were always part of the platform. For example, if you are writing APIs, they should conform as closely as possible to the BCL standards as far as naming etc. Codesmith essentially introduces a new file type into my development arsenal: the .cst template file. Having to use these files outside of Visual studio when I am trying to integrate them with a project that is being developed inside of the Visual Studio IDE just feels wrong. I would love to hear from the Codesmith team as to what their plans are beyond version 4.0


3 Responses to Codesmith 4.0 Feedback and Feature Requests

  1. Luke,

    Thank you for the feedback. Here are some comments on your feedback.

    1. Visual Studio Integration, this is a really hard one because the VS editor doesn’t support nested languages merged at run-time which is what we are doing since your template and target language could be any combination of languages. We could bring the editor control we are using into VS, but it’s no small undertaking. In fact, it would be a massive effort and in the end the only difference would be that you could edit your templates in VS. It’s not exactly a big selling point for the huge investment we would have to make into this feature. The other big problem with this one is that we’d have to maintain two IDE’s since we don’t want to require that you own VS to use CodeSmith.

    2. IntelliSense is definitely not an easy feature to implement. We’ve tried to do a good job, but you are right in that there are too many scenerios that the feature fails. We will be working to improve on these scenerios in the future. The biggest thing to keep in mind here is that we are cheating to get IntelliSense by compiling the template and then using reflection. So if your template doesn’t compile or you’ve added new things to your codebehind file and haven’t compiled those changes yet, you will run into issues.

    3. The assembly locking thing is also something that we are planning to address in the future.

    Eric J. Smith

  2. Luke Foust says:


    Thank you for your reply. It shows what a stand up company you guys are that you respond to customers feedback in such a professional manner.

    Would it help with the Visual Studio Integration if you were to restrict the code to just one language? That is a limitation that we have with all other VS project types and is something that I would gladly live with if it meant better integration.

  3. Thanks for the insight into CodeSmith, Luke. I am developing a product in this area and it is encouraging to see that that you are frustrated by problems that I have already solved.

    To me these issues are very basic – the real challenge for code generation tools lies in adding value beyond the mere generation of code.

    If you are interested in conducting a serious review I will give you a free licence for my software. It is due to reach beta at the end of June.

    Check out the developer notes on my website at, I’d appreciate your thoughts.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: