Skip to content
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

Uri Presentation Part 2, aka Cohost Html on-demand generation #10359

Merged
merged 17 commits into from
May 14, 2024

Conversation

davidwengier
Copy link
Contributor

Part of #9519

Commit at a time might be easier. Not really sure.

This PR finished off Uri Presentation in cohosting, but more importantly it brings html document generation to cohosting. The generation is done completely on-demand as we get a request for a document, and in general is much simpler than the current system, because whilst we still need to push the document to a VS buffer, we don't have to wait for the document to be pushed to VS from the LSP server, and synchronize those two pushes. This isn't doing any buffer management specifically for cohosting yet, but all of that is still needed for C# anyway, at the moment.

Copy link
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

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

There's lots to like here!

Comment on lines +54 to +56
// TODO: Eventually, for VS Code, the following piece of logic needs to make an LSP call rather than directly update the
// buffer, but the assembly this code currently lives in doesn't ship in VS Code, so we need to solve a few other things
// before we get there.
Copy link
Member

Choose a reason for hiding this comment

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

Does this need an issue filed for tracking?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO, no, this is just a note to future explorers when bringing cohosting to VS Code. An item specifically for this would be overkill.

ILoggerFactory loggerFactory)
: IHtmlDocumentSynchronizer
{
private static readonly Task<bool> s_falseTask = Task.FromResult(false);
Copy link
Member

Choose a reason for hiding this comment

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

Should there be a SpecializedTasks helper class like Roslyn's in Shared.Utilities?

https://sourceroslyn.io/#Microsoft.CodeAnalysis.Workspaces/SpecializedTasks.cs,25dbc38fd8ac0df3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be honest, I'm not sure why I even did this. I don't even expect the scenario where its used to be super common that it would show up on a trace. Having said that, creating finding all of the places a SpecializedTasks helper could be used sounds like a good thursday evening job :)

@davidwengier
Copy link
Contributor Author

Note to self: Can't merge before the corresponding Roslyn insertion


namespace Microsoft.CodeAnalysis.Razor.DocumentPresentation;

internal static class UriPresentationHelper
{
public static Uri? GetComponentFileNameFromUriPresentationRequest(RazorLanguageKind languageKind, Uri[]? uris, ILogger logger)
public static Uri? GetComponentFileNameFromUriPresentationRequest(Uri[]? uris, ILogger logger)
Copy link
Member

Choose a reason for hiding this comment

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

Observation: (nit since it is an internal API anyway, but) This API no longer takes language kind and seems like it is now HTML-specific. Your comments are at the caller level where you've moved this logic out to, but at the API level here, it is not obvious for someone looking at it later to know this is actually now HTML-specific (class or API or implementation doesn't make it obvious).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO it's quite the opposite. Except for the block of code I moved, the method has nothing to do with a specific language at all, its only job is to reason about the set of Uris passed in. What any caller chooses to do with the result is up to the caller. Thats why the language check was out of place.

@davidwengier davidwengier merged commit 5ec07b3 into dotnet:main May 14, 2024
12 checks passed
@davidwengier davidwengier deleted the CohostUriPresentationPart2 branch May 14, 2024 07:19
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone May 14, 2024
@Cosifne Cosifne removed this from the Next milestone May 28, 2024
@Cosifne Cosifne added this to the 17.11 P2 milestone May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants