Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/global.json @dotnet/razor-tooling @dotnet/razor-compiler
/azure-pipelines.yml @dotnet/razor-tooling @dotnet/razor-compiler
/eng/ @dotnet/razor-tooling @dotnet/razor-compiler
/eng/targets/Services.props @dotnet/razor-tooling
/eng/common/ @dotnet/razor-tooling @dotnet/razor-compiler
/eng/Versions.props @dotnet/razor-tooling @dotnet/razor-compiler
/eng/Version.Details.xml @dotnet/razor-tooling @dotnet/razor-compiler
Expand Down
72 changes: 36 additions & 36 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,82 +11,82 @@
<Sha>9c1cc994f8123ec2a923c5179c238c13da1b4ab7</Sha>
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CommonLanguageServerProtocol.Framework" Version="4.11.0-1.24214.4">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.ExternalAccess.Razor" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.Common" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.CSharp" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.EditorFeatures" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Features" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Common" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Text" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Wpf" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.EditorFeatures.Wpf" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.11.0-1.24214.4">
<Dependency Name="Microsoft.SourceBuild.Intermediate.roslyn" Version="4.11.0-2.24259.2">
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>84c5476ef3111c9abd78d43e65063280bb7202d9</Sha>
<Sha>c23414e1365f21c6bd34ab5b007546066f25b5d4</Sha>
<SourceBuild RepoName="roslyn" ManagedOnly="true" />
</Dependency>
</ProductDependencies>
Expand Down
36 changes: 18 additions & 18 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,25 @@
<MicrosoftSourceBuildIntermediatearcadePackageVersion>8.0.0-beta.24204.3</MicrosoftSourceBuildIntermediatearcadePackageVersion>
<MicrosoftDotNetXliffTasksPackageVersion>1.0.0-beta.23475.1</MicrosoftDotNetXliffTasksPackageVersion>
<MicrosoftSourceBuildIntermediatexlifftasksPackageVersion>1.0.0-beta.23475.1</MicrosoftSourceBuildIntermediatexlifftasksPackageVersion>
<MicrosoftNetCompilersToolsetPackageVersion>4.11.0-1.24214.4</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftNetCompilersToolsetPackageVersion>4.11.0-2.24259.2</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.11.0-1.24214.4</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.11.0-1.24214.4</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftSourceBuildIntermediateroslynPackageVersion>4.11.0-1.24214.4</MicrosoftSourceBuildIntermediateroslynPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.11.0-1.24214.4</MicrosoftVisualStudioLanguageServicesPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisCommonPackageVersion>
<MicrosoftCodeAnalysisCSharpPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisCSharpPackageVersion>
<MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisCSharpEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisCSharpFeaturesPackageVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisEditorFeaturesPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisEditorFeaturesCommonPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.11.0-2.24259.2</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftSourceBuildIntermediateroslynPackageVersion>4.11.0-2.24259.2</MicrosoftSourceBuildIntermediateroslynPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.11.0-2.24259.2</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 @@ -51,7 +51,13 @@ protected override IRazorPresentationParams CreateRazorRequestParameters(UriPres

protected override async Task<WorkspaceEdit?> TryGetRazorWorkspaceEditAsync(RazorLanguageKind languageKind, UriPresentationParams request, CancellationToken cancellationToken)
{
var razorFileUri = UriPresentationHelper.GetComponentFileNameFromUriPresentationRequest(languageKind, request.Uris, Logger);
if (languageKind is not RazorLanguageKind.Html)
{
// Component tags can only be inserted into Html contexts, so if this isn't Html there is nothing we can do.
return null;
}

var razorFileUri = UriPresentationHelper.GetComponentFileNameFromUriPresentationRequest(request.Uris, Logger);
if (razorFileUri == null)
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,13 @@
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Protocol;

namespace Microsoft.CodeAnalysis.Razor.DocumentPresentation;

internal static class UriPresentationHelper
{
public static Uri? GetComponentFileNameFromUriPresentationRequest(RazorLanguageKind languageKind, Uri[]? uris, ILogger logger)
public static Uri? GetComponentFileNameFromUriPresentationRequest(Uri[]? uris, ILogger logger)
Copy link
Contributor

@maryamariyan maryamariyan May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Observation: (nit since it is an internal API anyway, but) This API no longer takes language kind and seems like it is now HTML-specific. Your comments are at the caller level where you've moved this logic out to, but at the API level here, it is not obvious for someone looking at it later to know this is actually now HTML-specific (class or API or implementation doesn't make it obvious).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it's quite the opposite. Except for the block of code I moved, the method has nothing to do with a specific language at all, its only job is to reason about the set of Uris passed in. What any caller chooses to do with the result is up to the caller. Thats why the language check was out of place.

{
if (languageKind is not RazorLanguageKind.Html)
{
// Component tags can only be inserted into Html contexts, so if this isn't Html there is nothing we can do.
return null;
}

if (uris is null || uris.Length == 0)
{
logger.LogDebug($"No URIs were included in the request?");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ internal sealed class RemoteHtmlDocumentService(
{
public ValueTask<string?> GetHtmlDocumentTextAsync(RazorPinnedSolutionInfoWrapper solutionInfo, DocumentId razorDocumentId, CancellationToken cancellationToken)
=> RazorBrokeredServiceImplementation.RunServiceAsync(
solutionInfo,
ServiceBrokerClient,
solution => GetHtmlDocumentTextAsync(solution, razorDocumentId, cancellationToken),
cancellationToken);
solutionInfo,
ServiceBrokerClient,
solution => GetHtmlDocumentTextAsync(solution, razorDocumentId, cancellationToken),
cancellationToken);

private async ValueTask<string?> GetHtmlDocumentTextAsync(Solution solution, DocumentId razorDocumentId, CancellationToken _)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.CodeAnalysis.Razor.DocumentMapping;
using Microsoft.CodeAnalysis.Razor.DocumentPresentation;
using Microsoft.CodeAnalysis.Razor.Logging;
using Microsoft.CodeAnalysis.Razor.Protocol;
using Microsoft.CodeAnalysis.Razor.Remote;
using Microsoft.CodeAnalysis.Razor.Workspaces;
using Microsoft.CodeAnalysis.Remote.Razor.ProjectSystem;
Expand Down Expand Up @@ -54,13 +55,24 @@ internal sealed class RemoteUriPresentationService(

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

var razorFileUri = UriPresentationHelper.GetComponentFileNameFromUriPresentationRequest(languageKind, uris, _logger);
if (languageKind is not RazorLanguageKind.Html)
{
// Roslyn doesn't currently support Uri presentation, and whilst it might seem counter intuitive,
// our support for Uri presentation is to insert a Html tag, so we only support Html

// If Roslyn add support in future then this is where it would go.
return null;
}

var razorFileUri = UriPresentationHelper.GetComponentFileNameFromUriPresentationRequest(uris, _logger);
if (razorFileUri is null)
{
return null;
}

var ids = razorDocument.Project.Solution.GetDocumentIdsWithFilePath(GetDocumentFilePathFromUri(razorFileUri));
// 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
var uriToFind = RazorUri.GetDocumentFilePathFromUri(razorFileUri);
var ids = razorDocument.Project.Solution.GetDocumentIdsWithFilePath(uriToFind);
if (ids.Length == 0)
{
return null;
Expand Down Expand Up @@ -89,8 +101,4 @@ internal sealed class RemoteUriPresentationService(

return new TextChange(span.ToTextSpan(sourceText), tag);
}

// TODO: Call the real Roslyn API once https://github.com/dotnet/roslyn/pull/73289 is merged
public static string GetDocumentFilePathFromUri(Uri uri)
=> uri.IsFile ? uri.LocalPath : uri.AbsoluteUri;
}
Loading