From 0f3200c1515cefb56c4aa28ec0bd15bba71724e7 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Tue, 27 Jun 2023 11:47:32 +0530 Subject: [PATCH] Roslyn side changes to enable full solution background analysis in LSP/VSCode Work towards #68553. This needs a corresponding change in dotnet/vscode-csharp repo. I verified that this change + the corresponding vscode-csharp change enables FSA support in C# DevKit extension in VSCode. Needs couple more Roslyn side fixes as a follow-up: https://github.com/dotnet/roslyn/issues/68797 and https://github.com/dotnet/roslyn/issues/68798 --- .../Options/SolutionCrawlerOptionsStorage.cs | 14 ++++++++------ ...eConfigurationNotificationHandler_OptionList.cs | 7 +++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Features/LanguageServer/Protocol/Features/Options/SolutionCrawlerOptionsStorage.cs b/src/Features/LanguageServer/Protocol/Features/Options/SolutionCrawlerOptionsStorage.cs index 1f9772394ef7c..7952e5e081d4f 100644 --- a/src/Features/LanguageServer/Protocol/Features/Options/SolutionCrawlerOptionsStorage.cs +++ b/src/Features/LanguageServer/Protocol/Features/Options/SolutionCrawlerOptionsStorage.cs @@ -10,32 +10,34 @@ namespace Microsoft.CodeAnalysis.SolutionCrawler; internal static class SolutionCrawlerOptionsStorage { + private static readonly OptionGroup s_backgroundAnalysisOptionGroup = new(name: "background_analysis", description: ""); + /// /// Option to turn configure background analysis scope for the current user. /// public static readonly PerLanguageOption2 BackgroundAnalysisScopeOption = new( - "dotnet_solution_crawler_background_analysis_scope", defaultValue: BackgroundAnalysisScope.Default, serializer: EditorConfigValueSerializer.CreateSerializerForEnum()); + "dotnet_solution_crawler_background_analysis_scope", defaultValue: BackgroundAnalysisScope.Default, group: s_backgroundAnalysisOptionGroup, serializer: EditorConfigValueSerializer.CreateSerializerForEnum()); /// /// Option to turn configure background analysis scope for the current solution. /// public static readonly Option2 SolutionBackgroundAnalysisScopeOption = new( - "SolutionCrawlerOptionsStorage_SolutionBackgroundAnalysisScopeOption", defaultValue: null, serializer: EditorConfigValueSerializer.CreateSerializerForNullableEnum()); + "SolutionCrawlerOptionsStorage_SolutionBackgroundAnalysisScopeOption", defaultValue: null, group: s_backgroundAnalysisOptionGroup, serializer: EditorConfigValueSerializer.CreateSerializerForNullableEnum()); /// /// Option to configure compiler diagnostics scope for the current user. /// public static readonly PerLanguageOption2 CompilerDiagnosticsScopeOption = new( - "dotnet_compiler_diagnostics_scope", defaultValue: CompilerDiagnosticsScope.OpenFiles, serializer: EditorConfigValueSerializer.CreateSerializerForEnum()); + "dotnet_compiler_diagnostics_scope", defaultValue: CompilerDiagnosticsScope.OpenFiles, group: s_backgroundAnalysisOptionGroup, serializer: EditorConfigValueSerializer.CreateSerializerForEnum()); public static readonly PerLanguageOption2 RemoveDocumentDiagnosticsOnDocumentClose = new( - "remove_document_diagnostics_on_document_close", defaultValue: false); + "remove_document_diagnostics_on_document_close", defaultValue: false, group: s_backgroundAnalysisOptionGroup); public static readonly Option2 EnableDiagnosticsInSourceGeneratedFiles = new( - "dotnet_enable_diagnostics_in_source_generated_files", defaultValue: null); + "dotnet_enable_diagnostics_in_source_generated_files", defaultValue: null, group: s_backgroundAnalysisOptionGroup); public static readonly Option2 EnableDiagnosticsInSourceGeneratedFilesFeatureFlag = new( - "dotnet_enable_diagnostics_in_source_generated_files_feature_flag", defaultValue: false); + "dotnet_enable_diagnostics_in_source_generated_files_feature_flag", defaultValue: false, group: s_backgroundAnalysisOptionGroup); /// /// Enables forced scope when low VM is detected to improve performance. diff --git a/src/Features/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler_OptionList.cs b/src/Features/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler_OptionList.cs index 646690539eaba..e2e25c2880876 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler_OptionList.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler_OptionList.cs @@ -7,11 +7,11 @@ using Microsoft.CodeAnalysis.DocumentHighlighting; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.ImplementType; -using Microsoft.CodeAnalysis.Indentation; using Microsoft.CodeAnalysis.InlineHints; using Microsoft.CodeAnalysis.MetadataAsSource; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.QuickInfo; +using Microsoft.CodeAnalysis.SolutionCrawler; using Microsoft.CodeAnalysis.SymbolSearch; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Configuration @@ -53,6 +53,9 @@ internal partial class DidChangeConfigurationNotificationHandler FormattingOptions2.IndentationSize, FormattingOptions2.UseTabs, FormattingOptions2.NewLine, - FormattingOptions2.InsertFinalNewLine); + FormattingOptions2.InsertFinalNewLine, + // Background analysis + SolutionCrawlerOptionsStorage.BackgroundAnalysisScopeOption, + SolutionCrawlerOptionsStorage.CompilerDiagnosticsScopeOption); } }