This commit is contained in:
David Wengier 2024-09-18 07:54:30 +10:00
Родитель c349de7362
Коммит a7d127c021
2 изменённых файлов: 14 добавлений и 17 удалений

Просмотреть файл

@ -5,7 +5,6 @@ using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
using Microsoft.CodeAnalysis.Razor.Diagnostics;
using Microsoft.CodeAnalysis.Razor.Protocol;
@ -48,12 +47,10 @@ internal sealed class RemoteDiagnosticsService(in ServiceArgs args) : RazorDocum
// Yes, CSharpDocument.Documents are the Razor diagnostics. Don't ask.
var razorDiagnostics = codeDocument.GetCSharpDocument().Diagnostics;
using var allDiagnostics = new PooledArrayBuilder<LspDiagnostic>(capacity: razorDiagnostics.Length + csharpDiagnostics.Length + htmlDiagnostics.Length);
allDiagnostics.AddRange(RazorDiagnosticConverter.Convert(razorDiagnostics, codeDocument.Source.Text, context.Snapshot));
allDiagnostics.AddRange(await _translateDiagnosticsService.TranslateAsync(RazorLanguageKind.CSharp, csharpDiagnostics, context.Snapshot));
allDiagnostics.AddRange(await _translateDiagnosticsService.TranslateAsync(RazorLanguageKind.Html, htmlDiagnostics, context.Snapshot));
return allDiagnostics.DrainToImmutable();
return [
.. RazorDiagnosticConverter.Convert(razorDiagnostics, codeDocument.Source.Text, context.Snapshot),
.. await _translateDiagnosticsService.TranslateAsync(RazorLanguageKind.CSharp, csharpDiagnostics, context.Snapshot),
.. await _translateDiagnosticsService.TranslateAsync(RazorLanguageKind.Html, htmlDiagnostics, context.Snapshot)
];
}
}

Просмотреть файл

@ -136,15 +136,15 @@ public abstract class CohostEndpointTestBase(ITestOutputHelper testOutputHelper)
private static TextDocument CreateProjectAndRazorDocument(CodeAnalysis.Workspace workspace, ProjectId projectId, string projectName, DocumentId documentId, string documentFilePath, string contents, (string fileName, string contents)[]? additionalFiles)
{
var projectInfo = ProjectInfo
.Create(
projectId,
VersionStamp.Create(),
name: projectName,
assemblyName: projectName,
LanguageNames.CSharp,
documentFilePath)
.WithDefaultNamespace(TestProjectData.SomeProject.RootNamespace)
.WithMetadataReferences(AspNet80.ReferenceInfos.All.Select(r => r.Reference));
.Create(
projectId,
VersionStamp.Create(),
name: projectName,
assemblyName: projectName,
LanguageNames.CSharp,
documentFilePath)
.WithDefaultNamespace(TestProjectData.SomeProject.RootNamespace)
.WithMetadataReferences(AspNet80.ReferenceInfos.All.Select(r => r.Reference));
var solution = workspace.CurrentSolution.AddProject(projectInfo);