TaHoGen – Code Generation

Quick update on the TaHoGen open source project…

I just tidied up the whole source tree, added all the projects in a logical layout to one solution. I also sorted out the Visual Studio addin with better error handling and added a Setup project so that it can be easily installed by an end user.

Murad’s excellent SchemaBrowser was added added and checked in, now allowing us to glean data from databases to use in the code generation. We’re closing in on CodeSmith…

Next step is to demonstrate use by including a number of templates.

The problem with the addin (that was so difficult to remedy) was MDA’s – difficult to troubleshoot and even more difficult to fix.

When the addin is called by VS it tries to save a reference to the instance of VS that is creating it – this is so we can get a handle on the OutputWindow and add some new panes to it.

These sometimes (intermittently) get blocked by MDA’s and the panes do not get created – the panes only show build output text so I added some error handling to continue processing even if we cannot write to the pane.

Anyway, if you want to take it for a test run, you can get it here.

8 thoughts on “TaHoGen – Code Generation

  1. The sample SchemaBrowser.Test in the code is not working.
    After fixing the compilation error and running the sample, it did not compile the Entity.txt resource file correctly.
    <script runat="template"> was parsed as a Text Literal. Changing the code in LiteralTextBlockParser from:
    Parser invalidBlock = new StringParser("<%") | new IncludeBlockParser()
    to:
    Parser invalidBlock = new StringParser("<%") | new IncludeBlockParser() | new ScriptBlockParser();
    Did not work either.

    Do you now where I can find the code for NDescent2? Thanks

  2. Bari,

    It’s been a good 2 years since I looked at the code for this….
    The NDescent source should be in the svn repository also – look under TahoGen4Parsers…

    Not sure about the errors you mention – one issue I do recall (that might be related / useful) was that script block openers ( <% ) could not be on the same line as any code…

    Hope this helps .. KJ

  3. Thanks Ken. I found NDescent where you specified.

    Just in case someone is interrested, the problem was in scanner.PushState and scanner.PopState:
    Parsers like the DifferenceParser was not working properly because other parsers are also pushing the scanner state and it is not poped up if there is a match. So, assuming that the DifferenceParser is poping the same state as the one that was pushed is false. This can be seen by using a parser like ScriptBlockParser with the DifferenceParser.

    The solution was to add a scanner.RemoveState which works like scanner.PopState without setting the offset. And call this function whenever there is a PushState but PopState is not called.

    Also thanks for the T4 link! I never heard of it before.

Leave a Reply

Your email address will not be published. Required fields are marked *