Skip to content

Commit c68f6bf

Browse files
authored
Register UI context for cohost activation (#10287)
Register the UI context for Razor, so it can be used in Roslyn (see dotnet/roslyn#73172) Will eventual fix #10279 once the Roslyn side is in Part of #9519
2 parents b472006 + df3fe4b commit c68f6bf

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorConstants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ internal static class RazorConstants
1515

1616
public const string RazorLanguageServiceString = "4513FA64-5B72-4B58-9D4C-1D3C81996C2C";
1717

18+
public const string RazorCohostingUIContext = "6d5b86dc-6b8a-483b-ae30-098a3c7d6774";
19+
1820
public static readonly Guid RazorLanguageServiceGuid = new(RazorLanguageServiceString);
1921

2022
public const string VSProjectItemsIdentifier = "CF_VSSTGPROJECTITEMS";

src/Razor/src/Microsoft.VisualStudio.RazorExtension/RazorPackage.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ namespace Microsoft.VisualStudio.RazorExtension;
3535
[ProvideToolWindow(typeof(SyntaxVisualizerToolWindow))]
3636
[ProvideLanguageEditorOptionPage(typeof(AdvancedOptionPage), RazorConstants.RazorLSPContentTypeName, category: null, "Advanced", pageNameResourceId: "#1050", keywordListResourceId: 1060)]
3737
[Guid(PackageGuidString)]
38+
// We activate cohosting when the first Razor file is opened. This matches the previous behavior where the
39+
// LSP client MEF export had the Razor content type metadata.
40+
[ProvideUIContextRule(
41+
contextGuid: RazorConstants.RazorCohostingUIContext,
42+
name: "Razor Cohosting Activation",
43+
expression: "RazorContentType",
44+
termNames: ["RazorContentType"],
45+
termValues: [$"ActiveEditorContentType:{RazorConstants.RazorLSPContentTypeName}"])]
3846
internal sealed class RazorPackage : AsyncPackage
3947
{
4048
public const string PackageGuidString = "13b72f58-279e-49e0-a56d-296be02f0805";

0 commit comments

Comments
 (0)