I created this issue so that anyone that wants to, can implement it. I think its an important feature because manually editing the fsproj is not ideal to say the least.
Thanks to @mhutch for these pointers of what's required:
This will be a fair bit of work in MonoDevelop.Core and
The first part is infrastructural - you would need to make it so that changes to the order of the items in the project.Items collection is reflected when serializing the project file. It currently tries to find existing items and update them, then add any new items into existing groups (MSBuildProjectHandler)
CAVEAT - you could probably work around this by removing the items, saving the project, then re-adding them in the desired order. But this may have undesired side effects.
The second part is displaying it in the UI. The tree node builders currently sort all the nodes by name though this is overridable (NodeBuilder) So I'd suggest adding some kind of project.HasSignificantFileOrder property, then if this were set, the ProjectFolderNodeBuilder could sort the items appropriately.
The third part is drag-n-drop. The ProjectFileCommandHandler would have to override the overload of OnMultipleNodeDrop that takes a DropPosition to it can accept drops before/after it (NodeCommandHandler.cs) It currently only allows dropping files onto it for grouping (ProjectFileNodeBuilder.cs) and then it would have to alter the order of the files in the project correspondingly and trigger a save.
What's the motivation behind this feature? What would the user achieve by changing the order of items?
In F# the order the items are presented in the project must be in dependency order.
If C depends on B and B depends on A then they would be listed:
<Compile Include="A.fs" />
<Compile Include="B.fs" />
<Compile Include="C.fs" />
Oh, I see.
Well, the best thing would be if the F# binding could do something intelligent to figure out the best order!
I would just prefer to have the existing Visual Studio behaviour.
@knocte Some consider it a feature that you have to order your F# files. A large part of programming is managing dependencies, and with file ordering, you have to be acutely aware of what your dependencies are, at all times. A nice side effect of this is that you always know how to read F# source code. You can read a program from beginning to end to see how it is built up, brick by brick, or you can go the other way to get the overview of what is being done. The main entry point is always at the very bottom.
This is pretty much a duplicate of #60. I suggest closing #60 then.
Yeah maybe close #60, just need somebody to do the work now :-/
In Visual Studio I use Alt-Up/Down to reorder the files. This might be easier to implement than Drag and Drop for a first cut.
This is a big one. For us fsharpers, its just an inconvenience, but for people trying to learn, I bet it's a killer. What's the state of this today? Has the issue been raised with Xamarin?
Its up to us to implement it, we own the binding not Xamarin
@migueldeicaza Any chance any Xamarin Guys might lend a hand on this?
I bet the experienced Xamarin Studio Guys would nail this pretty quickly!
@7sharp9 @rojepp I've finally got some free cycles to try to tackle this. Keep your fingers crossed; I'll see what I can do.
@7sharp9 I wonder if on that first item I could simply stash the list of files into a temporary list then after the other stuff is done but before the file is written re-order the files if needed? I wonder if that would work.
@OnorioCatenacci I would probably start with adding a few commands to the project pad, something like this:
<Extension path = "/MonoDevelop/Ide/Commands">
<Command id = "Fsharp.Moveup"
defaultHandler = "FSharp.Moveup"
_label = "Move file up"
icon = "md-class"/>
<Extension path = "/MonoDevelop/Ide/ContextMenu/ProjectPad">
<Condition id="ItemType" value="Project|ProjectFile|MonoDevelop.Ide.Gui.Pads.ProjectPad.ProjectFolder">
<CommandItem id = "Fsharp.Moveup" insertafter="FindInFilesSeparator" insertbefore="CombineOptionsSeparator"/>
If you implement stubs for the commands you can explore how to move the items about.
Item 2 is already at least partially implemented here
Newbie to F# here. Doesn't seem to work for folders. Workaround appears to be to name folders _001_subproject, __002_anothersubproject and so on. In 2016? Bloody ugly,
If you want assistance @norru you may want to provide some details. Such as which version of Xamarin Studio you're working with, which OS, etc. etc. etc.
This is the old repo, as far I know folder drag and drop is working correctly.
Please log any issues via bugzilla: https://bugzilla.xamarin.com/enter_bug.cgi?product=Xamarin%20Studio using the component F# Addin with full details of the issue and reproduction steps.