Skip to content

Commit 5ec07b3

Browse files
authored
Uri Presentation Part 2, aka Cohost Html on-demand generation (#10359)
Part of #9519 Commit at a time might be easier. Not really sure. This PR finished off Uri Presentation in cohosting, but more importantly it brings html document generation to cohosting. The generation is done completely on-demand as we get a request for a document, and in general is much simpler than the current system, because whilst we still need to push the document to a VS buffer, we don't have to wait for the document to be pushed to VS from the LSP server, and synchronize those two pushes. This isn't doing any buffer management specifically for cohosting yet, but all of that is still needed for C# anyway, at the moment.
2 parents 92c46cf + d81c2ce commit 5ec07b3

File tree

18 files changed

+827
-75
lines changed

18 files changed

+827
-75
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/global.json @dotnet/razor-tooling @dotnet/razor-compiler
55
/azure-pipelines.yml @dotnet/razor-tooling @dotnet/razor-compiler
66
/eng/ @dotnet/razor-tooling @dotnet/razor-compiler
7+
/eng/targets/Services.props @dotnet/razor-tooling
78
/eng/common/ @dotnet/razor-tooling @dotnet/razor-compiler
89
/eng/Versions.props @dotnet/razor-tooling @dotnet/razor-compiler
910
/eng/Version.Details.xml @dotnet/razor-tooling @dotnet/razor-compiler

eng/Version.Details.xml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,82 +11,82 @@
1111
<Sha>a4c02499bef24d0e16255657ccdb160d26c82c32</Sha>
1212
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
1313
</Dependency>
14-
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.11.0-1.24214.4">
14+
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.11.0-2.24260.2">
1515
<Uri>https://github.com/dotnet/roslyn</Uri>
16-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
16+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
1717
</Dependency>
1818
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="4.11.0-1.24214.4">
1919
<Uri>https://github.com/dotnet/roslyn</Uri>
2020
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
2121
</Dependency>
22-
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor" Version="4.11.0-1.24214.4">
22+
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor" Version="4.11.0-2.24260.2">
2323
<Uri>https://github.com/dotnet/roslyn</Uri>
24-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
24+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
2525
</Dependency>
26-
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="4.11.0-1.24214.4">
26+
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="4.11.0-2.24260.2">
2727
<Uri>https://github.com/dotnet/roslyn</Uri>
28-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
28+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
2929
</Dependency>
30-
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.11.0-1.24214.4">
30+
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.11.0-2.24260.2">
3131
<Uri>https://github.com/dotnet/roslyn</Uri>
32-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
32+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
3333
</Dependency>
34-
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="4.11.0-1.24214.4">
34+
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="4.11.0-2.24260.2">
3535
<Uri>https://github.com/dotnet/roslyn</Uri>
36-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
36+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
3737
</Dependency>
38-
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.11.0-1.24214.4">
38+
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.11.0-2.24260.2">
3939
<Uri>https://github.com/dotnet/roslyn</Uri>
40-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
40+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
4141
</Dependency>
42-
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0-1.24214.4">
42+
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0-2.24260.2">
4343
<Uri>https://github.com/dotnet/roslyn</Uri>
44-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
44+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
4545
</Dependency>
46-
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="4.11.0-1.24214.4">
46+
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="4.11.0-2.24260.2">
4747
<Uri>https://github.com/dotnet/roslyn</Uri>
48-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
48+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
4949
</Dependency>
50-
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="4.11.0-1.24214.4">
50+
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="4.11.0-2.24260.2">
5151
<Uri>https://github.com/dotnet/roslyn</Uri>
52-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
52+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
5353
</Dependency>
54-
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="4.11.0-1.24214.4">
54+
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="4.11.0-2.24260.2">
5555
<Uri>https://github.com/dotnet/roslyn</Uri>
56-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
56+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
5757
</Dependency>
58-
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Wpf" Version="4.11.0-1.24214.4">
58+
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Wpf" Version="4.11.0-2.24260.2">
5959
<Uri>https://github.com/dotnet/roslyn</Uri>
60-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
60+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
6161
</Dependency>
62-
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="4.11.0-1.24214.4">
62+
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="4.11.0-2.24260.2">
6363
<Uri>https://github.com/dotnet/roslyn</Uri>
64-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
64+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
6565
</Dependency>
66-
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.11.0-1.24214.4">
66+
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.11.0-2.24260.2">
6767
<Uri>https://github.com/dotnet/roslyn</Uri>
68-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
68+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
6969
</Dependency>
70-
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.11.0-1.24214.4">
70+
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.11.0-2.24260.2">
7171
<Uri>https://github.com/dotnet/roslyn</Uri>
72-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
72+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
7373
</Dependency>
74-
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.11.0-1.24214.4">
74+
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.11.0-2.24260.2">
7575
<Uri>https://github.com/dotnet/roslyn</Uri>
76-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
76+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
7777
</Dependency>
78-
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.11.0-1.24214.4">
78+
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.11.0-2.24260.2">
7979
<Uri>https://github.com/dotnet/roslyn</Uri>
80-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
80+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
8181
</Dependency>
82-
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.11.0-1.24214.4">
82+
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.11.0-2.24260.2">
8383
<Uri>https://github.com/dotnet/roslyn</Uri>
84-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
84+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
8585
</Dependency>
8686
<!-- Intermediate is necessary for source build. -->
87-
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.11.0-1.24214.4">
87+
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.11.0-2.24260.2">
8888
<Uri>https://github.com/dotnet/roslyn</Uri>
89-
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
89+
<Sha>324e078a9b47b62cd6dec6c78c6308c4540aa1e5</Sha>
9090
<SourceBuild RepoName="roslyn" ManagedOnly="true" />
9191
</Dependency>
9292
</ProductDependencies>

eng/Versions.props

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,25 @@
5353
<MicrosoftSourceBuildIntermediatearcadePackageVersion>8.0.0-beta.24225.1</MicrosoftSourceBuildIntermediatearcadePackageVersion>
5454
<MicrosoftDotNetXliffTasksPackageVersion>1.0.0-beta.23475.1</MicrosoftDotNetXliffTasksPackageVersion>
5555
<MicrosoftSourceBuildIntermediatexlifftasksPackageVersion>1.0.0-beta.23475.1</MicrosoftSourceBuildIntermediatexlifftasksPackageVersion>
56-
<MicrosoftNetCompilersToolsetPackageVersion>4.11.0-1.24214.4</MicrosoftNetCompilersToolsetPackageVersion>
56+
<MicrosoftNetCompilersToolsetPackageVersion>4.11.0-2.24260.2</MicrosoftNetCompilersToolsetPackageVersion>
5757
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.11.0-1.24214.4</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
58-
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
59-
<MicrosoftCodeAnalysisCommonPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisCommonPackageVersion>
60-
<MicrosoftCodeAnalysisCSharpPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisCSharpPackageVersion>
61-
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
62-
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
63-
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
64-
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
65-
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
66-
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
67-
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
68-
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
69-
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
70-
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
71-
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
72-
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
73-
<MicrosoftSourceBuildIntermediateroslynPackageVersion>4.11.0-1.24214.4</MicrosoftSourceBuildIntermediateroslynPackageVersion>
74-
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.11.0-1.24214.4</MicrosoftVisualStudioLanguageServicesPackageVersion>
58+
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
59+
<MicrosoftCodeAnalysisCommonPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisCommonPackageVersion>
60+
<MicrosoftCodeAnalysisCSharpPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisCSharpPackageVersion>
61+
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
62+
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
63+
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
64+
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
65+
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
66+
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
67+
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
68+
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
69+
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
70+
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
71+
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
72+
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.11.0-2.24260.2</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
73+
<MicrosoftSourceBuildIntermediateroslynPackageVersion>4.11.0-2.24260.2</MicrosoftSourceBuildIntermediateroslynPackageVersion>
74+
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.11.0-2.24260.2</MicrosoftVisualStudioLanguageServicesPackageVersion>
7575
<!--
7676
Exception - Microsoft.Extensions.ObjectPool and System.Collections.Immutable packages are not updated by automation,
7777
but are present in Version.Details.xml for source-build PVP flow. See the comment in Version.Details.xml for more information.

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/DocumentPresentation/TextDocumentUriPresentationEndpoint.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ protected override IRazorPresentationParams CreateRazorRequestParameters(UriPres
5151

5252
protected override async Task<WorkspaceEdit?> TryGetRazorWorkspaceEditAsync(RazorLanguageKind languageKind, UriPresentationParams request, CancellationToken cancellationToken)
5353
{
54-
var razorFileUri = UriPresentationHelper.GetComponentFileNameFromUriPresentationRequest(languageKind, request.Uris, Logger);
54+
if (languageKind is not RazorLanguageKind.Html)
55+
{
56+
// Component tags can only be inserted into Html contexts, so if this isn't Html there is nothing we can do.
57+
return null;
58+
}
59+
60+
var razorFileUri = UriPresentationHelper.GetComponentFileNameFromUriPresentationRequest(request.Uris, Logger);
5561
if (razorFileUri == null)
5662
{
5763
return null;

src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentPresentation/UriPresentationHelper.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,13 @@
55
using System.IO;
66
using System.Linq;
77
using Microsoft.CodeAnalysis.Razor.Logging;
8-
using Microsoft.CodeAnalysis.Razor.Protocol;
98

109
namespace Microsoft.CodeAnalysis.Razor.DocumentPresentation;
1110

1211
internal static class UriPresentationHelper
1312
{
14-
public static Uri? GetComponentFileNameFromUriPresentationRequest(RazorLanguageKind languageKind, Uri[]? uris, ILogger logger)
13+
public static Uri? GetComponentFileNameFromUriPresentationRequest(Uri[]? uris, ILogger logger)
1514
{
16-
if (languageKind is not RazorLanguageKind.Html)
17-
{
18-
// Component tags can only be inserted into Html contexts, so if this isn't Html there is nothing we can do.
19-
return null;
20-
}
21-
2215
if (uris is null || uris.Length == 0)
2316
{
2417
logger.LogDebug($"No URIs were included in the request?");

src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/HtmlDocuments/RemoteHtmlDocumentService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ internal sealed class RemoteHtmlDocumentService(
1919
{
2020
public ValueTask<string?> GetHtmlDocumentTextAsync(RazorPinnedSolutionInfoWrapper solutionInfo, DocumentId razorDocumentId, CancellationToken cancellationToken)
2121
=> RazorBrokeredServiceImplementation.RunServiceAsync(
22-
solutionInfo,
23-
ServiceBrokerClient,
24-
solution => GetHtmlDocumentTextAsync(solution, razorDocumentId, cancellationToken),
25-
cancellationToken);
22+
solutionInfo,
23+
ServiceBrokerClient,
24+
solution => GetHtmlDocumentTextAsync(solution, razorDocumentId, cancellationToken),
25+
cancellationToken);
2626

2727
private async ValueTask<string?> GetHtmlDocumentTextAsync(Solution solution, DocumentId razorDocumentId, CancellationToken _)
2828
{

src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/UriPresentation/RemoteUriPresentationService.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
1111
using Microsoft.CodeAnalysis.Razor.DocumentPresentation;
1212
using Microsoft.CodeAnalysis.Razor.Logging;
13+
using Microsoft.CodeAnalysis.Razor.Protocol;
1314
using Microsoft.CodeAnalysis.Razor.Remote;
1415
using Microsoft.CodeAnalysis.Razor.Workspaces;
1516
using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem;
@@ -54,13 +55,24 @@ internal sealed class RemoteUriPresentationService(
5455

5556
var languageKind = _documentMappingService.GetLanguageKind(codeDocument, index, rightAssociative: true);
5657

57-
var razorFileUri = UriPresentationHelper.GetComponentFileNameFromUriPresentationRequest(languageKind, uris, _logger);
58+
if (languageKind is not RazorLanguageKind.Html)
59+
{
60+
// Roslyn doesn't currently support Uri presentation, and whilst it might seem counter intuitive,
61+
// our support for Uri presentation is to insert a Html tag, so we only support Html
62+
63+
// If Roslyn add support in future then this is where it would go.
64+
return null;
65+
}
66+
67+
var razorFileUri = UriPresentationHelper.GetComponentFileNameFromUriPresentationRequest(uris, _logger);
5868
if (razorFileUri is null)
5969
{
6070
return null;
6171
}
6272

63-
var ids = razorDocument.Project.Solution.GetDocumentIdsWithFilePath(GetDocumentFilePathFromUri(razorFileUri));
73+
// Make sure we go through Roslyn to go from the Uri the client sent us, to one that it has a chance of finding in the solution
74+
var uriToFind = RazorUri.GetDocumentFilePathFromUri(razorFileUri);
75+
var ids = razorDocument.Project.Solution.GetDocumentIdsWithFilePath(uriToFind);
6476
if (ids.Length == 0)
6577
{
6678
return null;
@@ -89,8 +101,4 @@ internal sealed class RemoteUriPresentationService(
89101

90102
return new TextChange(span.ToTextSpan(sourceText), tag);
91103
}
92-
93-
// TODO: Call the real Roslyn API once https://github.com/dotnet/roslyn/pull/73289 is merged
94-
public static string GetDocumentFilePathFromUri(Uri uri)
95-
=> uri.IsFile ? uri.LocalPath : uri.AbsoluteUri;
96104
}

0 commit comments

Comments
 (0)