F# Project System, meet Project Extender

I was not sure it is possible, but it is. I managed to implement the approach I described here, found a workaround to (almost) every problem I ran into along the way and packaged all of it into one little Visual Studio extension package which allows you to organize your f# project like this. FSharpTree

You can download it here.
Using the package is really simple. Once you open an F# project after installing the package, the context menu on the project in the Solution Explorer will give you one new item: ProjExtenderMenu

Clicking on the item will enable the Project Extender for your project. From this moment on the behavior of the solution explorer will change in a number of ways.

First of all the order of items in the solution explorer will no longer reflect the compilation order. All files will be listed in the alphabetical order within their directories, right after the subdirectories listed also in the alphabetical order.

Context menus on the project node as well as subdirectories now also provide a way to create new (sub)directories. Renaming items changes the position of the item in the solution explorer if it is necessary to keep the alphabetical order of items.

All of the features listed above and a few more which are not listed are self - explanatory and very similar to the way the Solution Explorer works for C# project among others.

The file compilation order is not affected by any changes to the files performed through solution explorer. Compilation order is controlled by a new project property page:ProjExtenderProperties

Pressing Move Up and Move Down buttons changes the compilation order by moving the selected file up or down in the compilation order list.

As explained in the previous post ability to support compilation order across multiple directories involves some cheating. In practical terms it means that every time a project is loaded, the project file will be modified. When the project is closed it is modified back. It works ok with subversion, because the final state of the project file does not change, but with other source control systems it may force you to checkout the project file even though you have no intention of modifying it. This is one of the things I found no way around. I hope you can live with it as I plan to.

One more thing worthy mentioning is that once you enable the Project Extender you will get two more buttons on the solution explorer: Show All Files and Refresh:ProjExtenderShowAll

Pressing the Show All Files button makes all files and/or subdirectories in the project directory visible in the solution explorer. Pressing this button again removes the elemens displaying such files from the solution explorer. Refresh button refreshes the list of files to bring it up to date. Again this functionality is similar to how it is done in other project systems, including ability to re-add previously excluded files back to the project.

And finally one last note: when you get really annoyed with the Project Extender you can easily disable it by using Disable F# project extender item on project context menu in the solution explorer.

I hope you will never use this command. Enjoy.

P.S. At this time the only platform supported is Visual Studio 2008/F# CTP 1.9.9.9. I am working on implementing it for Visual Studio 2010.

As of version 0.9.1.0 both VS2008 and VS 2010 are fully supported

6 Responses to “F# Project System, meet Project Extender”

  1. Joel Says:

    Sounds really nice! So, um, where can we get it?

  2. Scott Parker Says:

    Mike - this looks fantastic! Is there an official release for this, or do you suggest building from Bistro/branches/WithMethodsEngine/ProjectExtender ?

  3. Michael Feingold Says:

    I plan to upload it the setup tomorrow - some last minute problems. For now - feel free to download the source and build it for yourself. Let me know if you have problems or need help to get it running

  4. Michael Feingold Says:

    Sorry. Some last minute problems with the setup - I should've hold on with the post. Tomorrow I will make it available for everybody, but for now feel free to download the source and build it for yourself http://bistro-framework.googlecode.com/svn/Bistro/branches/WithMethodsEngine/ProjectExtender

  5. Michael Feingold Says:

    Ok. It is done. The go to http://fsprojectextender.codeplex.com/releases/view/44360 for download

  6. Alex Says:

    Hi Mike,

    i started using the plug-in with vs2010, and it works for some projects and fails for others. i basically have a project that has several folders in it, and the plug-in re-organizes them in alphabetical order correctly, but under compilation order tab, it gives this error:
    An error occurred trying to load the page.
    The given key was not present in the dictionary.

    ...i was not sure how to contact you other than leave a comment here, so if this is not the right place, please let me know.

    Any idea how to fix this?

    For my other project that only has files in it, the plug-in works great.

    Thanks,
    Alex

Leave a Reply