Skip to content

Conversation

akhera99
Copy link
Member

Fixes #76656

@akhera99 akhera99 requested a review from a team as a code owner June 16, 2025 16:16
{
return fieldSymbol;
foreach (var declarator in node.DescendantNodes().OfType<SyntaxNode>()
.Where(n => _syntaxFacts.IsVariableDeclarator(n)))
Copy link
Member

Choose a reason for hiding this comment

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

so this is a case where you want the descendent nodes to not descend in once you've hit an IsVariableDeclarator node.

Imagine you have something like Action f = () => { var v = methodInvocation(); }. You'll hit both the f = ... declarator and the v = ... declarator.

Technically, not the end of the world here as you validate you're getting an IFieldSymbol. But it's subtle and potentially a problem in the future. so better is to not descend any further once you hit the first layer of variable declarators.

does that make sense?

@akhera99 akhera99 enabled auto-merge (squash) June 16, 2025 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception in CSharpInlineMethodRefactoringProvider when multiple fields are declared in a field declaration
4 participants