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

Switch SG mode to 'balanced' by default #73618

Merged
merged 13 commits into from
May 22, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public partial class GeneratedClass : IInterface { }
</Document>
</Project>
</Workspace>, host:=host, renameTo:="A", sourceGenerator:=New GeneratorThatImplementsInterfaceMethod())

End Using
End Sub

Expand Down
7 changes: 4 additions & 3 deletions src/EditorFeatures/Test2/Rename/RenameEngineResult.vb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ Imports System.Collections.Immutable
Imports System.Threading
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.CodeActions
Imports Microsoft.CodeAnalysis.CodeCleanup
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Host
Imports Microsoft.CodeAnalysis.Options
Imports Microsoft.CodeAnalysis.Remote.Testing
Imports Microsoft.CodeAnalysis.Rename
Imports Microsoft.CodeAnalysis.Rename.ConflictEngine
Expand Down Expand Up @@ -62,14 +60,17 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Rename
Dim composition = EditorTestCompositions.EditorFeatures.AddParts(
GetType(NoCompilationContentTypeLanguageService),
GetType(NoCompilationContentTypeDefinitions),
GetType(WorkspaceTestLogger))
GetType(WorkspaceTestLogger),
GetType(TestWorkspaceConfigurationService))

If host = RenameTestHost.OutOfProcess_SingleCall OrElse host = RenameTestHost.OutOfProcess_SplitCall Then
composition = composition.WithTestHostParts(TestHost.OutOfProcess)
End If

Dim workspace = TestWorkspace.CreateWorkspace(workspaceXml, composition:=composition)
workspace.Services.SolutionServices.SetWorkspaceTestOutput(helper)
workspace.GlobalOptions.SetGlobalOption(
WorkspaceConfigurationOptionsStorage.SourceGeneratorExecution, SourceGeneratorExecutionPreference.Automatic)

If sourceGenerator IsNot Nothing Then
workspace.OnAnalyzerReferenceAdded(workspace.CurrentSolution.ProjectIds.Single(), New TestGeneratorReference(sourceGenerator))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ public static WorkspaceConfigurationOptions GetWorkspaceConfigurationOptions(thi
SourceGeneratorExecutionPreferenceUtilities.GetEditorConfigString));

public static readonly Option2<bool> SourceGeneratorExecutionBalancedFeatureFlag = new(
"dotnet_source_generator_execution_balanced_feature_flag", false);
"dotnet_source_generator_execution_balanced_feature_flag", true);
Copy link
Member Author

Choose a reason for hiding this comment

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

note: we still have the feature flag. So we still have control-tower support to flip this back to 'false' if we run into any problems with this in the wild.

Copy link
Member

Choose a reason for hiding this comment

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

Think we might need to have a modification here to leave it false by default for VSCode - I haven't yet had a chance to implement balanced mode there yet. Easiest way if you want to change the default is have a line of code in the language server project to explicitly set this to false - https://github.com/dotnet/roslyn/blob/main/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs#L90

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.Editor.Shared.Utilities
Imports Microsoft.CodeAnalysis.Editor.UnitTests
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Host
Imports Microsoft.CodeAnalysis.Shared.TestHooks
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.Text
Expand Down Expand Up @@ -131,7 +133,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.SolutionExplorer
</Project>
</Workspace>

Using workspace = EditorTestWorkspace.Create(workspaceXml)
Using workspace = EditorTestWorkspace.Create(
workspaceXml,
composition:=EditorTestCompositions.EditorFeatures.AddParts(GetType(TestWorkspaceConfigurationService)))

workspace.GlobalOptions.SetGlobalOption(
WorkspaceConfigurationOptionsStorage.SourceGeneratorExecution, SourceGeneratorExecutionPreference.Automatic)

Dim projectId = workspace.Projects.Single().Id
Dim source = CreateItemSourceForAnalyzerReference(workspace, projectId)
Dim generatorItem = Assert.IsAssignableFrom(Of SourceGeneratorItem)(Assert.Single(source.Items))
Expand Down Expand Up @@ -159,7 +167,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.SolutionExplorer
</Project>
</Workspace>

Using workspace = EditorTestWorkspace.Create(workspaceXml)
Using workspace = EditorTestWorkspace.Create(
workspaceXml,
composition:=EditorTestCompositions.EditorFeatures.AddParts(GetType(TestWorkspaceConfigurationService)))

workspace.GlobalOptions.SetGlobalOption(
WorkspaceConfigurationOptionsStorage.SourceGeneratorExecution, SourceGeneratorExecutionPreference.Automatic)

Dim projectId = workspace.Projects.Single().Id
Dim source = CreateItemSourceForAnalyzerReference(workspace, projectId)
Dim generatorItem = Assert.IsAssignableFrom(Of SourceGeneratorItem)(Assert.Single(source.Items))
Expand Down
Loading