Skip to content

Commit 97701a7

Browse files
Remove feature flag for SourceGen execution (#77712)
This flag was added back in April 2024 (#72494) when we added 'balanced mode' execution for Source GEnerators. The flag existed so that if we discovered a major problem, post ship, we could disable the feature. In other words, an emergency rip cord. We've had no problems since shipping the feature in all this time, and we haven't had to exercise the flag. So i'm removing it from Dev18.
2 parents b179444 + c44c7ac commit 97701a7

File tree

7 files changed

+16
-42
lines changed

7 files changed

+16
-42
lines changed

src/EditorFeatures/Test/Options/GlobalOptionsTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ private static bool IsStoredInGlobalOptions(PropertyInfo property, string? langu
168168
property.DeclaringType == typeof(DocumentFormattingOptions) && property.Name == nameof(DocumentFormattingOptions.InsertFinalNewLine) ||
169169
property.DeclaringType == typeof(ClassificationOptions) && property.Name == nameof(ClassificationOptions.FrozenPartialSemantics) ||
170170
property.DeclaringType == typeof(HighlightingOptions) && property.Name == nameof(HighlightingOptions.FrozenPartialSemantics) ||
171-
property.DeclaringType == typeof(BlockStructureOptions) && property.Name == nameof(BlockStructureOptions.IsMetadataAsSource));
171+
property.DeclaringType == typeof(BlockStructureOptions) && property.Name == nameof(BlockStructureOptions.IsMetadataAsSource) ||
172+
property.DeclaringType == typeof(WorkspaceConfigurationOptions) && property.Name == nameof(WorkspaceConfigurationOptions.SourceGeneratorExecution));
172173

173174
/// <summary>
174175
/// Our mock <see cref="IGlobalOptionService"/> implementation returns a non-default value for each option it reads.

src/LanguageServer/Protocol/Features/Options/WorkspaceConfigurationOptionsStorage.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,22 @@ internal static class WorkspaceConfigurationOptionsStorage
1010
{
1111
public static WorkspaceConfigurationOptions GetWorkspaceConfigurationOptions(this IGlobalOptionService globalOptions)
1212
=> new(
13-
SourceGeneratorExecution:
14-
globalOptions.GetOption(SourceGeneratorExecution) ??
15-
(globalOptions.GetOption(SourceGeneratorExecutionBalancedFeatureFlag) ? SourceGeneratorExecutionPreference.Balanced : SourceGeneratorExecutionPreference.Automatic),
13+
SourceGeneratorExecution: globalOptions.GetOption(SourceGeneratorExecution),
1614
ReloadChangedAnalyzerReferences:
1715
globalOptions.GetOption(ReloadChangedAnalyzerReferences) ?? globalOptions.GetOption(ReloadChangedAnalyzerReferencesFeatureFlag),
1816
ValidateCompilationTrackerStates: globalOptions.GetOption(ValidateCompilationTrackerStates));
1917

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

23-
public static readonly Option2<SourceGeneratorExecutionPreference?> SourceGeneratorExecution = new(
21+
public static readonly Option2<SourceGeneratorExecutionPreference> SourceGeneratorExecution = new(
2422
"dotnet_source_generator_execution",
25-
defaultValue: null,
23+
defaultValue: SourceGeneratorExecutionPreference.Balanced,
2624
isEditorConfigOption: true,
27-
serializer: new EditorConfigValueSerializer<SourceGeneratorExecutionPreference?>(
28-
s => SourceGeneratorExecutionPreferenceUtilities.Parse(s),
25+
serializer: new EditorConfigValueSerializer<SourceGeneratorExecutionPreference>(
26+
s => SourceGeneratorExecutionPreferenceUtilities.Parse(s, SourceGeneratorExecutionPreference.Balanced),
2927
SourceGeneratorExecutionPreferenceUtilities.GetEditorConfigString));
3028

31-
public static readonly Option2<bool> SourceGeneratorExecutionBalancedFeatureFlag = new(
32-
"dotnet_source_generator_execution_balanced_feature_flag", true);
33-
3429
public static readonly Option2<bool?> ReloadChangedAnalyzerReferences = new(
3530
"dotnet_reload_changed_analyzer_references",
3631
defaultValue: null,

src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,9 @@ public AdvancedOptionPageControl(OptionStore optionStore) : base(optionStore)
7373
BindToOption(Show_Remove_Unused_References_command_in_Solution_Explorer, FeatureOnOffOptions.OfferRemoveUnusedReferences, () => true);
7474

7575
// Source Generators
76-
BindToOption(Automatic_Run_generators_after_any_change, WorkspaceConfigurationOptionsStorage.SourceGeneratorExecution, SourceGeneratorExecutionPreference.Automatic, () =>
77-
{
78-
// If the option hasn't been set by the user, then check the feature flag. If the feature flag has set
79-
// us to only run when builds complete, then we're not in automatic mode. So we `!` the result.
80-
return !optionStore.GetOption(WorkspaceConfigurationOptionsStorage.SourceGeneratorExecutionBalancedFeatureFlag);
81-
});
82-
BindToOption(Balanced_Run_generators_after_saving_or_building, WorkspaceConfigurationOptionsStorage.SourceGeneratorExecution, SourceGeneratorExecutionPreference.Balanced, () =>
83-
{
84-
// If the option hasn't been set by the user, then check the feature flag. If the feature flag has set
85-
// us to only run when builds complete, then we're in `Balanced_Run_generators_after_saving_or_building` mode and directly return it.
86-
return optionStore.GetOption(WorkspaceConfigurationOptionsStorage.SourceGeneratorExecutionBalancedFeatureFlag);
87-
});
76+
BindToOption(Automatic_Run_generators_after_any_change, WorkspaceConfigurationOptionsStorage.SourceGeneratorExecution, SourceGeneratorExecutionPreference.Automatic);
77+
BindToOption(Balanced_Run_generators_after_saving_or_building, WorkspaceConfigurationOptionsStorage.SourceGeneratorExecution, SourceGeneratorExecutionPreference.Balanced);
78+
8879
BindToOption(Analyze_source_generated_files, SolutionCrawlerOptionsStorage.EnableDiagnosticsInSourceGeneratedFiles, () =>
8980
{
9081
// If the option has not been set by the user, check if the option is enabled from experimentation. If so, default to that.

src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,6 @@ public bool TryFetch(LocalUserRegistryOptionPersister persister, OptionKey2 opti
424424
{"dotnet_enable_diagnostics_in_source_generated_files", new RoamingProfileStorage("TextEditor.Roslyn.Specific.EnableDiagnosticsInSourceGeneratedFilesExperiment")},
425425
{"dotnet_enable_diagnostics_in_source_generated_files_feature_flag", new FeatureFlagStorage(@"Roslyn.EnableDiagnosticsInSourceGeneratedFiles")},
426426
{"dotnet_source_generator_execution", new RoamingProfileStorage("TextEditor.Roslyn.Specific.SourceGeneratorExecution")},
427-
{"dotnet_source_generator_execution_balanced_feature_flag", new FeatureFlagStorage(@"Roslyn.SourceGeneratorExecutionBalanced")},
428427
{"dotnet_reload_changed_analyzer_references", new RoamingProfileStorage("TextEditor.Roslyn.Specific.ReloadChangedAnalyzerReferences")},
429428
{"dotnet_reload_changed_analyzer_references_feature_flag", new FeatureFlagStorage(@"Roslyn.ReloadChangedAnalyzerReferences")},
430429
{"xaml_enable_lsp_intellisense", new FeatureFlagStorage(@"Xaml.EnableLspIntelliSense")},

src/VisualStudio/IntegrationTest/New.IntegrationTests/InProcess/StateResetInProcess.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public async Task ResetGlobalOptionsAsync(CancellationToken cancellationToken)
6565
ResetOption(globalOptions, InlineRenameUIOptionsStorage.UseInlineAdornment);
6666
ResetOption(globalOptions, MetadataAsSourceOptionsStorage.NavigateToDecompiledSources);
6767
ResetOption(globalOptions, WorkspaceConfigurationOptionsStorage.SourceGeneratorExecution);
68-
ResetOption(globalOptions, WorkspaceConfigurationOptionsStorage.SourceGeneratorExecutionBalancedFeatureFlag);
6968
ResetPerLanguageOption(globalOptions, FormattingOptions2.IndentationSize);
7069
ResetPerLanguageOption(globalOptions, BlockStructureOptionsStorage.CollapseSourceLinkEmbeddedDecompiledFilesWhenFirstOpened);
7170
ResetPerLanguageOption(globalOptions, CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces);

src/VisualStudio/VisualBasic/Impl/Options/AdvancedOptionPageControl.xaml.vb

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,9 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
7878
End Function)
7979

8080
' Source Generators
81-
BindToOption(Automatic_Run_generators_after_any_change, WorkspaceConfigurationOptionsStorage.SourceGeneratorExecution, SourceGeneratorExecutionPreference.Automatic,
82-
Function()
83-
' If the option hasn't been set by the user, then check the feature flag. If the feature flag has set
84-
' us to only run when builds complete, then we're not in automatic mode. So we `!` the result.
85-
Return Not optionStore.GetOption(WorkspaceConfigurationOptionsStorage.SourceGeneratorExecutionBalancedFeatureFlag)
86-
End Function)
81+
BindToOption(Automatic_Run_generators_after_any_change, WorkspaceConfigurationOptionsStorage.SourceGeneratorExecution, SourceGeneratorExecutionPreference.Automatic)
82+
BindToOption(Balanced_Run_generators_after_saving_or_building, WorkspaceConfigurationOptionsStorage.SourceGeneratorExecution, SourceGeneratorExecutionPreference.Balanced)
8783

88-
BindToOption(Balanced_Run_generators_after_saving_or_building, WorkspaceConfigurationOptionsStorage.SourceGeneratorExecution, SourceGeneratorExecutionPreference.Balanced,
89-
Function()
90-
' If the option hasn't been set by the user, then check the feature flag. If the feature flag has set
91-
' us to only run when builds complete, then we're in `Balanced_Run_generators_after_saving_or_building` mode and directly return it.
92-
Return optionStore.GetOption(WorkspaceConfigurationOptionsStorage.SourceGeneratorExecutionBalancedFeatureFlag)
93-
End Function)
9484
BindToOption(Analyze_source_generated_files, SolutionCrawlerOptionsStorage.EnableDiagnosticsInSourceGeneratedFiles,
9585
Function()
9686
' If the option has not been set by the user, check if the option is enabled from experimentation.

src/Workspaces/Core/Portable/Workspace/SourceGeneratorExecution.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,24 @@ internal static class SourceGeneratorExecutionPreferenceUtilities
2525
private const string balanced = "balanced";
2626

2727
// Default to beginning_of_line if we don't know the value.
28-
public static string GetEditorConfigString(SourceGeneratorExecutionPreference? value)
28+
public static string GetEditorConfigString(SourceGeneratorExecutionPreference value)
2929
{
3030
return value switch
3131
{
3232
SourceGeneratorExecutionPreference.Automatic => automatic,
3333
SourceGeneratorExecutionPreference.Balanced => balanced,
34-
null => "",
3534
_ => throw ExceptionUtilities.UnexpectedValue(value),
3635
};
3736
}
3837

39-
public static SourceGeneratorExecutionPreference? Parse(
40-
string optionString)
38+
public static SourceGeneratorExecutionPreference Parse(
39+
string optionString, SourceGeneratorExecutionPreference defaultValue)
4140
{
4241
return optionString switch
4342
{
4443
automatic => SourceGeneratorExecutionPreference.Automatic,
4544
balanced => SourceGeneratorExecutionPreference.Balanced,
46-
_ => null,
45+
_ => defaultValue,
4746
};
4847
}
4948
}

0 commit comments

Comments
 (0)