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

Enable extract refactorings in LSP #76718

Merged
merged 8 commits into from
Jan 24, 2025

Conversation

JoeRobich
Copy link
Member

@JoeRobich JoeRobich commented Jan 11, 2025

Options services are added to the LanguageServer project so that the extract refactorings will run. The options use defaults and do not require user interaction. This is part of the O# parity work and the defaults match those used by O#.

Once inserted, this will resolve dotnet/vscode-csharp#6430

@JoeRobich JoeRobich requested a review from a team as a code owner January 11, 2025 08:10
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 11, 2025
@JoeRobich JoeRobich force-pushed the dev/jorobich/enable-extract-refactorings branch from 5399edf to b4582d8 Compare January 11, 2025 08:30
UnifiedPredefinedSuggestedActionCategoryNames.StyleFix => CodeActionKind.QuickFix,
UnifiedPredefinedSuggestedActionCategoryNames.ErrorFix => CodeActionKind.QuickFix,
_ => throw ExceptionUtilities.UnexpectedValue(categoryName)
};

private static CodeActionKind GetRefactoringKind(IUnifiedSuggestedAction suggestedAction)
Copy link
Member Author

Choose a reason for hiding this comment

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

Providing the proper type will have VS Code render the actions differently.
image

image

ReferenceOutputAssembly="false"
Private="false" />
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" />
Copy link
Member Author

Choose a reason for hiding this comment

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

This is added to parse test code markup.

@JoeRobich JoeRobich force-pushed the dev/jorobich/enable-extract-refactorings branch from b4582d8 to 51e0c13 Compare January 11, 2025 08:51
@JoeRobich JoeRobich force-pushed the dev/jorobich/enable-extract-refactorings branch from a97921b to 59a55dc Compare January 14, 2025 06:12
<!--
Copy files contained in the project to a RoslynLSP subdirectory to emulate deployment of the language server.
-->
<Target Name="_CopyLanguageServerFiles" AfterTargets="ResolveProjectReferences">
Copy link
Member Author

Choose a reason for hiding this comment

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

We need the LanguageServer isolated into its own folder. This target works similarly to the already preset _CopyDevKitExtensionFiles.

@JoeRobich JoeRobich changed the title Enabled extract refactorings in LSP Enable extract refactorings in LSP Jan 16, 2025
@jasonmalinowski jasonmalinowski self-requested a review January 16, 2025 18:38
Copy files contained in the project to a RoslynLSP subdirectory to emulate deployment of the language server.
-->
<Target Name="_CopyLanguageServerFiles" AfterTargets="ResolveProjectReferences">
<MSBuild Projects="..\Microsoft.CodeAnalysis.LanguageServer\Microsoft.CodeAnalysis.LanguageServer.csproj" Targets="GetOutputPath">
Copy link
Member

Choose a reason for hiding this comment

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

Definitely test this in VS to make sure this doesn't cause issues with the VS fast up todate check (basically a build, then build again with no changes shouldn't rebuild any of these projects)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we are good.

Build started at 3:14 PM...
========== Build: 0 succeeded, 0 failed, 23 up-to-date, 0 skipped ==========
========== Build completed at 3:14 PM and took 00.852 seconds ==========

_logger.LogError(e, "Exception while shutting down the LSP process.");

// Process may have gone bad, so not much else we can do.
_process.Kill();
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if we should have an assert here after this is killed to fail the test - unless we have tests specifically testing a failed shutdown we shouldn't hit this


<ItemGroup Condition="'$(_LanguageServerOutputPath)' != ''">
<_LanguageServerFile Include="$(_LanguageServerOutputPath)\**\*.*" />
<_LanguageServerFile Remove="$(_LanguageServerOutputPath)\**\*.mef-composition" />
Copy link
Member

Choose a reason for hiding this comment

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

this deletes the mef cache right? wonder if we should delete this every time the test runs (instead of in msbuild)

Copy link
Member Author

Choose a reason for hiding this comment

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

This is mostly for local dev scenarios where many compositions may exist in your local build of Microsoft.CodeAnalysis.LangaugeServer and there is no need to move them to the test folder. Lets save deleting compositions on each test run for when we move the ExportProviderBuilder tests to use the LSP.


namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests;

internal interface ILspClient
Copy link
Member

Choose a reason for hiding this comment

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

is there much of a point in having this? the test needs the actual lsp server as it needs to dispose of it

Copy link
Member Author

Choose a reason for hiding this comment

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

The benefit here is that TestLspServer and TestLspClient can use the same set of extension methods to drive the language server.

Copy link
Member

@dibarbet dibarbet left a comment

Choose a reason for hiding this comment

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

lgtm, I think Jason wanted to take a look as well though

@JoeRobich
Copy link
Member Author

Merging, will take any additional feedback as a follow up.

@JoeRobich JoeRobich merged commit 83fa931 into main Jan 24, 2025
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jan 24, 2025
@dibarbet dibarbet removed this from the Next milestone Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure Needs UX Triage untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Can't extract interface
2 participants