none
Generating Code with custom templates from class diagrams RRS feed

  • Question

  • I have created a custom template and using it for a class in class diagram.  Whenever i Click on "Generate Code" , it generates code but uses the default bindings template for the class. I have mentioned customtemplate at "text Transformation" bindings specific to the class in the classdiagram.

    This only works if i change the project path in the "templateBindings" to a new folder path [ which should be different than what the default bindings are set to] .  I expect that it should use the custom template with the same projectpath , as i am applying this template at the class level. Is this the behavior ? or is it an Issue? I see the same thing happening in VNext also.

    Can you please provide me a solution for this.


    • Edited by deli123 Tuesday, March 27, 2012 11:17 AM
    Tuesday, March 27, 2012 11:16 AM

Answers

  • Hi deli,

    Reading your post I assume you have the same problem I had. I fixed this by changing the order in which the T4 templates are applied.

    Check the Stereotypes property of the Class in the classdiagram. This will probably say "Text Transformation, C# class". I think this is the way it is applied; so first your template and then the default which overwrites your templates output.

    Expand the Stereotypes property with the arrow in front of it in the properties window. Clear the checkbox for Text Transformation. Select another object in the classdiagram and save it. Now go back to the Stereotypes property and add the Text Transformation again of Add it with the Text Template Bind property. Now the order displayes will be "C# class, Text Transformation" so your template will be applied last (make sure to set the Overwrite to true)

    Good luck.

    Eric

    Monday, June 18, 2012 10:52 AM