Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Mar 17, 2022
1 parent 16f081d commit bd48e2d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ public WorkspaceConfigurationService(IGlobalOptionService globalOptions)

public WorkspaceConfigurationOptions Options
=> _lazyOptions ??= _globalOptions.GetWorkspaceConfigurationOptions();

internal void Clear()
=> _lazyOptions = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,15 @@ public static void Main()

if (invokeFromSourceGeneratedFile)
{
var workspace = await TestServices.Shell.GetComponentModelServiceAsync<VisualStudioWorkspace>(HangMitigatingCancellationToken);

// clear configuration options already read by initialization above, so that the global option update below is effective:
var configurationService = (WorkspaceConfigurationService)workspace.Services.GetRequiredService<IWorkspaceConfigurationService>();
configurationService.Clear();

var globalOptions = await TestServices.Shell.GetComponentModelServiceAsync<IGlobalOptionService>(HangMitigatingCancellationToken);
globalOptions.SetGlobalOption(new OptionKey(WorkspaceConfigurationOptionsStorage.EnableOpeningSourceGeneratedFilesInWorkspace, language: null), true);

await TestServices.Editor.GoToDefinitionAsync(HangMitigatingCancellationToken);
Assert.Equal($"{HelloWorldGenerator.GeneratedEnglishClassName}.cs {ServicesVSResources.generated_suffix}", await TestServices.Shell.GetActiveWindowCaptionAsync(HangMitigatingCancellationToken));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Microsoft.VisualStudio.Extensibility.Testing;
using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using Microsoft.VisualStudio.LanguageServices;
using Microsoft.VisualStudio.LanguageServices.Implementation;
using Microsoft.VisualStudio.LanguageServices.Telemetry;
using Microsoft.VisualStudio.Shell.Interop;
Expand All @@ -36,6 +37,11 @@ internal partial class StateResetInProcess

public async Task ResetGlobalOptionsAsync(CancellationToken cancellationToken)
{
// clear configuration options, so that the workspace configuration global option update below is effective:
var workspace = await TestServices.Shell.GetComponentModelServiceAsync<VisualStudioWorkspace>(cancellationToken);
var configurationService = (WorkspaceConfigurationService)workspace.Services.GetRequiredService<IWorkspaceConfigurationService>();
configurationService.Clear();

var globalOptions = await GetComponentModelServiceAsync<IGlobalOptionService>(cancellationToken);
ResetOption2(globalOptions, FeatureOnOffOptions.NavigateToDecompiledSources);
ResetOption2(globalOptions, WorkspaceConfigurationOptionsStorage.EnableOpeningSourceGeneratedFilesInWorkspace);
Expand Down

0 comments on commit bd48e2d

Please sign in to comment.