Skip to content
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

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

Merged
merged 6 commits into from
Jan 14, 2022

Conversation

CyrusNajmabadi
Copy link
Member

@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
Copy link
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
Member

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
Member 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
Member 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
Member Author

/azp run

@Youssef1313
Copy link
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
Member Author

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

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@CyrusNajmabadi
Copy link
Member 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