Skip to content

Conversation

@davidwengier
Copy link
Member

@davidwengier davidwengier commented Apr 16, 2025

Goes with dotnet/vscode-csharp#8189 and dotnet/razor#11748 to allow Razor cohosting in VS Code, but also fixes some VSIX issues that broke cohosting in VS too. Reviewing commit-at-a-time is probably recommended.

@davidwengier davidwengier requested a review from a team April 16, 2025 03:49
@davidwengier davidwengier requested review from a team as code owners April 16, 2025 03:49
@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 16, 2025
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Microsoft.CodeAnalysis.ExternalAccess.AspNetCore.dll" />
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Microsoft.CodeAnalysis.ExternalAccess.Razor.dll" />
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Microsoft.CodeAnalysis.ExternalAccess.Razor.Features.dll" />
<Asset Type="Microsoft.VisualStudio.MefComponent" Path="Microsoft.CodeAnalysis.ExternalAccess.Razor.EditorFeatures.dll" />
Copy link
Member Author

Choose a reason for hiding this comment

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

Wouldn't it be fun if this is even harder to get an exception for because it causes a 2 DLL load regression, instead of just the 1, because we accidentally improved DLL loads by trying to load a DLL that didn't exist?

if (Directory.Exists(serviceHubCoreDirectory))
{
directory = serviceHubCoreDirectory;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@chsienki this is a bit of a speculative change on my part, because it either doesn't matter whether its there, or I just always won the race, but it makes sense to me. In VS Code there is no ServiceHubCore folder. Does that make sense?

Also, doesn't matter if this isn't perfect for this PR, there will be more to come :)

Copy link
Member

Choose a reason for hiding this comment

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

Yep, I'm fine with this. A secondary question to which I suspect I know the answer: do we have integration tests in Razor for VSCode? I would have expected this to break them if we do.

Copy link
Member Author

Choose a reason for hiding this comment

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

We do, in the VS Code repo, though none with cohosting turned on (yet?).

I'm thinking of reverting this change though, as it was a bit speculative when I was having all sorts of source generator loading issues, so I was doing a bit of whack-a-mole to try to fix them.

Copy link
Member

Choose a reason for hiding this comment

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

If there is no ServiceHubCore folder in VS, then I think this is fixing a legitimate issue. If we're redirect to a non-existent assembly, the later logic will fail, and we'll ultimately fall back to loading from the SDK, meaning our redirection is broken.

<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.AspNetCore" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.CSharp" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.OmniSharp.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Razor" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you 🙏 I thought I grep'ed through to see if there were more

internal static string GenerateFullNameForOption(IOption2 option)
{
var optionGroupName = GenerateOptionGroupName(option);
// All options send to the client should have group name and config name.
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems incorrect now

Copy link
Member Author

Choose a reason for hiding this comment

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

You were right, but this all got reverted so it's back to being correct :)


if (cohostStartupService is not null)
{
await cohostStartupService.Value.StartupAsync(serializedClientCapabilities, requestContext, cancellationToken).ConfigureAwait(false);
Copy link
Member

Choose a reason for hiding this comment

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

consider trace logging on which service actually gets used, in case we need to debug something

Copy link
Member Author

Choose a reason for hiding this comment

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

The two services are just dual-insertion prevention. I'm going to remove the old one as soon as dotnet/razor#11748 merges.

…amicRegistrationService.cs

Co-authored-by: Dustin Campbell <dustin@teamcampbell.org>
@davidwengier davidwengier enabled auto-merge April 22, 2025 21:00
@davidwengier davidwengier merged commit dd027d8 into dotnet:main Apr 22, 2025
24 of 25 checks passed
@davidwengier davidwengier deleted the CohostVSCode branch April 22, 2025 22:24
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 22, 2025
davidwengier added a commit to dotnet/razor that referenced this pull request Apr 24, 2025
Goes with dotnet/roslyn#78167 and
dotnet/vscode-csharp#8189 to expose cohosting to
VS Code.

Needs dotnet/roslyn#78167 merged and referenced
before it will build.
@RikkiGibson RikkiGibson modified the milestones: Next, 18.0 P1 Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants