4.2 MetaEdit+ extension for Visual Studio
While the C# generator for the Watch Example provides
entry-level integration with Visual Studio by generating the required project
definitions and other additional files, it is recommended to use an additional
free Visual Studio extension to take the full advantage of the Visual Studio and
MetaEdit+ integration. There are several advantages of using the
extension:
| One-click
access to your MetaEdit+ repository from Visual Studio
|
| Live
tree view in Visual Studio of all your MetaEdit+ models
|
| Double-click
to open and edit MetaEdit+ models from Visual Studio
|
| Autobuild:
generate code from MetaEdit+ models, import into a Visual Studio solution, build
and run
|
| Trace
and debug on both the code and model levels simultaneously
|
To install the extension, start Visual Studio, select
Extending Visual Studio and then
Visit the Visual Studio Gallery
(as in
Figure 4-1).This will take you to
the Visual Studio Gallery main page.
Figure 4-1. Extending Visual Studio
Search for
‘MetaEdit+ extension for Visual Studio’ and follow the link to the
extension download page (as shown in
Figure
4-2). Press the
Download button and follow the instructions to
complete the extension installation.
Figure 4-2. Downloading Visual Studio extension
Start the
extension in Visual Studio by selecting
View | More Windows | Graph
Browser. The extension will try to start MetaEdit+ from its expected default
location. However, if MetaEdit+ is installed elsewhere, the error dialog shown
in
Figure 4-3 will appear. Should this
happen, you can set the required paths for MetaEdit+ by clicking the
Open the
Launch Parameter Window button in the toolbar (the one with the gear icon)
and entering the correct values in dialog that opens.
Figure 4-3. ‘No connection to MetaEdit+ API’ error dialog.
When
the extension connects to MetaEdit+, it will populate the Graph Browser pane
with a list of the graphs available in MetaEdit+ at the time (as shown in
Figure 4-4).
Figure 4-4. Visual Studio extension Graph Browser.
The
following operations are available in the Graph Browser pane:
| Run
‘Autobuild’ generator for selected
graph |
| Run
selected generator for selected
graph |
| Open
selected graph in
MetaEdit+ |
| Edit
properties of the selected
graph |
| Create
new
graph |
| Update
graph
list |
| Show/hide
types |
| Setting
launch parameters |
All communication between the
extension and MetaEdit+ is carried out via the MetaEdit+ API. Hence, all model
editing and code generation is carried out natively in MetaEdit+ while the
generated code is loaded into, build and executed in Visual Studio. To try this
out, select ‘2012Models’ graph in the Graph Browser pane and then
Edit Graph Properties from its popup menu. This will open the usual
property dialog in MetaEdit+. Set ‘C#: API’ as the
Generation
target platform, OK the dialog and select
Run Autobuild from the
‘2012Models’ popup menu in the Graph Browser pane to launch the code
generation. After the code is generated and compiled, the test environment will
be launched and visual debugging activated (as shown
Figure 4-5).
Figure 4-5. Using the Visual Studio extension
For further
information on the extension, please see its documentation on
Codeplex.