-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Avoid retaining memory while waiting for changes #67982
Conversation
src/Features/LanguageServer/Protocol/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs
Outdated
Show resolved
Hide resolved
This PR was completely rewritten to address a failure to clear all copies of data in a value type
/// <summary> | ||
/// The workspace this request is for, if applicable. This will be present if <see cref="Document"/> is | ||
/// present. It will be <see langword="null"/> if <c>requiresLSPSolution</c> is false. | ||
/// </summary> | ||
public readonly Workspace? Workspace; | ||
public Workspace? Workspace => _lspSolution?.Value.Workspace; |
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.
Can we make the exception a bit clearer if you use this after ClearSolutionContext is called? I assume you're doing the StrongBox to differentiate "this never had it" and "this was cleared", but that's not really confirmed anywhere.
(and frankly, I'm not sure why these wouldn't just throw if requiresLSPSolution is set, since I'd imagine that's a developer oops, but maybe I'm missing some context here)
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.
I assume you're doing the StrongBox to differentiate "this never had it" and "this was cleared"
No, the StrongBox<>
is required because every time RequestContext
is passed as an argument, a new copy is made. We need a common storage location for the references to Workspace and Solution that applies to all copies equally.
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.
➡️ Added code to throw for access to these properties if the solution context was initially available and has since been cleared.
Fixes AB#1809058