Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Add support for folder organization #116

Closed
CoreyKaylor opened this issue Mar 7, 2014 · 17 comments
Closed

Add support for folder organization #116

CoreyKaylor opened this issue Mar 7, 2014 · 17 comments

Comments

@CoreyKaylor
Copy link

Seems like an obvious feature... Are people not really using VS for most of their work with F#? Is the tolerance for pain just high and most don't mind the workarounds involved to organize their projects? I know my tone is trollish in nature, but I'm legitimately curious to see how others are dealing with this.

@ghost
Copy link

ghost commented Mar 7, 2014

Yes, this would be great to add.

(Note you can use folders with the Visual F# Tools, you just have to edit the project file by hand, see http://stackoverflow.com/questions/5918534/why-cant-i-add-a-subfolder-in-a-f-project)

@OkayX6
Copy link
Contributor

OkayX6 commented Mar 8, 2014

+1

In my team, we do use folders too, but we manually edit the fsproj.

@vasily-kirichenko
Copy link
Contributor

As I know, it's implemented in Xamarin. Maybe we could use some code from there?

@MarcinJuraszek
Copy link
Contributor

I have it done: https://github.com/MarcinJuraszek/VisualFSharpPowerTools/commit/88123b37328e47c2f6bd757f693f5518efd6faaf

but because F# is not my native language, I still need some time to read that code again, with fresh mind, and do some refactoring. I should be able to do PR tomorrow!

@dungpa
Copy link
Contributor

dungpa commented Mar 16, 2014

Great. We're looking forward to the pull request.

@vasily-kirichenko
Copy link
Contributor

I reviewed your code, please take a look.

@CoreyKaylor
Copy link
Author

Great news! One other note, generally pull requests flow much smoother if you keep your PR in a separate branch. Looking forward to seeing this get pulled in.

@MarcinJuraszek
Copy link
Contributor

OK, I have another version for folder organization. This one is reflection-based, and because of that there is no XML modifications and project does not have to be reloaded every time you do something. It's saved when you save the project file itself, use Save All or if you don't do that and try close the solution, you'll get a dialog about unsaved changes.

What works:

  • New Folder
  • Move Folder Up
  • Move Folder Down

What doesn't work:

  • Rename Folder - I've been playing with it for couple hours, and couldn't make it work. Using standard way to rename folder works fine only when folder is at project level and contain files only.

My local commit: https://github.com/MarcinJuraszek/VisualFSharpPowerTools/commit/ec91326d1be22c54290d9ebd7b5bf7ec9bf5e35e

@MarcinJuraszek
Copy link
Contributor

eh, the more I dig into this the less convinced I am about the entire concept of folders. Either there are some really serious issues with how Solution Explorer handles folders in F# projects or I'm just missing something.

e.g. seems like folder name must be unique in the entire project - work just fine, as long as the entire hierarchy does not contains two folders with the same name

<ItemGroup>
    <Compile Include="Library1.fs" />
    <None Include="Script.fsx" />
    <Compile Include="First\Second\File.fs" />
</ItemGroup>

works just fine

image

but as soon as you change Second to First

<ItemGroup>
    <Compile Include="Library1.fs" />
    <None Include="Script.fsx" />
    <Compile Include="First\First\File.fs" />
</ItemGroup>

or add another one called Second somewhere within project

<ItemGroup>
    <Compile Include="Library1.fs" />
    <None Include="Script.fsx" />
    <Compile Include="First\Second\File.fs" />
    <Compile Include="Second\File.fs" />
</ItemGroup>

it will break project loading:
image

@ghost
Copy link

ghost commented Mar 19, 2014

I believe that's a poorly implemented check in the Visual F# Tools (not intrinsic to VS). We may just have to live with that limitation for now (folder support would still be immensely useful even with limitations like this)

@CoreyKaylor
Copy link
Author

Just an idea, but in the same spirit as this suggestion http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/4512873-vs-ide-should-support-file-patterns-in-project-fil.

What if the approach was to rely on the filesystem entirely and call refresh on the project item to ensure the IDE represented the latest changes?

So add folder would only add the folder to the filesystem and refresh the project. Same for rename. Make sense? Bad idea?

@MarcinJuraszek
Copy link
Contributor

@dsyme So maybe we should stick to stuff that works, e.g. New Folder on project level only + Move Folder Up / Move Folder Down. This way if someone will try to add nested structure using existing VS UI (as soon as there is at least one folder, you can add subfolders from UI) or modifying project file manually it will be up to VS if it works or not.

We could also introduce additional validation to check if there is already a folder with given name in the entire project when user tried to add new one using F# Power Tools -> New Folder option.

@CoreyKaylor I'm not sure how that could be implemented without reimplementing entire ProjectManager from scratch.

@OkayX6
Copy link
Contributor

OkayX6 commented Mar 19, 2014

@MarcinJuraszek We could also introduce additional validation to check if there is already a folder with given name in the entire project when user tried to add new one using F# Power Tools -> New Folder option.

Yes please!

@dungpa
Copy link
Contributor

dungpa commented Mar 19, 2014

@MarcinJuraszek Thank you for the investigation. It's valuable to know what works and what doesn't wrt folder organization. I read your blog post; it's very helpful indeed.

I also support a small set of features which work correctly. We shouldn't attempt to alter linear order of F# files or invent a new F# project system. Until F# project system gives more flexibility in folder handling (e.g. separating between compilation order and file order), even a simple support for folder organization is a good step forwards

@MarcinJuraszek
Copy link
Contributor

I've added project-wide validation to the dialog, removed Rename command and did some cleanup. Check the lasted checkin: https://github.com/MarcinJuraszek/VisualFSharpPowerTools/commit/9e69e6b76551afacfc0b359e1e933b0bf13271d4

@ghost
Copy link

ghost commented Mar 22, 2014

Fantastic work!

@CoreyKaylor
Copy link
Author

Yes, awesome to see this get pulled in!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants