Installation and start-up
Plugin to Microsoft Visual Studio 2010 is installed by double-clicking on the package with the .VSIX extension, and then follow the instructions. In the case of this project a file is named BielastyAdam.VisualModelForFSharp.DslPackage. Pack looks like Figure 1 below.
Figure 1: Plugin VisualModelForFSharp for Microsoft Visual Studio 2010
The package will be distributed via the Visual Studio Gallery website. Then it will be available to other users via the Extension Manager, which is built-in the tool for Microsoft Visual Studio 2010 that allows you to install plugins. Alternatively, the plugin can be shared on any web page. Users have to download and install it manually.
In the Extension Manager the plugin can be accessed by selecting the tools menu:
Tools->Extension Manager…
Extension Manager window is shown in Figure 2 below. Here you can find the installed plug-ins and see their status. Using the Extension Manager, you can search other plug-ins from Visual Studio Gallery online.
If you can see the plug-in Visual Model For F #, it means that the installation was successful.
To use the functionality offered by this addition, you must create a new F # project. This is shown in Figure 3. To do this, click on the toolbar in the following order.
File-> New-> Project …
You will see the following window. Please select the application F#.
The next step is to create a sister project to the last. To do this properly you need to select the main root of the tree in the Solution Explorer. Click the right mouse button on the branch
Add-> New Project …
and the best is to choose the empty Empty Project project, as it is shown in Figure 4 below.
Our main solution should look now like on Figure 5. We have the F# project, and selected project C#. In the latter models will be created and transformed .tt files from the source code.
It should be now added to the project files so that you can model the functional programs and generate source code. The files responsible for these things add up automatically when you select a project
Add-> New Item …
when you hit the right button on the C# project. You have to do so, because of C# is available to transform text files with .tt extension.
The following window (Fig. 6) shows that among the options we have to choose the Visual Model For F #. Select this item, enter the name in the Name field, such as Model1.vmffs, and click Add to add.
After completing the previous steps our solution tree should look like Figure 7 below. New files have been added to the project: Model1.vmffs file is the most important file that can be opened with a visual editor. Just click on it twice. Model1.vmffs.diagram text file stores the character model. Another file is Model1.tt, i.e. to transform a text file. The result transformed model is shown as Model1.fs file, which is a source code file in F#.
Note: If Model1.tt file does not appear automatically in the tree with the project, you must create it manually. To do this, right-click on the name of the project such as OurModelProject and select the new .tt file (Text Template). Then add the following code:
<#@ output extension=".fs" #> <#@ VisualModelForFSharp processor="VisualModelForFSharpDirectiveProcessor" requires="fileName='$fileinputname$.vmffs'" #> <#@ template inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation" #> //plugin: Visual Model For F# //author: Adam Bielasty //website: www.bielasty.pl <#= this.RootModel.GenerateCode() #>
Listing 1: TT Template
In place of $fileinputname$.vmffs insert the name of the file containing the model, e.g. Model1.vmffs.
If you want to have something visible in the Model1.fs file, always after finishing the model, click on the Transform All Templates button shown in Figure 8 below. After this action all the files with the .tt extension will be transformed according to their definition.
Finally, we copy and paste the following result of transformation or just paste the .fs file to the project application from F#. In this way we can create multiple files with source code F #, from which we can use F# in the project.
The following Figure 9 is presented in the main window of Microsoft Visual Studio 2010 during the functional modeling. The left part is a set of components that can be dragged and dropped to the main space.