Saturday, 24 March 2012

Running O2 REPL Script environment inside Visual Studio 2010

For the VisualStudio 2010 users, here is how to setup the VisualStudio 2010 AddIn that is included with the latest version of O2 and same examples on how to use it, for example O2's REPL Script environment

In the folder you installed O2, if you go to the O2.Platform.Projects/binaries folder, you should find a file called O2_Platform_VisualStudio_AddIn.AddIn


That is the O2 Visual Studio 2010 AddIn, and the easiest way to load it up in VisualStudio is to add this folder into the path VisualStudio 2010 will look for Addins.

To get there:
  • open VisualStudio 2010, 
  • go the menu Tools -> Options,  
  • in the popup window, go to Environment -> Add-in/Macros Securty
  • Click Add
  • Enter the path
It should look something like this:


Then open the Add-In manager (from the menu Options-> Add-In manager...)


Tick the 'O2_Platform_VisualStudio_AddIn' box (if it is not there you might need to reboot VisualStudio) and click OK:

After that, if all goes according to plan :) ,  you should see a MessageBox that looks like this:

Inline image 4

Followed by an O2 Log Viewer WinForm and the addition of an O2 Platform menu item to Visual Studio

Inline image 5


If you open the new O2 Platform menu you should see these 3 options:

Inline image 6

Which look like this when opened:

Inline image 7


What is very cool is that these are WinForm Controls running inside an (non WinForm) Visual Studio Window. Which means that we can place them anywhere inside the visualStudio GUI:



And now that we are inside VisualStudio, we can script VisualStudio from inside VisualStudio :)

For example, this is how to add a new top level menu:

Inline image 10

How you open an empty WinForm's Panel:

Inline image 11

And finally, here is how you add/consume an existing O2 WinForm Control. For example the ascx_Search_AST from the O2 .NET Static Analysis engine (in this case we will first load up a C# file and then browse its AST)

Inline image 12


Let me know if you have any issues running it.

Dinis
Post a Comment