Skip to content

Commit

Permalink
Cohost diagnostics support (#10882)
Browse files Browse the repository at this point in the history
Fixes #10696
Fixes #10769
Fixes #10874
Needs Roslyn change: dotnet/roslyn#75102

The actual code change was quite straight foward. The test code was a
bigger pain. Previously in cohosting tests we had two MEF composition,
one for Razor and one for Roslyn. Since Roslyn diagnostics can only run,
or at least start, in devenv, we now need three MEF compositions -
Roslyn devenv, Roslyn OOP and razor OOP - and two workspaces - Roslyn
devenv and Roslyn OOP - and our previous MEF infrastructure really
didn't handle this well, as evidenced by the fact that this PR also
fixes #10874

Now our MEF infra is simpler: We still cache catalogs etc. statically
the save time, but we create an `ExportProvider` as needed and expect
consumers to dispose of it like any other `IDisposable`, though there is
also here a test fixture to share the editor composition in the
formatting tests so we don't pay a huge penalty in terms of test run
time.

Commit-at-a-time if you want to read the story from beginning to end,
but it should be reasonably okay to just review as a whole too.
  • Loading branch information
davidwengier authored Sep 18, 2024
2 parents 966d762 + fe5dc7b commit 4b3e409
Show file tree
Hide file tree
Showing 76 changed files with 881 additions and 711 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>08649fed58d668737a54913f7d4c649a8da5dc6e</Sha>
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Wpf" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Wpf" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.12.0-3.24454.5">
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.12.0-3.24466.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>9f86520c46f67d2a8a59af189f8fd87e35c574bb</Sha>
<Sha>7b7951aa13c50ad768538e58ed3805898b058928</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.24453.1</MicrosoftSourceBuildIntermediatearcadePackageVersion>
<MicrosoftDotNetXliffTasksPackageVersion>1.0.0-beta.23475.1</MicrosoftDotNetXliffTasksPackageVersion>
<MicrosoftSourceBuildIntermediatexlifftasksPackageVersion>1.0.0-beta.23475.1</MicrosoftSourceBuildIntermediatexlifftasksPackageVersion>
<MicrosoftNetCompilersToolsetPackageVersion>4.12.0-3.24454.5</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.12.0-3.24454.5</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.12.0-3.24454.5</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftSourceBuildIntermediateroslynPackageVersion>4.12.0-3.24454.5</MicrosoftSourceBuildIntermediateroslynPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.12.0-3.24454.5</MicrosoftVisualStudioLanguageServicesPackageVersion>
<MicrosoftNetCompilersToolsetPackageVersion>4.12.0-3.24466.4</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.12.0-3.24466.4</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.12.0-3.24466.4</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftSourceBuildIntermediateroslynPackageVersion>4.12.0-3.24466.4</MicrosoftSourceBuildIntermediateroslynPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.12.0-3.24466.4</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
1 change: 1 addition & 0 deletions eng/targets/Services.props
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
<ServiceHubService Include="Microsoft.VisualStudio.Razor.Formatting" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteFormattingService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.Razor.GoToImplementation" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteGoToImplementationService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.Razor.SpellCheck" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteSpellCheckService+Factory" />
<ServiceHubService Include="Microsoft.VisualStudio.Razor.Diagnostics" ClassName="Microsoft.CodeAnalysis.Remote.Razor.RemoteDiagnosticsService+Factory" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Microsoft.AspNetCore.Razor.LanguageServer.Diagnostics;
using Microsoft.AspNetCore.Razor.LanguageServer.EndpointContracts;
using Microsoft.AspNetCore.Razor.LanguageServer.Hosting;
using Microsoft.CodeAnalysis.Razor.Diagnostics;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
<Compile Include="..\..\test\Microsoft.AspNetCore.Razor.Test.Common.Tooling\Workspaces\TestWorkspaceServices.cs">
<Link>TestServices\%(FileName)%(Extension)</Link>
</Compile>
<Compile Include="..\..\test\Microsoft.AspNetCore.Razor.Test.Common.Tooling\Mef\ExportProviderExtensions.cs">
<Link>TestServices\%(FileName)%(Extension)</Link>
</Compile>

<None Remove=".gitignore" />
<None Remove="BenchmarkDotNet.Artifacts\**" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.AspNetCore.Razor.LanguageServer.Hosting;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.AspNetCore.Razor.Telemetry;
using Microsoft.CodeAnalysis.Razor.Diagnostics;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Razor.Protocol.Diagnostics;
Expand Down Expand Up @@ -72,7 +73,9 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(VSInternalDocumentDiagno
return null;
}

var razorDiagnostics = await GetRazorDiagnosticsAsync(documentContext, cancellationToken).ConfigureAwait(false);
var documentSnapshot = documentContext.Snapshot;

var razorDiagnostics = await GetRazorDiagnosticsAsync(documentSnapshot).ConfigureAwait(false);

var (csharpDiagnostics, htmlDiagnostics) = await GetHtmlCSharpDiagnosticsAsync(documentContext, correlationId, cancellationToken).ConfigureAwait(false);

Expand All @@ -96,7 +99,7 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(VSInternalDocumentDiagno
{
if (report.Diagnostics is not null)
{
var mappedDiagnostics = await _translateDiagnosticsService.TranslateAsync(RazorLanguageKind.CSharp, report.Diagnostics, documentContext, cancellationToken).ConfigureAwait(false);
var mappedDiagnostics = await _translateDiagnosticsService.TranslateAsync(RazorLanguageKind.CSharp, report.Diagnostics, documentSnapshot).ConfigureAwait(false);
report.Diagnostics = mappedDiagnostics;
}

Expand All @@ -110,7 +113,7 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(VSInternalDocumentDiagno
{
if (report.Diagnostics is not null)
{
var mappedDiagnostics = await _translateDiagnosticsService.TranslateAsync(RazorLanguageKind.Html, report.Diagnostics, documentContext, cancellationToken).ConfigureAwait(false);
var mappedDiagnostics = await _translateDiagnosticsService.TranslateAsync(RazorLanguageKind.Html, report.Diagnostics, documentSnapshot).ConfigureAwait(false);
report.Diagnostics = mappedDiagnostics;
}

Expand All @@ -121,10 +124,10 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(VSInternalDocumentDiagno
return allDiagnostics.ToArray();
}

private static async Task<VSInternalDiagnosticReport[]?> GetRazorDiagnosticsAsync(DocumentContext documentContext, CancellationToken cancellationToken)
private static async Task<VSInternalDiagnosticReport[]?> GetRazorDiagnosticsAsync(IDocumentSnapshot documentSnapshot)
{
var codeDocument = await documentContext.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
var sourceText = await documentContext.GetSourceTextAsync(cancellationToken).ConfigureAwait(false);
var codeDocument = await documentSnapshot.GetGeneratedOutputAsync().ConfigureAwait(false);
var sourceText = codeDocument.Source.Text;
var csharpDocument = codeDocument.GetCSharpDocument();
var diagnostics = csharpDocument.Diagnostics;

Expand All @@ -133,7 +136,7 @@ public TextDocumentIdentifier GetTextDocumentIdentifier(VSInternalDocumentDiagno
return null;
}

var convertedDiagnostics = RazorDiagnosticConverter.Convert(diagnostics, sourceText, documentContext.Snapshot);
var convertedDiagnostics = RazorDiagnosticConverter.Convert(diagnostics, sourceText, documentSnapshot);

return
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.AspNetCore.Razor.Utilities;
using Microsoft.CodeAnalysis.Razor;
using Microsoft.CodeAnalysis.Razor.Diagnostics;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
using Microsoft.CodeAnalysis.Razor.Protocol;
Expand Down Expand Up @@ -187,7 +188,7 @@ .. csharpDiagnostics ?? []
if (_documentContextFactory.Value.TryCreate(delegatedParams.TextDocument.Uri, projectContext: null, out var documentContext))
{
return await _translateDiagnosticsService.Value
.TranslateAsync(RazorLanguageKind.CSharp, fullDiagnostics.Items, documentContext, token)
.TranslateAsync(RazorLanguageKind.CSharp, fullDiagnostics.Items, documentContext.Snapshot)
.ConfigureAwait(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Microsoft.AspNetCore.Razor.LanguageServer.Tooltip;
using Microsoft.AspNetCore.Razor.ProjectEngineHost;
using Microsoft.CodeAnalysis.Razor.Completion;
using Microsoft.CodeAnalysis.Razor.Diagnostics;
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.Formatting;
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ protected override ILspServices ConstructLspServices()

services.AddLifeCycleServices(this, _clientConnection, _lspServerActivationTracker);

services.AddDiagnosticServices();
services.AddSemanticTokensServices(featureOptions);
services.AddDocumentManagementServices(featureOptions);
services.AddCompletionServices();
Expand All @@ -140,6 +139,9 @@ protected override ILspServices ConstructLspServices()

if (!featureOptions.UseRazorCohostServer)
{
// Diagnostics
services.AddDiagnosticServices();

// Auto insert
services.AddSingleton<IOnAutoInsertProvider, CloseTextTagOnAutoInsertProvider>();
services.AddSingleton<IOnAutoInsertProvider, AutoClosingTagOnAutoInsertProvider>();
Expand Down
Loading

0 comments on commit 4b3e409

Please sign in to comment.