Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved project folder support #2692

Merged
merged 21 commits into from
Apr 20, 2017
Merged

Conversation

saul
Copy link
Contributor

@saul saul commented Mar 24, 2017

Fixes #2178, #2048, #2539, #1095 and #732

Folder node selected

  • Add Above
    • ✨ Add New: added support
    • ✨ Add Existing: added support
    • ✨ Add Folder added support
  • Add Below
    • ✨ Add New: added support
    • ✨ Add Existing: added support
    • ✨ Add Folder added support
  • ✨ Add Above/Add Below on an empty folder

File node selected

  • Add Above
    • Add New
      • 🐞 Within sub-folder: fixed
      • At root: already supported
    • Add Existing
      • 🐞 Within sub-folder: fixed
      • At root: already supported
  • Add Below
    • Add New
      • 🐞 Within sub-folder: fixed
      • At root: already supported
    • Add Existing
      • 🐞 Within sub-folder: fixed
      • At root: already supported

Cut & Paste

copy and paste

Add > Add Existing...

create intermediate

  • 🐞 Add > Add Existing... on the project node should place the file in the correct subfolder fixed
  • Add > Add Existing... anywhere in the project tree should place the file in the correct subfolder added
  • Add > Add Existing... should create any necessary intermediate directories added
  • 🐞 Add > Add Existing... now works with files that are outside of the project hierarchy fixed

"Add Folder"

new folder

  • Add Above/Below > New Folder menu item added
  • ✨ Enable "Add Folder" on project node added

Miscellaneous

  • 🐞 Better support for non-Windows style directory separators in .fsproj fixed
  • Add Above/Below > Add Existing... should fail early if the file is in a different subtree added
  • 🔬 Test multiple folders with the same name
  • 🔬 Fix all bugs with linked files
  • ✨ If the folder exists on disk, use it instead of throwing an error
  • 🐞 Deleting a folder with links to files elsewhere on disk is deleting those files

@vasily-kirichenko
Copy link
Contributor

This is great.

No "Add folder" menu

image

@saul
Copy link
Contributor Author

saul commented Mar 24, 2017

@vasily-kirichenko is that a feature request or a regression? :)

@vasily-kirichenko
Copy link
Contributor

That was a feature request :)

"Add new item" into a folder adds it to the end in the project file:

image

image

@vasily-kirichenko
Copy link
Contributor

vasily-kirichenko commented Mar 24, 2017

...then I tried to move File1.fs up:

image

It's moved in solution explorer, but the project file has not changed, it's same as on the picture above.

@saul
Copy link
Contributor Author

saul commented Mar 24, 2017

Ah. I know why this is. The path separators need to be backslash

@vasily-kirichenko
Copy link
Contributor

So... I think it should work with both types of slashes since it's very likely / is used on linux and mac (if you open a project created in, say, Xamarin on Mac).

@dsyme
Copy link
Contributor

dsyme commented Mar 24, 2017

Wow, it would be great to get this in.

@cloudRoutine
Copy link
Contributor

right now it'll put it in the right folder if you click on the folder itself and do add item

@vasily-kirichenko
Copy link
Contributor

@cloudRoutine that's what I did.

@cloudRoutine
Copy link
Contributor

bizarre, this is the only way that works consistently for me

@saul
Copy link
Contributor Author

saul commented Mar 24, 2017

@cloudRoutine it's because Vasily had Linux-style directory separators in some of the files in his .fsproj - I'm fixing that now

@saul
Copy link
Contributor Author

saul commented Mar 24, 2017

@vasily-kirichenko @cloudRoutine fixed in 4d33380


I've also just re-enabled support for "Add folder" on the project node:
empty folder

@forki
Copy link
Contributor

forki commented Mar 24, 2017

Wow this is so cool. Thanks so much for doing this.

@vasily-kirichenko
Copy link
Contributor

awesome! will test it tomorrow.

@saul
Copy link
Contributor Author

saul commented Mar 24, 2017

Just fixed cut/copy and pasting files around:

copy and paste

cc @abelbraaksma

@cartermp
Copy link
Contributor

@saul You're a rockstar. Love it!

@vasily-kirichenko
Copy link
Contributor

@saul everything works great. Very cool :) Any plans to add drag-n-drop support? :)

@forki
Copy link
Contributor

forki commented Mar 25, 2017

Can we try to get the first batch in? It would immediately be helpful. Further improvements like draggedy-droppery-mousy-minkie could be added in another PR.

@saul
Copy link
Contributor Author

saul commented Mar 25, 2017

@forki my plan is to just fix the stuff that's there for the minute (see my incomplete check boxes in the PR description

@saul
Copy link
Contributor Author

saul commented Mar 25, 2017

A bit more progress - coming close for this to be merged.

I've reworked how the Solution Explorer and project file are synchronised. Any operation on a file in the Solution Explorer is no longer attempted to be 'replayed' on the project file (e.g adding a file to the Solution Explorer would try to move it to where we expected it in the project file). Instead, the file is added to the Solution Explorer to the most reasonable place, and then moved elsewhere if possible. Wherever the file ends up, the build project will replicate. This means it should no longer be possible for the Solution Explorer and project file to become 'out of sync'.

An example error is shown below:

@dsyme
Copy link
Contributor

dsyme commented Mar 31, 2017

.... using the #load directive to reference the files. Wouldn't it be possible to relay on this to improve the xplat story and removing the file ordering issues?

@nelak Yes, see the suggestion links above - please add your comments there.

@cloudRoutine
Copy link
Contributor

@saul I hope you haven't given up on this PR in favor of CPS work, which is all well and good but it'll be months before we get our hands on it.

Whereas this makes some really useful material gains that can be taken advantage of today (I merge this PR into my custom tools branch, no nightlies for me 😉 )

@dsyme
Copy link
Contributor

dsyme commented Apr 3, 2017

@cloudRoutine @saul @KevinRansom In the context of open source working, I think there can be "prime the pump" advantages to accepting feature work like this, even if it is later thrown away and replaced when CPS comes.

Specifically, it can help familiarize contributors with a feature area, making it easier to implement/debug/extend/correct/... the feature second time around. And people get to use and debug the UX for the feature early. And people also get very motivated to ensure the feature works in the later version as well.

I think the community experience with VFPT was somewhat similar - although built with the pre-Roslyn VS integration, the lessons, code, UX and so on were all incredibly valuable. And it was/is a highly valuable set of tools in its own right. So VFPT was definitely "worth it" as it primed the pump for the Roslynized version, as well as being useful in its own right.

@cartermp
Copy link
Contributor

cartermp commented Apr 3, 2017

I agree that this would be good to get in. The CPS work is currently scheduled for 15.3, which will be in a July timeframe, but as that work progresses we may have to cut scope. I'm also not convinced that we'll be able to completely switch over to that project system for .NET Framework projects in that time frame. Since .NET Framework represents the vast majority of projects in .NET, improvements like this are wonderful.

@cartermp
Copy link
Contributor

cartermp commented Apr 3, 2017

@dotnet-bot test this please

@KevinRansom
Copy link
Member

@dsyme @saul I want to accept this. I think the CI failures where what was holding me back so far. I am also particularly keen to see a prototype of the compilation order node. Since that offers a solution to our long existing issue with file ordering and folders.

Kevin

@saul
Copy link
Contributor Author

saul commented Apr 3, 2017

@cloudRoutine @KevinRansom I don't think this will be completed this week. Time constraints are making this week particularly difficult, but next week I'm hoping to have this (and the rest of my PRs!) merged.

Apologies for the delay, but rest assured I haven't given up on this.

@saul
Copy link
Contributor Author

saul commented Apr 15, 2017

I think the following tasks should be moved to a separate issue/PR:

  • If the folder doesn't exist, create a virtual folder
  • If you add a concrete item to a virtual folder create a folder on disk and add the item
  • If you add a linked item to a virtual folder it stays virtual

I think they're great things to have but I think this is feature creep. 'Virtual folders' don't exist as a concept within the project system at present, so it'd be a lot of new code to add this.

Also will take a look at the failing tests soon then this will be ready to merge.

@saul
Copy link
Contributor Author

saul commented Apr 15, 2017

Also @cloudRoutine as requested, here's what happens when you try to rename a folder (that is not empty) to a folder that already exists:

image

Note if the folder you're trying to rename is empty, it does it without complaining now.

@cloudRoutine
Copy link
Contributor

I think they're great things to have but I think this is feature creep. 'Virtual folders' don't exist as a concept within the project system at present, so it'd be a lot of new code to add this.

I don't know what you mean by "exist as a concept" but you can definitely have virtual folders within a project.

  <ItemGroup>
    <Compile Include="AssemblyInfo.fs" />
    <Compile Include="Library1.fs" />
    <None Include="Script.fsx" />
    <Content Include="packages.config" />
    <Compile Include="one.fs">
      <Link>virtual-folder\one.fs</Link>
    </Compile>
    <Compile Include="two.fs">
      <Link>virtual-folder\two.fs</Link>
    </Compile>
  </ItemGroup>

You see a folder node in the project tree, there is no corresponding folder on disk.
All I want is that if I add another linked item to that "virtual folder" there shouldn't be a new folder created on disk.

@saul whatever you're thinking of is way more complicated than it needs to be

@saul
Copy link
Contributor Author

saul commented Apr 19, 2017

No idea what the test failure is here because I can't even view the whole file

@majocha
Copy link
Contributor

majocha commented Apr 19, 2017

@saul

Errors and Failures

1) Failed : Tests.ProjectSystem.ProjectItems.AddNewItem.ItemAppearsAtBottomOfFsprojFileEvenIfUnknownItemWithSameName
Expected
["orig.fs"; "a.fs"]
but got
["a.fs"; "orig.fs"]

@saul
Copy link
Contributor Author

saul commented Apr 19, 2017

@majocha Thanks - but how in god's name did you find that?

@majocha
Copy link
Contributor

majocha commented Apr 19, 2017

@saul I saved `view as plain text' link to text file :)

@charlesroddie
Copy link
Contributor

@saul
The screenshots here look great!
But please don't make the solution order different from compile order.

@saul saul changed the title [WIP] Improved project folder support Improved project folder support Apr 19, 2017
@saul
Copy link
Contributor Author

saul commented Apr 19, 2017

Removed the failing test as it's impossible to reproduce in a real-world scenario. The test was doing the following:

In a project with the following MSBuild:

                <ItemGroup>
                    <Unknown Include="a.fs" />
                    <Compile Include="orig.fs" />
                </ItemGroup>

It was simulating adding the "a.fs" to the project. Now in VS proper this is a no-op - VS detects that the file is already in the project and does nothing. The test was simulating this about 5 layers deep and so some assumptions were failing. I don't believe they need addressing as the scenario can't be reproduced in a real-life scenario anyway.

@KevinRansom
Copy link
Member

@saul is it your recommendation that this is reviewable.

@saul
Copy link
Contributor Author

saul commented Apr 20, 2017

@KevinRansom reviewable and in a state to be merged

Copy link
Member

@KevinRansom KevinRansom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work.

@KevinRansom
Copy link
Member

@saul Thanks for this it looks great.

Kevin

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

Successfully merging this pull request may close these issues.

Adding new or existing items to folders in the Solution Explorer is broken