Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Razor EA For Roslyn #11510

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Conversation

ryzngard
Copy link
Contributor

@ryzngard ryzngard commented Feb 19, 2025

Razor side of dotnet/roslyn#77194

  • Remove Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace, we no longer ship an EA for Roslyn
  • Add a new Microsoft.VisualStudioCode.RazorExtension and package that will be put in .razorExtension in VS Code
    • This will contain endpoints and LSP services that will be loaded in the roslyn language server for VS Code.
  • Remove Microsoft.AspNetCore.Razor.ProjectEngineHost as that layer of separation is no longer needed

Copilot description below

This pull request includes several changes to the Razor project, focusing on project restructuring and dependency updates. The most important changes include adding a new package version, renaming and removing projects, and updating the RazorWorkspaceListenerBase class.

Project restructuring:

  • Razor.sln: Renamed Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace to Microsoft.VisualStudioCode.RazorExtension and removed Microsoft.AspNetCore.Razor.ProjectEngineHost and its test project. [1] [2] [3]
  • docs/ProjectsAndLayering.md: Updated documentation to reflect the new project name.

Code updates:

Project removals:

  • Removed Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace project and its related files. [1] [2] [3]

@davidwengier
Copy link
Member

Do you want reviews? I'll admit, the first thing I saw in here was code that used to be in ExternalAccess.RoslynWorkspace, which used to be VS Code exclusive, moved to MS.VS.RazorExtension which used to be VS exclusive, and I got very confused by what the intent was.

Then I re-read it! :)

@ryzngard
Copy link
Contributor Author

Do you want reviews? I'll admit, the first thing I saw in here was code that used to be in ExternalAccess.RoslynWorkspace, which used to be VS Code exclusive, moved to MS.VS.RazorExtension which used to be VS exclusive, and I got very confused by what the intent was.

Then I re-read it! :)

I don't think it's ready for reviews yet

@DustinCampbell
Copy link
Member

I don't think it's ready for reviews yet

Feel free to ping in Teams when you're ready.

@ryzngard ryzngard marked this pull request as ready for review March 21, 2025 00:11
@ryzngard ryzngard requested review from a team as code owners March 21, 2025 00:11
<MicrosoftNetCompilersToolsetPackageVersion>4.14.0-dev</MicrosoftNetCompilersToolsetPackageVersion>
<MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>4.14.0-dev</MicrosoftCommonLanguageServerProtocolFrameworkPackageVersion>
<MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>4.14.0-dev</MicrosoftCodeAnalysisExternalAccessRazorPackageVersion>
<MicrosoftCodeAnalysisCommonPackageVersion>4.14.0-dev</MicrosoftCodeAnalysisCommonPackageVersion>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These will need to be updated once the package is available.

Copy link
Member

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

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

Mostly LGTM. I skipped the one file with the merge conflict markers though 😛

@@ -106,11 +106,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Compiler Tests", "Compiler
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Microbenchmarks.Generator", "src\Compiler\perf\Microsoft.AspNetCore.Razor.Microbenchmarks.Generator\Microsoft.AspNetCore.Razor.Microbenchmarks.Generator.csproj", "{7400A168-2552-49C7-93E3-D4DAA90C216F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace", "src\Razor\src\Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace\Microsoft.AspNetCore.Razor.ExternalAccess.RoslynWorkspace.csproj", "{2223B8FD-D98A-47BE-94A9-6A3A6B8557B8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudioCode.RazorExtension", "src\Razor\src\Microsoft.VisualStudioCode.RazorExtension\Microsoft.VisualStudioCode.RazorExtension.csproj", "{2223B8FD-D98A-47BE-94A9-6A3A6B8557B8}"
Copy link
Member

Choose a reason for hiding this comment

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

I don't know of a better name, and I don't think it matters, but I would like to state for the record that Microsoft.VisualStudio.RazorExtension is a visual studio extension and Microsoft.VisualStudioCode.RazorExtension is not a visual studio code extension 😛

{
<<<<<<< HEAD
Copy link
Member

Choose a reason for hiding this comment

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

Oops

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦


namespace Microsoft.VisualStudioCode.RazorExtension.Endpoints;

internal class RazorFileChangedResponse
Copy link
Member

Choose a reason for hiding this comment

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

Used?

internal sealed class RazorDynamicFileUpdate
{
[JsonPropertyName("edits")]
public required ServerTextChange[] Edits { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

We have RazorTextChange which looks the same as ServerTextChange. Also, why not put this array directly in RazorProvideDynamicFileResponse? Looks like there is even a debug assert to ensure there is only ever one RazorDynamicFileUpdate anyway


file sealed class LspDynamicFileProvider(IRazorClientLanguageServerManager clientLanguageServerManager) : RazorLspDynamicFileInfoProvider
{
private const string ProvideRazorDynamicFileInfoMethodName = "razor/provideDynamicFileInfo";
Copy link
Member

Choose a reason for hiding this comment

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

Looks like there are two files in this project that define this. Centralize?


[ExportRazorStatelessLspService(typeof(RazorWorkspaceService)), Shared]
[method: ImportingConstructor]
file class WorkspaceService(ILoggerFactory loggerFactory) : RazorWorkspaceService
Copy link
Member

Choose a reason for hiding this comment

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

File name doesn't match class name. Also not sure why this is a file class. I guess it doens't hurt, but seems odd.

file class WorkspaceService(ILoggerFactory loggerFactory) : RazorWorkspaceService
{
private readonly ILoggerFactory _loggerFactory = loggerFactory;
private readonly ILogger _logger = loggerFactory.CreateLogger<RazorWorkspaceService>();
Copy link
Member

Choose a reason for hiding this comment

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

This should probably create a logged for WorkspaceService, though being a file class, that type name probably looks ugly.


projectsToInitialize = _projectIdWithDynamicFiles;
// May as well clear out the collection, it will never get used again anyway.
_projectIdWithDynamicFiles = [];
Copy link
Member

Choose a reason for hiding this comment

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

I think you copied this code from the C# extension, where I was the one who wrote it, but I must ask Past Dave™, why not just call .Clear()? Could make the hashset readonly. Or set the hashset to null?

{
private readonly ILoggerFactory _loggerFactory = loggerFactory;
private readonly ILogger _logger = loggerFactory.CreateLogger<RazorWorkspaceService>();
private Lock _initializeLock = new();
Copy link
Member

Choose a reason for hiding this comment

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

Readonly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants