-
Notifications
You must be signed in to change notification settings - Fork 196
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
Move C# and Html document generation (ie, compilation) to the Cohost side of the world #9766
Conversation
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 :)
src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/Cohost/OpenDocumentGenerator.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/Cohost/OpenDocumentGenerator.cs
Show resolved
Hide resolved
// 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/Cohost/OpenDocumentGenerator.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/Cohost/OpenDocumentGenerator.cs
Outdated
Show resolved
Hide resolved
return _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync( | ||
() => _razorProjectService.UpdateDocument(uri.GetAbsoluteOrUNCPath(), sourceText, version), | ||
cancellationToken); | ||
await await _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync(async () => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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" 😁
src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/Cohost/DidChangeHandler.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/Cohost/OpenDocumentGenerator.cs
Outdated
Show resolved
Hide resolved
return _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync( | ||
() => _razorProjectService.UpdateDocument(uri.GetAbsoluteOrUNCPath(), sourceText, version), | ||
cancellationToken); | ||
await await _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync(async () => |
There was a problem hiding this comment.
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 :)
src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/Cohost/OpenDocumentGenerator.cs
Show resolved
Hide resolved
// 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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/Cohost/OpenDocumentGenerator.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/Cohost/OpenDocumentGenerator.cs
Show resolved
Hide resolved
src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/Cohost/OpenDocumentGenerator.cs
Show resolved
Hide resolved
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. |
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