-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Another way to correct generate Uri for new Document when resolve code action #68995
Conversation
@@ -206,8 +206,11 @@ private DocumentFileInfo MakeDocumentFileInfo(MSB.Framework.ITaskItem documentIt | |||
var isLinked = IsDocumentLinked(documentItem); | |||
var isGenerated = IsDocumentGenerated(documentItem); | |||
var sourceCodeKind = GetSourceCodeKind(filePath); | |||
var relativePath = PathUtilities.GetDirectoryName( | |||
PathUtilities.GetRelativePath(_projectDirectory, filePath)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this going to do if the file path is outside the project directory cone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔If it is not in the project directory, we might support things like ..
so it could be ..\..\projectB\cool\folder
.
Or we should just assume the document lives in the project directory and use null/ImmutableArray.Empty
in all other cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh cool I found PathUtilites.GetRelativePath
could give ..
as the parent folder, so I guess I just need to add some tests to verify that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess my question isn't "what does the method return" but "do we expect ..
entries to appear in the folders list in the first place?"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔I feel it should be allowed in the legacy project, I have added a test for that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See MSBuildWorkspaceWithDocumentInParentFolders
test, its referencing a document in ../MyDir
src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHandler.cs
Outdated
Show resolved
Hide resolved
src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHandler.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/TestUtilities/Workspaces/TestWorkspace_XmlCreation.cs
Outdated
Show resolved
Hide resolved
</Compile> | ||
<Compile Include="CSharpClass.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="..\MyDir\MyClass.cs" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the core test scenario in MSBuildWorkspaceWithDocumentInParentFolders
using var workspace = CreateMSBuildWorkspace(); | ||
var project = await workspace.OpenProjectAsync(GetSolutionFileName(@"CSharpProject\CSharpProject.csproj")); | ||
var linkedDocument = project.Documents.Single(d => d.Name == "Foo.cs"); | ||
Assert.Equal(new[] { "Blah" }, linkedDocument.Folders); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the linked location in our resources file. See here
<Link>Blah\Foo.cs</Link> |
@jasonmalinowski It's ready to be reviewed second time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. I have a few questions just to double check a few behaviors, but assuming everything is matching up, let's .
A different path to fix #68550
The reason is we don't provide
folders
in document in LSP server, so when https://sourceroslyn.io/#Microsoft.CodeAnalysis.Features/CodeRefactorings/MoveType/AbstractMoveTypeService.MoveTypeEditor.cs,148 is called, no folder is given, and we fall back to add the document under the project root.