Show / Hide Table of Contents

Testing and Debugging Generator Files

Once you have written your Generator you will want to debug and test it.

There are a number of features built into SilverModel to make this as easy as possible.

These features are:

  • Preview Window
  • Output Window
  • Error Window

Debugging Templates with the Razor Editor Preview Tab

This Preview tab in the editor provides a number of important features.

Firstly it allows you to check that your template complies and produces an valid output.

Secondly it allow you to run macros within SilverModel and see the output of the macro.

Checking and Debuging your Razor Templates

Once you have written your Razor Template you will now want to check that the code is valid and works.

The first step you will need to do is to select an "Sample Code Element" in the properties window. This will then allow the Razor Editor to run with an valid UML Element.

Then you can select the "Preview" tab and the Razor Template will be complied and run with the UML element previously selected.

Demo

This demo shows the selection of an UML element and then running a Razor Template

RazorTemplate

Preview Window

When you press the preview tab on the editor. The generator will run and display the output of the generator.

By setting the Property for Element in Sample Code you can set the UML Element that the preview window will use to generate the code.

Output Window

The output window allow the code generator to output message to the window.

Example

@Model.Output.WriteLine(Model.Class.Name)

Error Window

When you preview your Generator code any errors will display in this window. This will show any compile errors in your generator template.

ErrorWindow

Preview

The Generator Preview function allows you to test the output for Generator/s against your selected Class Diagram.

Also the Preview function can be used it you just wish to Cut and Paste part of the output to your development environment.

Preview

Back to top Generated by DocFX