Skip to content

Simplify workspace initialization in the LSP server #78010

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

Conversation

jasonmalinowski
Copy link
Member

Right now we have the logic for which analyzers get added to a workspace in Program.cs, which calls a special method that specifically initializes the main host workspace. This refactors it so that could be used to initialize any workspace, and removes any tricky ordering problems that might happen by using cleaner MEF imports when we have them.

@jasonmalinowski jasonmalinowski requested a review from a team as a code owner April 4, 2025 23:44
@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 4, 2025
Right now we have the logic for which analyzers get added to a workspace
in Program.cs, which calls a special method that specifically
initializes the main host workspace. This refactors it so that could
be used to initialize any workspace, and removes any tricky ordering
problems that might happen by using cleaner MEF imports when we have
them.
@jasonmalinowski jasonmalinowski force-pushed the simplify-workspace-initialization branch from 9033536 to 55fbdc3 Compare April 4, 2025 23:45
@@ -54,17 +69,17 @@ public LanguageServerWorkspaceFactory(
public ProjectSystemHostInfo ProjectSystemHostInfo { get; }
public ProjectTargetFrameworkManager TargetFrameworkManager { get; }

public async Task InitializeSolutionLevelAnalyzersAsync(ImmutableArray<string> analyzerPaths)
public ImmutableArray<AnalyzerFileReference> CreateSolutionLevelAnalyzerReferencesForWorkspace(Workspace workspace)
Copy link
Member Author

Choose a reason for hiding this comment

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

@RikkiGibson Now you could just MEF import this type and call this method and that'd give you your list of AnalyzerFileReferences that could be used for any workspace.

@jasonmalinowski jasonmalinowski merged commit 60ea270 into dotnet:main Apr 5, 2025
25 checks passed
@jasonmalinowski jasonmalinowski deleted the simplify-workspace-initialization branch April 5, 2025 01:35
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE 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.

3 participants