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

Remove A/B option to disable recoverable texts #73965

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -25,9 +24,6 @@ public static WorkspaceConfigurationOptions GetWorkspaceConfigurationOptions(thi
public static readonly Option2<StorageDatabase> Database = new(
"dotnet_storage_database", WorkspaceConfigurationOptions.Default.CacheStorage, serializer: EditorConfigValueSerializer.CreateSerializerForEnum<StorageDatabase>());

public static readonly Option2<bool> DisableRecoverableText = new(
"dotnet_disable_recoverable_text", WorkspaceConfigurationOptions.Default.DisableRecoverableText);

public static readonly Option2<bool> ValidateCompilationTrackerStates = new(
"dotnet_validate_compilation_tracker_states", WorkspaceConfigurationOptions.Default.ValidateCompilationTrackerStates);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -59,6 +58,5 @@ public WorkspaceConfigurationOptions()
/// </summary>
public static readonly WorkspaceConfigurationOptions RemoteDefault = new(
CacheStorage: StorageDatabase.None,
EnableOpeningSourceGeneratedFiles: false,
DisableRecoverableText: false);
EnableOpeningSourceGeneratedFiles: false);
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,11 @@ public TextDocumentState(SolutionServices solutionServices, DocumentInfo info, L
public IReadOnlyList<string> 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<IWorkspaceConfigurationService>();
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;
Expand Down Expand Up @@ -144,13 +137,11 @@ public async Task<VersionStamp> 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)
{
Expand All @@ -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<IWorkspaceConfigurationService>();
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
Expand Down
Loading