-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Allow Razor cohosting to run in VS Code, and fix it in VS #78167
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
Conversation
…service can be moved
| <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" /> |
There was a problem hiding this comment.
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; | ||
| } |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" /> |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems incorrect now
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
src/Tools/ExternalAccess/Razor/Features/Cohost/IRazorCohostDynamicRegistrationService.cs
Outdated
Show resolved
Hide resolved
…amicRegistrationService.cs Co-authored-by: Dustin Campbell <dustin@teamcampbell.org>
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.
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.