Skip to content

Cohost Razor and Roslyn to better share object types and object instances #9519

@phil-allen-msft

Description

@phil-allen-msft

Individual endpoint status: #10364

In no particular order:

  1. Moving off IDynamciFileInfo
  2. Razor calling Roslyn via C# API
  3. Pull data from SG
  4. Miscellaneous files, and custom or non-Razor SDK usage and how that could work
    • Scenario is projects that don’t reference the source generator, and don’t have .cshtml and .razor files as AdditionalDocuments.
    • Can we have a service that allows customization/custom creation of a project in Misc Files workspace – Razor could add additional document and source generator reference
    • Could Project System lie to Roslyn and add an additional file, instead/as well as dynamic
      • Doesn't help in the C# extension without devkit, where that code doesn't exist
      • Doing it in Roslyn would solve for DevKit and non
      • We could however do it through https://github.com/dotnet/project-system/blob/main/src/Microsoft.VisualStudio.ProjectSystem.Managed/ProjectSystem/DesignTimeTargets/Microsoft.CSharp.DesignTime.targets (or equiv in VS Code)
        • We can add .razor and .cshtml as additional documents, and we can reference the source generator, and Roslyn and everything else will be none the wiser
        • Need to ensure nothing conflicts with the real Web and Razor sdks, and what they do
        • Should also create a <DefaultRazorFileIdeSupport>false</DefaultRazorFileIdeSupport> get-out-of-jail-free property that people can specify to disable the behaviour if it causes problems
          • At the end of the day, people who have "weird" set ups can solve their issues with MS Build goo (add additional documents, reference source gen), but the upgrade experience is bad. Is it better if we do that for them, in a way that only affects design time, and give them an opt-out if it causes issues?
    • Could Roslyn just add all dynamic files as additional documents?
      • Needs to be sensitive to duplicates
      • Gets difficult to thread things through, as projects change SDKs and people modify things.
      • Using misc files is easier as every individual file is isolated. Is that an acceptable tooling experience though?
    • We can hook into miscellaneous file creation easily enough:
      • Currently every individual misc file in Roslyn gets its own project, logic is here which is called from here
      • These methods won't be called for .razor files now, because Roslyn doesn't own the buffer, so we'd have to call them through EA.
      • Possibly just as easy for us to create our own misc files project(s), with the right references etc., and expose a way to add them to the Roslyn misc workspace. As long as the LSP server can find them again, the rest shouldn't really matter
      • Will need separate hooks for VS Code
      • Won't help if a file is an AdditionalDocument, but the source generator isn't referenced
  5. Dynamic registration
  6. Legacy Editor
    • Still needs Razor Project System?
      • ANSWER: Yes
    • Still needs IDynamicFileInfo?
      • ANSWER: Yes, for background compilation so local tag helpers are found
      • To discuss: Suppress generator in Legacy only, but not LSP?
        • Also needed when Cohost feature flag is off
  7. Faults and telemetry etc.
    • Need to make sure faults from cohost end points can be routed to the Razor team easily
      • Currently being reported by the Roslyn LSP server
      • Should Razor report them too?
      • Can we have a mechanism where Roslyn knows to categorize as razor (LSP request language name?) or override the fault event name itself?
        • We have a mechanism like this in place for logging, for VS Code, so could use that perhaps
  8. Roslyn options
    • They don't sync to OOP automatically sadly, so code in OOP always gets defaults
    • Roslyn uses callbacks for getting options values on demand. Razor services don't have callbacks, and if they did, they couldn't get the Roslyn options
    • To Discuss: Can we create a generic system so our EA can fill in options somehow? Will do as they come up. Razor should pass options to Roslyn anyway.
    • Expect Razor files do not respect C# code style new line rules #11276 to regress without some action here Fixed
  9. VS Code follow up
    • Log with a custom message to get logs in the Razor output window Allow the Roslyn client to log messages from Razor vscode-csharp#8201
    • Check instructions for the "Report an Issue" command, and TODO include feature flag values when reporting.
    • Settings: ClientSettingsReader is just one big TODO right now
    • In DevKit, Roslyn registered doc sync endpoints for Razor files. In cohosting we need to do this always. Right now these things happen in different repos, and possibly both at the same time, which could be bad.
    • Telemetry needs to be hooked up properly in the VS Code extension
    • Initialization feels slow. Need to make sure we're not doing anything non-cohosting, and consider "warming up" the Razor MEF composition (and/or add caching?)
    • Restore documents don't refresh themselves, so are stuck in a bad state until an edit/scroll/resize
    • Need to communicate back to the HtmlDocumentSynchronizer when a Razor document is closed, we can remove any synchronization tasks

Sub-issues

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions