Skip to content
代码片段 群组 项目
提交 ffb63164 编辑于 作者: Dustin Campbell's avatar Dustin Campbell
浏览文件

Fix crash in Inline Rename

As the types into an Inline Rename field, the Rename engine attempts to resolve conflicts at each reference. It does this by expanding nodes are the references and then simplifying them down to the smallest node that does not change semantics.

During this process, one of the expansion steps is to add explicit types to lambda parameters that were defined without types. However, the expander wasn't rewriting lambdas with multiple parameters correctly. Essentially, the rewriter assumed that, when replacing a node within a `SeparatedSyntaxList<T>`, the identities of other nodes within the list would not change. However, that's not the case. So, it would successfully replace the first parameter within a lambda's parameter list. However, when it attempted to replace the second parameter, the *original* second parameter could no longer be found in the `SeparatedSyntaxList<T>` because the identity of the second parameter in the list had changed. At this point, `SepratedSyntaxList<T>.Replace(...)` would throw an `ArgumentOutOfRangeException` and VS would crash.

The user scenario is that typing within an Inline Rename field can cause Visual Studio to simply crash, resulting in potenal data loss.

The fix changes the rewriter to not pass the original parameters to `SeparatedSyntaxList<T>.Replace(...)`. Instead, it passes the parameters that are contained when the new list as it builds it up.

This is a regression introduced after Update 1 with PR #6432.
上级 8b547268
No related branches found
No related tags found
无相关合并请求
......@@ -197,7 +197,9 @@ public override SyntaxNode VisitParenthesizedLambdaExpression(ParenthesizedLambd
{
var typeSyntax = parameterSymbols[i].Type.GenerateTypeSyntax().WithTrailingTrivia(s_oneWhitespaceSeparator);
var newParameter = parameters[i].WithType(typeSyntax).WithAdditionalAnnotations(Simplifier.Annotation);
newParameters = newParameters.Replace(parameters[i], newParameter);
var currentParameter = newParameters[i];
newParameters = newParameters.Replace(currentParameter, newParameter);
}
var newParameterList = parameterList.WithParameters(newParameters);
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册