-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Don't assume misc files are documents #81785
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
Conversation
| var documents = miscWorkspace.CurrentSolution.GetDocumentIdsWithFilePath(documentPath); | ||
| if (documents.Any()) | ||
| // Filter to actual documents, ignoring additional documents like Razor files etc. | ||
| var documentIds = solution.GetDocumentIdsWithFilePath(documentPath).WhereAsArray(id => solution.GetDocument(id) is not null); |
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.
im not sure this is quite right - razor docs are added as misc, and when we find the real one we need to remove the misc one. this will just cause it to leak.
might need to check below wjat kind of doc, and remove it
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.
Definitely not claiming to understand this, but the key change here in my mind is that this method not only doesn't error, but will now return false when it finds a Razor document. That allows the project system to fall back to the previous path and unload the misc project for the Razor file altogether.
It seems to me, from reading the code here, that since the CanonicalMiscFilesProjectLoader only ever adds documents, never additional documents, then it should only ever remove the same. Having said that, I don't know what "canonical" means in this scenario, nor why Razor files are ever seen in anything with "File Based" in the name.
What exactly does it mean to "leak" 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.
Sorry - I think you're right - the FBP loader will unload it if it returns false here. I missed that the FBP loader would actually do it if this returned false
| var documents = miscWorkspace.CurrentSolution.GetDocumentIdsWithFilePath(documentPath); | ||
| if (documents.Any()) | ||
| // Filter to actual documents, ignoring additional documents like Razor files etc. | ||
| var documentIds = solution.GetDocumentIdsWithFilePath(documentPath).WhereAsArray(id => solution.GetDocument(id) is not null); |
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.
Sorry - I think you're right - the FBP loader will unload it if it returns false here. I missed that the FBP loader would actually do it if this returned false
Fixes microsoft/vscode-dotnettools#2629
I could not get a test working for this, I don't fully understand all of the machinery here. The Razor file was always coming back as a misc file even after being added to a real project?