Quantcast
Channel: Category Name
Viewing all articles
Browse latest Browse all 10804

[Guest post] Visual F# Power Tools: community-led tooling for F# in Visual Studio

$
0
0

This is a guest post by Anh-Dung Phan and Vasily Kirichenko, F# community developers and contributors to the superb Visual F# Power Tools extension for Visual Studio.  – Visual F# Team

We are pleased to tell you about the Visual F# Power Tools, a Visual Studio extension aimed at providing extended tooling for F# in Visual Studio. You can download it today from the Visual Studio gallery.

The goal of the extension is to complement the standard Visual Studio F# tooling by adding missing features such as semantic highlighting, rename refactoring, find all references, metadata-as-source, and more.

What’s particularly special about this project is that it's a collective effort of the F# open source community. We work alongside the Visual F# Team at Microsoft in order to provide a complete toolset for F# users in Visual Studio.

This project is about 1.5 years old now, and has received overwhelmingpositivefeedback from the F# community. Today we are excited to share this effort, and the story behind it, with a broader audience.

How did it get started?

There have been some interesting conversations in the F# community, asserting that if F# had better IDE tools in Visual Studio, then it would be a lot easier to learn and adopt the language.

In fact, F# easily has the best IDE support among statically-typed functional languages, through Visual Studio and Xamarin Studio. But the bar has been set extremely high by the C# tooling in Visual Studio (not to mention ReSharper), and as a result many developers expect this same level of support before even considering F#.

While we believe that F# is a superb general-purpose language that can stand out on its own, there is certainly lots of room for improvement in the tooling area. After working on F# ReSharper support for a few years without success, we finally attempted to do something about the situation.

At the end of January 2014, the Power Tools project got started.

The initial goal was to collect existing F# IDE extensions into a single place for curating and maintaining. At various points in time, extensions for automatic source code formatting, XML doc generation, and depth colorizing had been used in the community, but none were actively maintained.

Around the same time, the FSharp.Compiler.Service (FCS) project debuted as a shiny new compiler-as-a-service library for F#.  FCS is a Roslyn-like compiler API where all components of the compilation pipeline (e.g. lexer, parser, symbols, typed ASTs, assembly generator) are exposed for programmatic use.

FCS gave us a wonderful opportunity to not only curate existing extensions, but also to add many advanced features.

We took a chance on FCS, and many features were implemented quite naturally.  This tweet sums up our experience from the first three months:

Where are we?

Now over a year has passed, and we would like to take stock of where we are, and reflect on some of our most popular features.

Getting started

Version 2.0.0 of the extension was just released, and supports Visual Studio 2015 and 2013. In order to install the extension, search for "F# Power Tools" in "Tools -> Extensions and Updates -> Online". You can also download it directly from the Visual Studio Gallery.

The Power Tools offer a variety of features, each of which may or may not suit a particular developer’s preferences, so we provide a dedicated option set to tweak things for your own tastes.

generaloptions

Semantic highlighting

Similar to what the C# editor does, we colorize F# code based on its semantic structures.

Besides highlighting F# reference types and value types, we also provide color categories for modules, functions, quotations, unused values, and more.

A unique category that has been adopted enthusiastically is one covering all mutable values:

semantic_highlighting

Right there, the F# community shows its love for immutability, opting in to bright red alerts for any use of mutable state! We attribute the popularity of this little feature to all the pains we've been through trying to manage the complexity of mutable state in our pre-F# days.

Find all references

This is one of those features that, once you have it, it's really hard to live without.

Place the cursor on any symbol defined in the current solution, hit Shift-F12, and boom -- all references with detailed navigation information are displayed:

find_all_references

No more string search or manual browsing in order to look for certain symbols.

Similarly, we have Refactor -> Rename for all symbols defined in current solution.

This is one of our favorite navigational features.

In Visual Studio 2013, there was an important improvement where NavigateTo (Ctrl-,) started delivering results via a non-modal dialog.

With the Visual F# Power Tools, just type in any identifier you like (or a part of it) and you've got all relevant results from all projects in your solution, ready for quick navigation. It even works seamlessly on mixed F#/C# solutions:

navigate_to

Source code formatting

Automatic code formatting is a feature long-enjoyed by C# developers, but not offered for F# in Visual Studio.  The Power Tools project adds support for source code formatting, along with various options which control the details of adjusted code.

reformat

Resolve unopened namespaces and modules

Another favorite of C# developers is the ability for the editor to detect when you might have forgotten a ‘using’ statement.

F# developers can now do the same – we can offer to add ‘open’ statements for missing namespaces and modules, or to fully-qualify usages for you:

addopen

Automatic generation of pattern match cases

Besides filling in IDE features that C# already has, we have additionally added some features that are specific to F#.

One of these is the ability to automatically generate pattern match cases when matching against an F# discriminated union type.  The F# type system knows which cases have not been handled, so we can auto-populate those for you:

patterncase3

There are more exciting features that we don’t have time to mention here, so check out our homepage for more detailed documentation.

What's next?

Recently, a lot of new shiny tools have been created to assist with F# development, matching the growing number of F# developers who want them. There are many opportunities to provide better tooling to F# users by integrating such projects.

For example, we have been using SourceLink, a .NET library that automates source indexing, to support navigation to source code hosting platforms such as .NET reference sources, GitHub, etc. for external libraries.

We are also working on integrating FSharpLint, a style-checking tool for F#.

Another possibility is to improve the experience of using F# Interactive inside Visual Studio. There have been feature requests to provide more fine-grained ways to send code to F# Interactive. Some features, like syntax coloring and code completion, could tremendously improve the F# Interactive user experience.

Another area for enhancement is C# interoperability, where our features should be aware of referenced C# projects. If you would like to give this a higher priority, let us know by comments or voting.

There have been some requests to implement more refactoring features. These features are indeed challenging and they require significant involvement of FCS. But of course, they are also fun to implement, just like the feeling we have had since day one of this project.

We are actively seeking contributors. If you would like to join us, you can report bugs, send reviews/suggestions, or, better yet, fork the project and send pull requests.

Together we make F# tooling better, day by day.


Viewing all articles
Browse latest Browse all 10804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>