Do not return empty nodes in the refactoring helpers service.#58830
Conversation
ab7680a to
18721c7
Compare
There was a problem hiding this comment.
I think the fix could be in line 137 (AbstractAddParameterCheckCodeRefactoringProvider.cs
), which might be missing getInnermostNodeForTie: true
var firstParameterNode = (TParameterSyntax)root.FindNode(parameterSpan);The challenge is to find a test case. Is there any scenario where the syntax tree can contain a ParameterList with missing parenthesis? this is a case where the ParameterSyntax and ParameterListSyntax might have the same span, so the cast will fail.
This could cause a problem for simple lambdas, where the parameter span is the same as the identifier span. |
Yes, i thought that was likely teh case too. However, i still can't figure out a repro for this. As such, i didn't want to make a change that doesn't certainly fix things. This change at least lets us know what is going on so we can narrow this down :) |
Technically that would be ok as this is FindNode and the 'identifier' is a token. That said, i still can't figure out how FindNode, when given the span of a parameter, is getting the ParameterList back instead. Taht's the weird thing here. |
|
/azp run |
Going to see if #58845 can hint to a repro |
|
actually i have a theory. let me try out parameters that are missing. that might cause some issues here. |
|
Azure Pipelines successfully started running 4 pipeline(s). |
Yes. This is the case that hits this. |
Fixes #58811