Don't assume misc files are documents#81785
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.
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.
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.
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.
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?