-
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
Fix NRE when invoking completion in empty document #10610
Conversation
In empty document completion context will have RazorDocumentSyntax as Owner. RazorDoucmentSyntax has null as the parent, which makes sense. However compiler thinks we can't have a null here, while obviously we do. I'm adding a null check and a test for this case. We would probably further discuss the implications here. I tried to track down how we get null in a non-nullable field, but it's a bit confusing since the class gets generated.
Thinking more about this though... Seems like we should get HTML tags and tag helpers when invoking completion in an empty document. Legacy editor has that - LSP Razor editor returns neither HTML tags nor tag helpers. Things to work better if you type in either I think we should get this fix in, and if we decided it's worth pursing, also log a bug for a better fix that will get tag names and tag helpers in the completion. |
...azor/src/Microsoft.AspNetCore.Razor.LanguageServer/Completion/TagHelperCompletionProvider.cs
Outdated
Show resolved
Hide resolved
What is the user impact of the null ref? I would imagine nothing other than telemetry or logs, so I don't think there is any point trying to get this in over just fixing completion so it works in this situation as expected. |
I investigated this more in terms of what it would take to "just fix the issue" 😄 and unfortunately it looks fairly complicated as I anticipated.
we'd need to change that (or at least special-case this for a completely empty document). A bit of a scary change (and would probably cause performance implications unless we special-cased it for the 0-length document case) Without that, position doesn't map to HTML (and completion request wouldn't get sent to HTML server)
We do get HTML snippets in that case, but not tags in the completion list in Razor. in HTML (LSP mode) we get nothing.
Given all of the above, I'd still say we should get this simple fix in and file bugs for the rest of the work (with some work done in WebTools by Vlad or his team). Or we could leave it as is (after fixing NRE) since we have no user feedback, and if the user actually starts typing (e.g. |
Thanks for the screenshot. Totally happy to take this fix since there is actual user impact. A real fix to have tooling handle empty documents (though my gut feeling is that we wouldn't want to change the compiler for that?) can come later if its complicated. I was hoping that simply using the owner, rather than its parent, in this case would just magically work :) |
Sadly no :( HtmlFacts has special cases as well, we'd need to add one more for RazorDocumentSyntax which isn't completely obvious (the existing ones go off of the Tag properties, and document is not a tag of course 😄)
Anyway - anything else to address in this one that we are waiting on or is it good to go? |
It just needs to compile 😛 |
Oh c'mon, it's a minor detail 😄 (fixed, local commit on my box wasn't pushed, oops) |
|
In empty document completion context will have RazorDocumentSyntax as Owner. RazorDoucmentSyntax has null as the parent, which makes sense. However compiler thinks we can't have a null here, while obviously we do.
I'm adding a null check and a test for this case. We would probably further discuss the implications here. I tried to track down how we get null in a non-nullable field, but it's a bit confusing since the class gets generated.
### Summary of the changes