未验证 提交 8df7f5ca 编写于 作者: D Dustin Campbell 提交者: GitHub

Merge pull request #25225 from Neme12/concatToInterpolatedString

Fixing NullReferenceException inside ConvertToInterpolatedString
......@@ -398,6 +398,36 @@ void M()
{
var v = ""A"" + 1 + [||]""B"" + @""C"";
}
}");
}
[WorkItem(20943, "https://github.com/dotnet/roslyn/issues/20943")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsConvertToInterpolatedString)]
public async Task TestMissingWithDynamic1()
{
await TestMissingInRegularAndScriptAsync(
@"class C
{
void M()
{
dynamic a = ""b"";
string c = [||]""d"" + a + ""e"";
}
}");
}
[WorkItem(20943, "https://github.com/dotnet/roslyn/issues/20943")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsConvertToInterpolatedString)]
public async Task TestMissingWithDynamic2()
{
await TestMissingInRegularAndScriptAsync(
@"class C
{
void M()
{
dynamic dynamic = null;
var x = dynamic.someVal + [||]"" $"";
}
}");
}
}
......
......@@ -190,9 +190,9 @@ private static SyntaxNode ConcatinateTextToTextNode(SyntaxGenerator generator, S
return false;
}
var method = semanticModel.GetSymbolInfo(expression, cancellationToken).Symbol as IMethodSymbol;
return method?.MethodKind == MethodKind.BuiltinOperator &&
method.ContainingType.SpecialType == SpecialType.System_String &&
return semanticModel.GetSymbolInfo(expression, cancellationToken).Symbol is IMethodSymbol method &&
method.MethodKind == MethodKind.BuiltinOperator &&
method.ContainingType?.SpecialType == SpecialType.System_String &&
(method.MetadataName == WellKnownMemberNames.AdditionOperatorName ||
method.MetadataName == WellKnownMemberNames.ConcatenateOperatorName);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册