Skip to content

Commit

Permalink
Remove dodgy UpdateSolution method in cohosting tests (#10627)
Browse files Browse the repository at this point in the history
Part of #9519 and
#10603
Requires dotnet/roslyn#74402

Removes a little more dodginess in the cohosting tests by actually using
the `RazorPinnedSolutionInfoWrapper` for solution checksums, just like
the real OOP services.
  • Loading branch information
davidwengier authored Jul 18, 2024
2 parents 8fd82a8 + 9abb3a4 commit d91189f
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 77 deletions.
76 changes: 38 additions & 38 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,82 +11,82 @@
<Sha>9ae78a4e6412926d19ba97cfed159bf9de70b538</Sha>
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Wpf" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Wpf" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.11.0-3.24303.3">
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.12.0-1.24366.6">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>ec443fac0dcc4e9ce2f83b9202f689dc2872b9f3</Sha>
<Sha>30edd04fd41dec9e8f9f48e698ebd5b80d9f7677</Sha>
<SourceBuild RepoName="roslyn" ManagedOnly="true" />
</Dependency>
</ProductDependencies>
Expand Down
38 changes: 19 additions & 19 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,25 @@
<MicrosoftSourceBuildIntermediatearcadePackageVersion>9.0.0-beta.24352.2</MicrosoftSourceBuildIntermediatearcadePackageVersion>
<MicrosoftDotNetXliffTasksPackageVersion>1.0.0-beta.23475.1</MicrosoftDotNetXliffTasksPackageVersion>
<MicrosoftSourceBuildIntermediatexlifftasksPackageVersion>1.0.0-beta.23475.1</MicrosoftSourceBuildIntermediatexlifftasksPackageVersion>
<MicrosoftNetCompilersToolsetPackageVersion>4.11.0-3.24303.3</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.11.0-3.24303.3</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.11.0-3.24303.3</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftSourceBuildIntermediateroslynPackageVersion>4.11.0-3.24303.3</MicrosoftSourceBuildIntermediateroslynPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.11.0-3.24303.3</MicrosoftVisualStudioLanguageServicesPackageVersion>
<MicrosoftNetCompilersToolsetPackageVersion>4.12.0-1.24366.6</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.12.0-1.24366.6</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.12.0-1.24366.6</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftSourceBuildIntermediateroslynPackageVersion>4.12.0-1.24366.6</MicrosoftSourceBuildIntermediateroslynPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.12.0-1.24366.6</MicrosoftVisualStudioLanguageServicesPackageVersion>
<!--
Exception - Microsoft.Extensions.ObjectPool and System.Collections.Immutable packages are not updated by automation,
but are present in Version.Details.xml for source-build PVP flow. See the comment in Version.Details.xml for more information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.LanguageServer.Extensions;
using Microsoft.AspNetCore.Razor.LanguageServer.Hosting;
Expand Down Expand Up @@ -34,20 +35,20 @@ public async Task LocaleIsSetCorrectly()
server.Initialize();
var queue = server.GetTestAccessor().GetRequestExecutionQueue();

var initializeParams = new InitializeParams
var initializeParams = JsonSerializer.SerializeToElement(new InitializeParams
{
Capabilities = new(),
Locale = "de-DE"
};
});

await queue.ExecuteAsync<InitializeParams, InitializeResult>(initializeParams, Methods.InitializeName, LanguageServerConstants.DefaultLanguageName, server.GetLspServices(), DisposalToken);
await queue.ExecuteAsync(initializeParams, Methods.InitializeName, server.GetLspServices(), DisposalToken);

// We have to send one more request, because culture is set before any request starts, but the first initialize request has to
// be started in order to set the culture.
// The request isn't actually valid, so we wrap it in a try catch, but we don't care for this test
try
{
await queue.ExecuteAsync<VSInternalDocumentDiagnosticsParams, VSInternalDiagnosticReport[]>(new(), VSInternalMethods.DocumentPullDiagnosticName, LanguageServerConstants.DefaultLanguageName, server.GetLspServices(), DisposalToken);
await queue.ExecuteAsync(JsonSerializer.SerializeToElement(new object()), VSInternalMethods.DocumentPullDiagnosticName, server.GetLspServices(), DisposalToken);
}
catch { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ public async Task TrySynchronize_NewDocument_Generates()

Assert.True(await synchronizer.TrySynchronizeAsync(document, DisposalToken));

var version = await RazorDocumentVersion.CreateAsync(document, DisposalToken);

Assert.Equal(1, version.WorkspaceVersion);

Assert.Collection(publisher.Publishes,
i =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
using Microsoft.CodeAnalysis.Remote.Razor;
using Xunit;

namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;

internal sealed class TestBrokeredServiceInterceptor : IRazorBrokeredServiceInterceptor
{
private Solution? _solution;
private readonly TestSolutionStore _solutionStore = new();

public void UpdateSolution(Solution solution)
{
_solution = solution;
}
public Task<RazorPinnedSolutionInfoWrapper> GetSolutionInfoAsync(Solution solution, CancellationToken cancellationToken)
=> _solutionStore.AddAsync(solution, cancellationToken);

public ValueTask RunServiceAsync(
Func<CancellationToken, ValueTask> implementation,
Expand All @@ -29,5 +27,11 @@ public ValueTask<T> RunServiceAsync<T>(
RazorPinnedSolutionInfoWrapper solutionInfo,
Func<Solution, ValueTask<T>> implementation,
CancellationToken cancellationToken)
=> implementation(_solution.AssumeNotNull());
{
var solution = _solutionStore.Get(solutionInfo);

Assert.NotNull(solution);

return implementation(solution);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ private async Task<TService> GetOrCreateServiceAsync<TService>()
{
var service = await GetOrCreateServiceAsync<TService>();

// In an ideal world we'd be able to maintain a dictionary of solution checksums in TestServiceBroker, and use
// the RazorPinnedSolutionInfoWrapper properly, but we need Roslyn changes for that. For now, this works fine
// as we don't have any code that makes multiple parallel calls to TryInvokeAsync in the same test.
var solutionInfo = new RazorPinnedSolutionInfoWrapper();
_serviceInterceptor.UpdateSolution(solution);
var solutionInfo = await _serviceInterceptor.GetSolutionInfoAsync(solution, cancellationToken);
return await invocation(service, solutionInfo, cancellationToken);
}

Expand Down

0 comments on commit d91189f

Please sign in to comment.