-
Notifications
You must be signed in to change notification settings - Fork 199
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
DoumentState does not import _Imports because C:\pathto\_Imports.razor
is not treated the same as c:\pathto\_Imports.razor
#10007
Comments
I don't think its the uppercase/lowercase letter. razor/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs Lines 64 to 65 in 58db842
but _documents uses a special comparer that ignores casing and normalizes slashes to avoid issues.razor/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs Line 29 in 58db842
Unless you're on a case sensitive operating system? But given the screenshots are from Windows I'm guessing you're not bothering to go through the fun of remote debugging (and if you are, do you want a job, because I don't think I know how to do that myself!) The "item" in your last sceeenshot is |
For better or worse, my project has an I did start looking at FilePathNormlaize, but came to the conclusion I was out of my depth and needed to some direction on whether the bug is in comparing paths or within the way with vscode delivers the "ProjectPath". I didn't see a test for the comparer for this specific scenario of mismatched dive letter caseing. I am debugging (on windows) by building razor on my machine and attaching it to the running instance of rzls that the debug instance of vcode launches when you run the "Launch Extension" debug task. |
Yes, no argument there. Your screenshot shows them correctly in |
…lowered before calculating the hashcode. dotnet#10007
@davidwengier Not at all, that wasn't how I took it. Turns out I was tired enough to not even realize that 1 of the 2 import files didn't actually exist in my project. The "temporary API method"
Even with the change I made to I can't, for the time being at least, get my head wrapped around how the list of valid TagHelpers is built. The other odd thing of note is how often the snapshot DocumentCount and _documents.Count is mismatched while RazorEngine is executing the phases. I would expect _documents to stay consistent once the project fully loaded, this could also be bad assumption. Apologies for all the discourse. |
There are two halves to how Razor works in VS Code: One half runs in Roslyn, and looks through the compilation for all "tag helpers" and serializes that information to the The other half is the code in our repo that reads the
|
Not at all. If its easier to chat over Discord or email, feel free to reach out. I'm the same alias on the C# Discord (https://discord.gg/csharp) or my email is david dot wengier at microsoft dot com. |
I found a (the?) bug! I must apologise @rsandbach, I was wrong, and case sensitivity absolutely could be the issue. I am investigating an internal bug and it seems that whilst we do specify the converter on the dictionary, and that converter is case insensitive, its |
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1957989 and hopefully also #10007 When I added `FilePathNormalizingComparer` I failed to test `GetHashCode` and it has a bug, meaning the comparer didn't work in dictionaries. For some as-yet unknown reason this seems to only be a problem on the first load of a new project in VS Code. 🤷♂️
I am getting language service errors using dotnet/vscode-csharp that components do not exist.
I think the issue is that
DocumentStates.GetImportsCore()
is not bringing in any project_Imports.razor
files when conducting document analysis on the current file (App.razor
). It does include the defaultglobal::
usings.I can resolve the errors by adding a using statement to
App.razor
.In my case,
item.PhysicalPath
has an uppercase "C" for the drive letter, but all of the dictionary keys (file paths) for _document in projectSnapshot have a lowercase "c". The result ofproject.GetDocument(item.PhysicalPath)
is a null, instead of the actual object import file contents.While debugging I can confirm that the import files are added by each feature here:
razor/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.cs
Lines 234 to 237 in af11d85
Since the result of
project.GetDocument()
is null, they aren't actually added for analysis.razor/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentState.cs
Lines 247 to 259 in af11d85
The ComponentImportProjectFeature seems to be returning the document paths with an uppercase drive
razor/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/Language/Components/ComponentImportProjectFeature.cs
Lines 45 to 48 in af11d85
We can see there is a mismatch between the file paths in documents and import files.
The uppercase letter seems to be coming from however HostProject.FilePath is exposed, but not sure if this is a razor or vscode-csharp issue. :)
razor/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs
Line 206 in af11d85
The text was updated successfully, but these errors were encountered: