From 6ad4dbecc8ec9020b91efbcabb5ea28aa07db40a Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Wed, 12 Jun 2024 09:31:00 -0700 Subject: [PATCH 1/2] Remove A/B option to disable recoverable texts --- .../Options/WorkspaceConfigurationOptionsStorage.cs | 4 ---- .../Core/Def/Options/VisualStudioOptionStorage.cs | 1 - .../Portable/Workspace/IWorkspaceConfigurationService.cs | 8 +++----- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/LanguageServer/Protocol/Features/Options/WorkspaceConfigurationOptionsStorage.cs b/src/LanguageServer/Protocol/Features/Options/WorkspaceConfigurationOptionsStorage.cs index 514450460e7f3..8fab97e720a1e 100644 --- a/src/LanguageServer/Protocol/Features/Options/WorkspaceConfigurationOptionsStorage.cs +++ b/src/LanguageServer/Protocol/Features/Options/WorkspaceConfigurationOptionsStorage.cs @@ -15,7 +15,6 @@ public static WorkspaceConfigurationOptions GetWorkspaceConfigurationOptions(thi EnableOpeningSourceGeneratedFiles: globalOptions.GetOption(EnableOpeningSourceGeneratedFilesInWorkspace) ?? globalOptions.GetOption(EnableOpeningSourceGeneratedFilesInWorkspaceFeatureFlag), - DisableRecoverableText: globalOptions.GetOption(DisableRecoverableText), SourceGeneratorExecution: globalOptions.GetOption(SourceGeneratorExecution) ?? (globalOptions.GetOption(SourceGeneratorExecutionBalancedFeatureFlag) ? SourceGeneratorExecutionPreference.Balanced : SourceGeneratorExecutionPreference.Automatic), @@ -25,9 +24,6 @@ public static WorkspaceConfigurationOptions GetWorkspaceConfigurationOptions(thi public static readonly Option2 Database = new( "dotnet_storage_database", WorkspaceConfigurationOptions.Default.CacheStorage, serializer: EditorConfigValueSerializer.CreateSerializerForEnum()); - public static readonly Option2 DisableRecoverableText = new( - "dotnet_disable_recoverable_text", WorkspaceConfigurationOptions.Default.DisableRecoverableText); - public static readonly Option2 ValidateCompilationTrackerStates = new( "dotnet_validate_compilation_tracker_states", WorkspaceConfigurationOptions.Default.ValidateCompilationTrackerStates); diff --git a/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs b/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs index 8841c4fa3071a..a266a724e10d9 100644 --- a/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs +++ b/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs @@ -421,7 +421,6 @@ public bool TryFetch(LocalUserRegistryOptionPersister persister, OptionKey2 opti {"visual_basic_style_unused_value_assignment_preference", new RoamingProfileStorage("TextEditor.VisualBasic.Specific.UnusedValueAssignmentPreference")}, {"visual_basic_style_unused_value_expression_statement_preference", new RoamingProfileStorage("TextEditor.VisualBasic.Specific.UnusedValueExpressionStatementPreference")}, {"visual_studio_navigate_to_object_browser", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.NavigateToObjectBrowser")}, - {"dotnet_disable_recoverable_text", new FeatureFlagStorage(@"Roslyn.DisableRecoverableText")}, {"dotnet_validate_compilation_tracker_states", new FeatureFlagStorage(@"Roslyn.ValidateCompilationTrackerStates")}, {"dotnet_enable_diagnostics_in_source_generated_files", new RoamingProfileStorage("TextEditor.Roslyn.Specific.EnableDiagnosticsInSourceGeneratedFilesExperiment")}, {"dotnet_enable_diagnostics_in_source_generated_files_feature_flag", new FeatureFlagStorage(@"Roslyn.EnableDiagnosticsInSourceGeneratedFiles")}, diff --git a/src/Workspaces/Core/Portable/Workspace/IWorkspaceConfigurationService.cs b/src/Workspaces/Core/Portable/Workspace/IWorkspaceConfigurationService.cs index 288fbddf9fc72..86d5673603214 100644 --- a/src/Workspaces/Core/Portable/Workspace/IWorkspaceConfigurationService.cs +++ b/src/Workspaces/Core/Portable/Workspace/IWorkspaceConfigurationService.cs @@ -36,9 +36,8 @@ internal sealed class DefaultWorkspaceConfigurationService() : IWorkspaceConfigu internal readonly record struct WorkspaceConfigurationOptions( [property: DataMember(Order = 0)] StorageDatabase CacheStorage = StorageDatabase.SQLite, [property: DataMember(Order = 1)] bool EnableOpeningSourceGeneratedFiles = false, - [property: DataMember(Order = 2)] bool DisableRecoverableText = false, - [property: DataMember(Order = 3)] SourceGeneratorExecutionPreference SourceGeneratorExecution = SourceGeneratorExecutionPreference.Automatic, - [property: DataMember(Order = 4)] bool ValidateCompilationTrackerStates = + [property: DataMember(Order = 2)] SourceGeneratorExecutionPreference SourceGeneratorExecution = SourceGeneratorExecutionPreference.Automatic, + [property: DataMember(Order = 3)] bool ValidateCompilationTrackerStates = #if DEBUG // We will default this on in DEBUG builds true #else @@ -59,6 +58,5 @@ public WorkspaceConfigurationOptions() /// public static readonly WorkspaceConfigurationOptions RemoteDefault = new( CacheStorage: StorageDatabase.None, - EnableOpeningSourceGeneratedFiles: false, - DisableRecoverableText: false); + EnableOpeningSourceGeneratedFiles: false); } From 8efeb0bbf3924153f25279c75e064cc933b09412 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Wed, 12 Jun 2024 09:35:51 -0700 Subject: [PATCH 2/2] Fallout --- .../Workspace/Solution/TextDocumentState.cs | 32 ++++++------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentState.cs b/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentState.cs index 63fa8cb9f446d..bcf207ad2c851 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentState.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/TextDocumentState.cs @@ -69,18 +69,11 @@ public TextDocumentState(SolutionServices solutionServices, DocumentInfo info, L public IReadOnlyList Folders => Attributes.Folders; public string Name => Attributes.Name; - private static ITextAndVersionSource CreateStrongText(TextAndVersion text) - => new ConstantTextAndVersionSource(text); + private static ConstantTextAndVersionSource CreateStrongText(TextAndVersion text) + => new(text); - private static ITextAndVersionSource CreateRecoverableText(TextAndVersion text, SolutionServices services) - { - var service = services.GetRequiredService(); - var options = service.Options; - - return options.DisableRecoverableText - ? CreateStrongText(text) - : new RecoverableTextAndVersion(new ConstantTextAndVersionSource(text), services); - } + private static RecoverableTextAndVersion CreateRecoverableText(TextAndVersion text, SolutionServices services) + => new(new ConstantTextAndVersionSource(text), services); public ITemporaryStorageTextHandle? StorageHandle => (TextAndVersionSource as RecoverableTextAndVersion)?.StorageHandle; @@ -144,13 +137,11 @@ public async Task GetTextVersionAsync(CancellationToken cancellati } public TextDocumentState UpdateText(TextAndVersion newTextAndVersion, PreservationMode mode) - { - var newTextSource = mode == PreservationMode.PreserveIdentity - ? CreateStrongText(newTextAndVersion) - : CreateRecoverableText(newTextAndVersion, solutionServices); - - return UpdateText(newTextSource, mode, incremental: true); - } + => UpdateText(mode == PreservationMode.PreserveIdentity + ? CreateStrongText(newTextAndVersion) + : CreateRecoverableText(newTextAndVersion, solutionServices), + mode, + incremental: true); public TextDocumentState UpdateText(SourceText newText, PreservationMode mode) { @@ -170,12 +161,9 @@ public TextDocumentState UpdateText(TextLoader loader, PreservationMode mode) private static ITextAndVersionSource CreateTextFromLoader(TextLoader loader, PreservationMode mode, SolutionServices solutionServices) { - var service = solutionServices.GetRequiredService(); - var options = service.Options; - // If the caller is explicitly stating that identity must be preserved, then we created a source that will load // from the loader the first time, but then cache that result so that hte same result is *always* returned. - if (mode == PreservationMode.PreserveIdentity || options.DisableRecoverableText) + if (mode == PreservationMode.PreserveIdentity) return new LoadableTextAndVersionSource(loader, cacheResult: true); // If the loader asks us to always hold onto it strongly, then we do not want to create a recoverable text