Rider 2018.1 brings file ordering to F# projects

Maarten Balliauw

The latest build of Rider 2018.1 EAP brings joy to F# developers by adding file ordering to F# projects! Files are now ordered in dependency order, and we can drag-and-drop to reorder files in our project. Let’s have a look!

File ordering for F# in Rider

The F# compiler, when invoked using MSBuild, will determine file order based on <Compile> entries in our .fsproj file (which is just like any other project file). The latest Rider 2018.1 EAP will display files in our project in the same order. We can also re-order files in F# projects, helping us structure our project.

In the Solution Explorer, we can drag-and-drop F# files (click and hold, drag the mouse), and control the file order that will be observed by MSBuild and the compiler:

Ordering FSharp files in Rider Solution Explorer

File re-ordering not only works for single files, it works for multiple files as well! Note we can also move files before or after an existing directory.

Ordering multiple files in an FSharp project

Why file (and code) ordering matters in F#

For developers coming from other .NET languages, like C#, working with F# projects can be a bit confusing at first. While in C# we can organize our code in namespaces and in classes, the F# compiler requires files (and code within a file) to be organized “in order”. We can not use forward references to code that hasn’t been seen by the compiler yet.

Let’s explain this using an object oriented concept. We can write a Person class that has a property of type Address. One will be in Person.cs, the other in Address.cs. In C#, the order of files would not matter, while in F# our Address class will have to be defined before our Person class, or compilation will fail.

Starting with F# 4.1, we can use the module rec keyword in a module or namespace to allow unordered code within, but in general having support for re-ordering files in F# projects will help us successfully work with our projects.

We’d love to hear your feedback on F# file re-ordering! Give the latest Rider 2018.1 EAP build a try!

Comments below can no longer be edited.

4 Responses to Rider 2018.1 brings file ordering to F# projects

  1. s952163 says:

    April 12, 2018

    Nice! Finally! 🙂

  2. Terence Hinrichsen says:

    March 3, 2020

    Searching for the ability to also do this with “Directories” in my Solution view? Is this available in Rider – I am evaluating 2019.3 and cannot seem to find the ability to do this except editing my fsproj file outside of Rider?

    • Maarten Balliauw says:

      March 3, 2020

      This is currently being worked on, hopefully coming to 2020.1.

      Right now, editing the .fsproj file is indeed the workaound. You can do this in Rider by navigating to it (from Go to Everything), or by using the Edit context menu. There’s also F4 (go to source) if you select the project in the solution explorer.

      • jhondev says:

        April 17, 2020

        Glad to read this. it would be nice to have this feature

Subscribe

Subscribe to .NET Tools updates