Skip to content

Do not return empty nodes in the refactoring helpers service.#58830

Merged
CyrusNajmabadi merged 6 commits into
dotnet:mainfrom
CyrusNajmabadi:captureInfo
Jan 14, 2022
Merged

Do not return empty nodes in the refactoring helpers service.#58830
CyrusNajmabadi merged 6 commits into
dotnet:mainfrom
CyrusNajmabadi:captureInfo

Conversation

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi commented Jan 13, 2022

Fixes #58811

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner January 13, 2022 04:46
@ghost ghost added the Area-IDE label Jan 13, 2022
Copy link
Copy Markdown
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sharwell
Copy link
Copy Markdown
Contributor

which might be missing getInnermostNodeForTie: true

This could cause a problem for simple lambdas, where the parameter span is the same as the identifier span.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

I think the fix could be in line 137 (AbstractAddParameterCheckCodeRefactoringProvider.cs
), which might be missing getInnermostNodeForTie: true

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 :)

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

This could cause a problem for simple lambdas, where the parameter span is the same as the identifier span.

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.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

/azp run

@Youssef1313
Copy link
Copy Markdown
Member

I think the fix could be in line 137 (AbstractAddParameterCheckCodeRefactoringProvider.cs
), which might be missing getInnermostNodeForTie: true

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 :)

Going to see if #58845 can hint to a repro

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

actually i have a theory. let me try out parameters that are missing. that might cause some issues here.

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 4 pipeline(s).

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

actually i have a theory. let me try out parameters that are missing. that might cause some issues here.

Yes. This is the case that hits this.

@CyrusNajmabadi CyrusNajmabadi changed the title Capture information to help track down a crash seen in the wild. Do not return empty nodes in the refactoring helpers service. Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InvalidCastException from AbstractAddParameterCheckCodeRefactoringProvider`5.UpdateDocumentForRefactoringAsync

6 participants