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

Move C# and Html document generation (ie, compilation) to the Cohost side of the world #9766

Conversation

davidwengier
Copy link
Contributor

In theory this means the end of document sync issues forever!

In practice there is one fire-and-forget async method call here, from a sync context, so edge cases will still creep in. But all of this code should be deleted eventually anyway :D

This still leaves in place the text sync endpoints, and updates to the LSP servers
project system, so that everything else functions as expected
This also nicely lets us Find All Refs on the Cohost feature flag and see all of the code that can be deleted :)
@davidwengier davidwengier requested a review from a team as a code owner December 27, 2023 04:56
// The server clearly wants to tell us about a document in a project, but we don't know which project it's in.
// Sadly there isn't anything we can do here to, we're just in a state where the server and client are out of
// sync with their understanding of the document contents, and since changes come in as a list of changes,
// the user experience is broken. All we can do is hope the user closes and re-opens the document.
Copy link
Contributor

Choose a reason for hiding this comment

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

All we can do is hope the user closes and re-opens the document.

Should we show a shell message box to the user asking them to do that?

return _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync(
() => _razorProjectService.UpdateDocument(uri.GetAbsoluteOrUNCPath(), sourceText, version),
cancellationToken);
await await _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync(async () =>
Copy link
Contributor

Choose a reason for hiding this comment

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

_projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync

just for my education - curious why projectSnapshotManager needs it's own dispatcher and when should we run on that dispatcher's thread. We can chat in sync-up if it's a long answer :)

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a long, and hopefully eventually removed, answer :)

Copy link
Contributor Author

@davidwengier davidwengier Dec 27, 2023

Choose a reason for hiding this comment

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

The questions in this PR are all excellent and unfortunately the answer to most of them is "yes, this is not ideal, but hopefully we can remove it eventually" 😁

Copy link
Contributor

@alexgav alexgav left a comment

Choose a reason for hiding this comment

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

:shipit:

return _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync(
() => _razorProjectService.UpdateDocument(uri.GetAbsoluteOrUNCPath(), sourceText, version),
cancellationToken);
await await _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync(async () =>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a long, and hopefully eventually removed, answer :)

// sync with their understanding of the document contents, and since changes come in as a list of changes,
// the user experience is broken. All we can do is hope the user closes and re-opens the document.
Debug.Fail($"Server wants to update {documentSnapshot.Uri} in {projectKey} but we don't know about the document being in any projects");
_logger.LogError("[Cohost] Server wants to update {hostDocumentUri} in {projectKeyId} by we only know about that document in misc files. Server and client are now out of sync.", documentSnapshot.Uri, projectKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

Might as well include a "closing and opening the document may fix this issue" if a user happens to look at the logs.

// sync with their understanding of the document contents, and since changes come in as a list of changes,
// the user experience is broken. All we can do is hope the user closes and re-opens the document.
Debug.Fail($"Server wants to update {documentSnapshot.Uri} in {projectKey} but we don't know about the document being in any projects");
_logger.LogError("[Cohost] Server wants to update {hostDocumentUri} in {projectKeyId} by we only know about that document in misc files. Server and client are now out of sync.", documentSnapshot.Uri, projectKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we fault on states like this? Is there really nothing we can do, or is it we don't know what causes this yet?

@davidwengier
Copy link
Contributor Author

davidwengier commented Dec 28, 2023

Thanks for the feedback.. Have address most of it, and I've adjusted some of the edge cases to be a bit more aggressive about failing, but I left the user experience unchanged in a release build, because I hope this code is not around any more once we start rolling the feature flag out to users.

@davidwengier davidwengier merged commit 2ded3ad into dotnet:features/cohost Dec 28, 2023
12 checks passed
@davidwengier davidwengier deleted the dev/dawengie/GenerateOnCohostOnly branch December 28, 2023 05:11
davidwengier added a commit that referenced this pull request Jan 5, 2024
Part of #9519

Now that the initial cohost PR has been merged, we don't need to use the
feature branch any more. That means this PR, which is big, but all of
the code in it has been reviewed, in
#9761,
#9766 and
#9767.
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.

3 participants