Skip to content

Conversation

davidwengier
Copy link
Member

@davidwengier davidwengier commented Aug 12, 2025

Putting this up as draft for now, gonna see if I can do a dual test insertion to confirm this makes RPS happy. The UI context is defined in dotnet/razor#12079 so its a little bit painful to validate everything together :)

This PR does two things:

  1. Makes the lifetime service Lazy, which it should have always been but I forgot. Not being lazy means Razor can't move to it, as just MEF construction causes RPS regressions. Oops!
  2. Adds a ui context to control pre-initialization. This allows Razor to control whether that occurs, when, and whether it actually does anything.

Until Razor is in this won't do anything, but runs in the dual test insertion (https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/664449) look good so far.

@davidwengier davidwengier force-pushed the RazorCapabilityUIContext branch from 540014c to e260767 Compare August 25, 2025 03:16
@davidwengier davidwengier marked this pull request as ready for review August 26, 2025 01:37
@davidwengier davidwengier requested a review from a team as a code owner August 26, 2025 01:37
@@ -11,6 +11,8 @@ internal static class Constants
{
public const string RazorLanguageName = LanguageInfoProvider.RazorLanguageName;

// The UI context is provided by Razor, so this guid must match the one in https://github.com/dotnet/razor/blob/main/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorConstants.cs
// These UI contexts are provided by Razor, so must match https://github.com/dotnet/razor/blob/main/src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorConstants.cs
Copy link
Member

Choose a reason for hiding this comment

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

Should Razor simply use these values from the EA?

Copy link
Member Author

Choose a reason for hiding this comment

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

I already think it's a bit weird that a UI context defined in Razor is only used in Roslyn. Making it so that a UI context defined in Razor, and used in Roslyn, has a Guid defined in Roslyn, is not really any weirder, though it would mean our RazorPackage would need IVT to the EA. I don't know at what point any of this feels too weird to be worth doing.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah maybe not worth the trouble then. Is there a unit test in razor to ensure these are in sync?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, but thats a great idea! Will add that to the Razor side of things

@davidwengier davidwengier merged commit bddbba5 into dotnet:main Aug 26, 2025
25 checks passed
@davidwengier davidwengier deleted the RazorCapabilityUIContext branch August 26, 2025 02:33
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants